diff --git a/apps/vr-tests-react-components/src/stories/Field.stories.tsx b/apps/vr-tests-react-components/src/stories/Field.stories.tsx index 2e4b0f0a4a786..663edb6328523 100644 --- a/apps/vr-tests-react-components/src/stories/Field.stories.tsx +++ b/apps/vr-tests-react-components/src/stories/Field.stories.tsx @@ -6,7 +6,6 @@ import { CheckboxField, ComboboxField, InputField, - InputFieldProps, ProgressField, RadioGroupField, SelectField, @@ -16,85 +15,120 @@ import { TextareaField, } from '@fluentui/react-field'; import { SparkleFilled } from '@fluentui/react-icons'; +import { FieldComponent, FieldPropsWithOptionalComponentProps } from '@fluentui/react-field/src/Field'; -const AllFields = ( - props: Pick< - InputFieldProps, - 'orientation' | 'required' | 'label' | 'validationState' | 'validationMessage' | 'validationMessageIcon' | 'hint' - >, -) => { - return ( -
- - - - - - - - - - - - - - - - -
- ); -}; +type FieldComponentProps = Pick< + FieldPropsWithOptionalComponentProps, + 'orientation' | 'required' | 'label' | 'validationState' | 'validationMessage' | 'validationMessageIcon' | 'hint' +>; -storiesOf('Field Converged', module) - .addDecorator(story => ( -
-
- {story()} +/** + * Common VR tests for all field components. Pass the given Field component (or a wrapper around it). + */ +const storiesOfField = (name: string, Field: React.VoidFunctionComponent) => + storiesOf(name, module) + .addDecorator(story => {story()}) + .addDecorator(story => ( +
+
+ {story()} +
-
- )) - .addStory('base', () => ) - .addStory('required', () => ) - .addStory('validation:error', () => ) - .addStory('validation:warning', () => ) - .addStory('validation:success', () => ) - .addStory('validation:custom', () => ( - } validationMessage="Custom message" /> - )) - .addStory('hint', () => ) - .addStory('horizontal', () => ) - .addStory('horizontal+label:multiline', () => ( - - )) - .addStory('horizontal+validation:error+hint', () => ( - - )) - .addStory('size:small', () => ( -
- - - - - - - - -
- )) - .addStory('size:large', () => ( -
- - - - - - - -
- )) - .addStory('CheckboxField+fieldLabel', () => ( - - )); + )) + .addStory('base', () => ) + .addStory('required', () => ) + .addStory('validation', () => ( +
+ + + + } + validationMessage="Custom message" + /> +
+ )) + .addStory('hint', () => ) + .addStory('horizontal', () => ( + + )); + +/** + * Same as storiesOfField, but with extra stories for Field components that support the size prop. + */ +const storiesOfFieldWithSize = ( + name: string, + Field: React.VoidFunctionComponent, +) => + storiesOfField(name, Field) + .addStory('size:small', () => ) + .addStory('size:large', () => ); + +// +// CheckboxField +// +storiesOfField('CheckboxField converged', CheckboxField) + .addStory('size:large', () => ) + .addStory('fieldLabel', () => ); + +// +// ComboboxField +// +storiesOfFieldWithSize('ComboboxField converged', ComboboxField); + +// +// InputField +// +storiesOfFieldWithSize('InputField converged', InputField); + +// +// ProgressField +// +storiesOfField('ProgressField converged', props => ); + +// +// RadioGroupField +// +storiesOfField('RadioGroupField converged', props => ( + + + + + +)); + +// +// SelectField +// +storiesOfFieldWithSize('SelectField converged', props => ( + + + +)); + +// +// SliderField +// +storiesOfField('SliderField converged', SliderField); + +// +// SpinButtonField +// +storiesOfField('SpinButtonField converged', SpinButtonField); + +// +// SwitchField +// +storiesOfField('SwitchField converged', SwitchField); + +// +// TextareaField +// +storiesOfFieldWithSize('TextareaField converged', TextareaField);