From aef3ee9147846515b6487ac351ee4a374022917c Mon Sep 17 00:00:00 2001 From: Brian Nguyen Date: Tue, 26 Sep 2023 13:57:45 -0700 Subject: [PATCH 1/5] Initial Form conversion --- .storybook/main.js | 1 + .storybook/storybook.requires.js | 11 +++ .../Form/HelpText/HelpText.constants.ts | 2 +- .../Form/HelpText/HelpText.stories.tsx | 60 ++++++---------- .../components/Form/Label/Label.stories.tsx | 32 +++------ .../Form/TextField/TextField.stories.tsx | 68 ++++++++++--------- .../components/Form/TextField/TextField.tsx | 2 +- .../Form/TextField/foundation/Input/Input.tsx | 4 +- .../TextFieldSearch.stories.tsx | 52 +++++++------- 9 files changed, 110 insertions(+), 122 deletions(-) diff --git a/.storybook/main.js b/.storybook/main.js index 84117eacb0e..8db13114a66 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -2,6 +2,7 @@ module.exports = { stories: [ '../app/component-library/components/Cards/Card/**/*.stories.?(ts|tsx|js|jsx)', '../app/component-library/components/Banners/Banner/variants/BannerAlert/**/*.stories.?(ts|tsx|js|jsx)', + '../app/component-library/components/Form/**/*.stories.?(ts|tsx|js|jsx)', ], addons: ['@storybook/addon-ondevice-controls'], framework: '@storybook/react-native', diff --git a/.storybook/storybook.requires.js b/.storybook/storybook.requires.js index 8614f98a259..0a700ba32d6 100644 --- a/.storybook/storybook.requires.js +++ b/.storybook/storybook.requires.js @@ -24,6 +24,13 @@ global.STORIES = [ importPathMatcher: "^\\.[\\\\/](?:app\\/component-library\\/components\\/Banners\\/Banner\\/variants\\/BannerAlert(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$", }, + { + titlePrefix: "", + directory: "./app/component-library/components/Form", + files: "**/*.stories.?(ts|tsx|js|jsx)", + importPathMatcher: + "^\\.[\\\\/](?:app\\/component-library\\/components\\/Form(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$", + }, ]; import "@storybook/addon-ondevice-controls/register"; @@ -50,6 +57,10 @@ const getStories = () => { return { "./app/component-library/components/Cards/Card/Card.stories.tsx": require("../app/component-library/components/Cards/Card/Card.stories.tsx"), "./app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx": require("../app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx"), + "./app/component-library/components/Form/HelpText/HelpText.stories.tsx": require("../app/component-library/components/Form/HelpText/HelpText.stories.tsx"), + "./app/component-library/components/Form/Label/Label.stories.tsx": require("../app/component-library/components/Form/Label/Label.stories.tsx"), + "./app/component-library/components/Form/TextField/TextField.stories.tsx": require("../app/component-library/components/Form/TextField/TextField.stories.tsx"), + "./app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx": require("../app/component-library/components/Form/TextFieldSearch/TextFieldSearch.stories.tsx"), }; }; diff --git a/app/component-library/components/Form/HelpText/HelpText.constants.ts b/app/component-library/components/Form/HelpText/HelpText.constants.ts index bcf93b5c456..23240c1f140 100644 --- a/app/component-library/components/Form/HelpText/HelpText.constants.ts +++ b/app/component-library/components/Form/HelpText/HelpText.constants.ts @@ -26,7 +26,7 @@ export const TEXT_COLOR_BY_HELPTEXT_SEVERITY: TextColorByHelpTextSeverity = { // Sample consts export const SAMPLE_HELPTEXT_TEXT = 'Sample HelpText Text'; -export const SAMPLE_LIST_ITEM_PROPS: HelpTextProps = { +export const SAMPLE_HELPTEXT_PROPS: HelpTextProps = { severity: DEFAULT_HELPTEXT_SEVERITY, children: SAMPLE_HELPTEXT_TEXT, }; diff --git a/app/component-library/components/Form/HelpText/HelpText.stories.tsx b/app/component-library/components/Form/HelpText/HelpText.stories.tsx index 75296616f93..63a87780b7c 100644 --- a/app/component-library/components/Form/HelpText/HelpText.stories.tsx +++ b/app/component-library/components/Form/HelpText/HelpText.stories.tsx @@ -1,42 +1,24 @@ -/* eslint-disable no-console */ - -// Third party dependencies. -import React from 'react'; -import { storiesOf } from '@storybook/react-native'; -import { select, text } from '@storybook/addon-knobs'; - -// External dependencies. -import { storybookPropsGroupID } from '../../../constants/storybook.constants'; - // Internal dependencies. -import HelpText from './HelpText'; -import { HelpTextProps, HelpTextSeverity } from './HelpText.types'; -import { - DEFAULT_HELPTEXT_SEVERITY, - SAMPLE_HELPTEXT_TEXT, -} from './HelpText.constants'; - -export const getHelpTextStoryProps = (): HelpTextProps => { - const helpTextText = text( - 'HelpText', - SAMPLE_HELPTEXT_TEXT, - storybookPropsGroupID, - ); - - const severitySelector = select( - 'severity', - HelpTextSeverity, - DEFAULT_HELPTEXT_SEVERITY, - storybookPropsGroupID, - ); - return { - children: helpTextText, - severity: severitySelector, - }; +import { default as HelpTextComponent } from './HelpText'; +import { SAMPLE_HELPTEXT_PROPS } from './HelpText.constants'; +import { HelpTextSeverity } from './HelpText.types'; + +const HelpTextMeta = { + title: 'Component Library / Form', + component: HelpTextComponent, + argTypes: { + severity: { + options: Object.values(HelpTextSeverity), + mapping: Object.values(HelpTextSeverity), + control: { + type: 'select', + labels: Object.keys(HelpTextSeverity), + }, + }, + }, }; +export default HelpTextMeta; -const HelpTextStory = () => ; - -storiesOf('Component Library / Form', module).add('HelpText', HelpTextStory); - -export default HelpTextStory; +export const HelpText = { + args: SAMPLE_HELPTEXT_PROPS, +}; diff --git a/app/component-library/components/Form/Label/Label.stories.tsx b/app/component-library/components/Form/Label/Label.stories.tsx index 7df9fed7359..beb422a1f49 100644 --- a/app/component-library/components/Form/Label/Label.stories.tsx +++ b/app/component-library/components/Form/Label/Label.stories.tsx @@ -1,27 +1,15 @@ -/* eslint-disable no-console */ - -// Third party dependencies. -import React from 'react'; -import { storiesOf } from '@storybook/react-native'; -import { text } from '@storybook/addon-knobs'; - -// External dependencies. -import { storybookPropsGroupID } from '../../../constants/storybook.constants'; - // Internal dependencies. -import Label from './Label'; -import { LabelProps } from './Label.types'; +import { default as LabelComponent } from './Label'; import { SAMPLE_LABEL_TEXT } from './Label.constants'; -export const getLabelStoryProps = (): LabelProps => { - const labelText = text('label', SAMPLE_LABEL_TEXT, storybookPropsGroupID); - return { - children: labelText, - }; +const LabelMeta = { + title: 'Component Library / Form', + component: LabelComponent, }; +export default LabelMeta; -const LabelStory = () =>