Skip to content

Commit

Permalink
feat: add SliderField primitive (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch authored Nov 15, 2021
1 parent 906096d commit 78209e2
Show file tree
Hide file tree
Showing 14 changed files with 3,623 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,43 @@ export default function SimplePropertyBindingDefaultValue(
}
`;
exports[`amplify render tests primitives SliderField 1`] = `
"/* eslint-disable */
import React from \\"react\\";
import {
EscapeHatchProps,
SliderField,
SliderFieldProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
export type SliderFieldPrimitiveProps = React.PropsWithChildren<
Partial<SliderFieldProps> & {
overrides?: EscapeHatchProps | undefined | null;
}
>;
export default function SliderFieldPrimitive(
props: SliderFieldPrimitiveProps
): React.ReactElement {
const { overrides: overridesProp, ...rest } = props;
const overrides = { ...overridesProp };
return (
/* @ts-ignore: TS2322 */
<SliderField
name=\\"slider\\"
label=\\"Slider\\"
defaultValue={50}
min={0}
max={100}
step={1}
{...rest}
{...getOverrideProps(overrides, \\"SliderField\\")}
></SliderField>
);
}
"
`;
exports[`amplify render tests primitives TextField 1`] = `
"/* eslint-disable */
import React from \\"react\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ exports[`Primitives SearchField 1`] = `"<SearchField {...rest} {...getOverridePr

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

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

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

exports[`Primitives SwitchField 1`] = `"<SwitchField {...rest} {...getOverrideProps(overrides, \\"SwitchField\\")}></SwitchField>"`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,9 @@ describe('amplify render tests', () => {
test('TextField', () => {
expect(generateWithAmplifyRenderer('primitives/TextFieldPrimitive').componentText).toMatchSnapshot();
});

test('SliderField', () => {
expect(generateWithAmplifyRenderer('primitives/SliderFieldPrimitive').componentText).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"id": "1234-5678-9010",
"componentType": "SliderField",
"name": "SliderFieldPrimitive",
"properties": {
"name": {
"value": "slider"
},
"label": {
"value": "Slider"
},
"defaultValue": {
"value": "50",
"type": "Number"
},
"min": {
"value": "0",
"type": "Number"
},
"max": {
"value": "100",
"type": "Number"
},
"step": {
"value": "1",
"type": "Number"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
ScrollViewProps,
SearchFieldProps,
SelectFieldProps,
SliderFieldProps,
StepperFieldProps,
SwitchFieldProps,
TabItemProps,
Expand Down Expand Up @@ -240,6 +241,9 @@ export class AmplifyRenderer extends ReactStudioTemplateRenderer {
parent,
).renderElement(renderChildren);

case Primitive.SliderField:
return new ReactComponentRenderer<SliderFieldProps>(component, this.importCollection, parent).renderElement();

case Primitive.StepperField:
return new ReactComponentWithChildrenRenderer<StepperFieldProps>(
component,
Expand Down
1 change: 1 addition & 0 deletions packages/studio-ui-codegen-react/lib/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum Primitive {
ScrollView = 'ScrollView',
SearchField = 'SearchField',
SelectField = 'SelectField',
SliderField = 'SliderField',
StepperField = 'StepperField',
SwitchField = 'SwitchField',
Tabs = 'Tabs',
Expand Down
Loading

0 comments on commit 78209e2

Please sign in to comment.