Skip to content

Commit

Permalink
fix: removing label override for checkbox field, and removing label, …
Browse files Browse the repository at this point in the history
…which is not in primitives
  • Loading branch information
alharris-at committed Nov 19, 2021
1 parent 37a3463 commit c819478
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,40 @@ export default function MyIconCloud(
"
`;
exports[`amplify render tests primitives CheckboxField 1`] = `
"/* eslint-disable */
import React from \\"react\\";
import {
CheckboxField,
CheckboxFieldProps,
EscapeHatchProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
export type CheckBoxFieldPrimitiveProps = React.PropsWithChildren<
Partial<CheckboxFieldProps> & {
overrides?: EscapeHatchProps | undefined | null;
}
>;
export default function CheckBoxFieldPrimitive(
props: CheckBoxFieldPrimitiveProps
): React.ReactElement {
const { overrides: overridesProp, ...rest } = props;
const overrides = { ...overridesProp };
return (
/* @ts-ignore: TS2322 */
<CheckboxField
label=\\"Subscribe\\"
name=\\"subscribe\\"
value=\\"yes\\"
{...rest}
{...getOverrideProps(overrides, \\"CheckboxField\\")}
></CheckboxField>
);
}
"
`;
exports[`amplify render tests primitives SliderField 1`] = `
"/* eslint-disable */
import React from \\"react\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ exports[`Primitives Icon 1`] = `"<Icon {...rest} {...getOverrideProps(overrides,

exports[`Primitives Image 1`] = `"<Image {...rest} {...getOverrideProps(overrides, \\"Image\\")}></Image>"`;

exports[`Primitives Label 1`] = `"<Label {...rest} {...getOverrideProps(overrides, \\"Label\\")}></Label>"`;

exports[`Primitives Link 1`] = `"<Link {...rest} {...getOverrideProps(overrides, \\"Link\\")}></Link>"`;

exports[`Primitives Loader 1`] = `"<Loader {...rest} {...getOverrideProps(overrides, \\"Loader\\")}></Loader>"`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ describe('amplify render tests', () => {
expect(generateWithAmplifyRenderer('primitives/SliderFieldPrimitive').componentText).toMatchSnapshot();
});

test('CheckboxField', () => {
expect(generateWithAmplifyRenderer('primitives/CheckboxFieldPrimitive').componentText).toMatchSnapshot();
});

test('Built-in Iconset', () => {
expect(generateWithAmplifyRenderer('builtInIconset').componentText).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "1234-5678-9010",
"componentType": "CheckboxField",
"name": "CheckBoxFieldPrimitive",
"properties": {
"label": {
"value": "Subscribe"
},
"name": {
"value": "subscribe"
},
"value": {
"value": "yes"
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
HeadingProps,
IconProps,
ImageProps,
LabelProps,
LinkProps,
LoaderProps,
PaginationProps,
Expand Down Expand Up @@ -156,13 +155,6 @@ export class AmplifyRenderer extends ReactStudioTemplateRenderer {
case Primitive.Image:
return new ReactComponentRenderer<ImageProps>(component, this.importCollection, parent).renderElement();

case Primitive.Label:
return new ReactComponentWithChildrenRenderer<LabelProps>(
component,
this.importCollection,
parent,
).renderElement(renderChildren);

case Primitive.Link:
return new ReactComponentWithChildrenRenderer<LinkProps>(
component,
Expand Down
5 changes: 0 additions & 5 deletions packages/codegen-ui-react/lib/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ enum Primitive {
Heading = 'Heading',
Icon = 'Icon',
Image = 'Image',
Label = 'Label',
Link = 'Link',
Loader = 'Loader',
Pagination = 'Pagination',
Expand Down Expand Up @@ -67,17 +66,13 @@ export const PrimitiveChildrenPropMapping: Partial<Record<Primitive, string>> =
[Primitive.Badge]: 'label',
[Primitive.Button]: 'label',
[Primitive.Heading]: 'label',
[Primitive.Label]: 'label',
[Primitive.Link]: 'label',
// [Primitive.MenuButton]: 'label',
// [Primitive.MenuItem]: 'label',
[Primitive.Radio]: 'label',
// [Primitive.TableCell]: 'label',
[Primitive.Text]: 'label',
[Primitive.ToggleButton]: 'label',

// remove once label is added in Amplify UI
[Primitive.CheckboxField]: 'label',
};

export const PrimitiveTypeParameter: Partial<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ describe('Generated Components', () => {
.should(
'have.attr',
'd',
'M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z',
'M12 6C14.62 6 16.88 7.86 17.39 10.43L17.69 11.93L19.22 12.04C20.78 12.14 22 13.45 22 15C22 16.65 20.65 18 19 18H6C3.79 18 2 16.21 2 14C2 11.95 3.53 10.24 5.56 10.03L6.63 9.92L7.13 8.97C8.08 7.14 9.94 6 12 6ZM12 4C9.11 4 6.6 5.64 5.35 8.04C2.34 8.36 0 10.91 0 14C0 17.31 2.69 20 6 20H19C21.76 20 24 17.76 24 15C24 12.36 21.95 10.22 19.35 10.04C18.67 6.59 15.64 4 12 4Z',
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('Primitives', () => {
cy.get('path').should(
'have.attr',
'd',
'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z',
'M11 7H13V9H11V7ZM11 11H13V17H11V11ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z',
);
});
});
Expand All @@ -128,13 +128,6 @@ describe('Primitives', () => {
});
});

describe('Label', () => {
it('Basic', () => {
cy.visit('http://localhost:3000/primitives-tests');
cy.get('#label').find('label').should('have.text', 'Hello world');
});
});

describe('Link', () => {
it('Basic', () => {
cy.visit('http://localhost:3000/primitives-tests');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
HeadingPrimitive,
IconPrimitive,
ImagePrimitive,
LabelPrimitive,
LinkPrimitive,
LoaderPrimitive,
PaginationPrimitive,
Expand Down Expand Up @@ -95,10 +94,6 @@ export default function PrimitivesTests() {
<Heading>Image</Heading>
<ImagePrimitive />
</View>
<View id="label">
<Heading>Label</Heading>
<LabelPrimitive />
</View>
<View id="link">
<Heading>Link</Heading>
<LinkPrimitive />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
"componentType": "CheckboxField",
"name": "CheckboxFieldPrimitive",
"properties": {
"children": {
"label": {
"value": "Subscribe"
},
"name": {
"value": "subscribe"
},
"value": {
"value": "yes"
}
}
}

This file was deleted.

1 change: 0 additions & 1 deletion packages/test-generator/lib/components/primitives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export { default as GridPrimitive } from './GridPrimitive.json';
export { default as HeadingPrimitive } from './HeadingPrimitive.json';
export { default as IconPrimitive } from './IconPrimitive.json';
export { default as ImagePrimitive } from './ImagePrimitive.json';
export { default as LabelPrimitive } from './LabelPrimitive.json';
export { default as LinkPrimitive } from './LinkPrimitive.json';
export { default as LoaderPrimitive } from './LoaderPrimitive.json';
export { default as PaginationPrimitive } from './PaginationPrimitive.json';
Expand Down
2 changes: 1 addition & 1 deletion scripts/integ-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm run integ:templates
# install
lerna bootstrap
lerna add --scope integration-test aws-amplify
lerna add --scope integration-test @aws-amplify/ui-react@0.0.0-next-d7c53a2-2021101311032
lerna add --scope integration-test @aws-amplify/ui-react@next
lerna add --scope integration-test @aws-amplify/datastore
lerna add --scope integration-test @aws-amplify/codegen-ui
lerna add --scope integration-test @aws-amplify/codegen-ui-react
Expand Down

0 comments on commit c819478

Please sign in to comment.