From 7d23e21d1abb087d2e2956e987ac08c9095d6142 Mon Sep 17 00:00:00 2001 From: Pavel Klibani Date: Sun, 17 Sep 2023 02:00:06 +0200 Subject: [PATCH] Docs(web-react): Add Radio demo #DS-905 - Radio demo in web-react is now same as demo in web and web-twig --- .../src/components/Radio/demo/Radio.tsx | 8 ----- .../components/Radio/demo/RadioDefault.tsx | 12 +++++++ .../components/Radio/demo/RadioDisabled.tsx | 22 ++++++++----- .../components/Radio/demo/RadioHelperText.tsx | 17 +++------- .../Radio/demo/RadioHiddenLabel.tsx | 8 +++++ .../src/components/Radio/demo/RadioItem.tsx | 29 +++++++++++----- .../src/components/Radio/demo/RadioList.tsx | 33 ------------------- .../components/Radio/demo/RadioValidation.tsx | 23 +++++++++++++ .../Radio/demo/RadioValidationState.tsx | 12 ------- .../src/components/Radio/demo/index.tsx | 22 ++++++------- 10 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 packages/web-react/src/components/Radio/demo/Radio.tsx create mode 100644 packages/web-react/src/components/Radio/demo/RadioDefault.tsx create mode 100644 packages/web-react/src/components/Radio/demo/RadioHiddenLabel.tsx delete mode 100644 packages/web-react/src/components/Radio/demo/RadioList.tsx create mode 100644 packages/web-react/src/components/Radio/demo/RadioValidation.tsx delete mode 100644 packages/web-react/src/components/Radio/demo/RadioValidationState.tsx diff --git a/packages/web-react/src/components/Radio/demo/Radio.tsx b/packages/web-react/src/components/Radio/demo/Radio.tsx deleted file mode 100644 index 2144e09d33..0000000000 --- a/packages/web-react/src/components/Radio/demo/Radio.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -import { ComponentStory } from '@storybook/react'; -import Radio from '../Radio'; -import { SpiritRadioProps } from '../../../types'; - -const Story: ComponentStory = (args: SpiritRadioProps) => ; - -export default Story; diff --git a/packages/web-react/src/components/Radio/demo/RadioDefault.tsx b/packages/web-react/src/components/Radio/demo/RadioDefault.tsx new file mode 100644 index 0000000000..5ab94f5741 --- /dev/null +++ b/packages/web-react/src/components/Radio/demo/RadioDefault.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import Radio from '../Radio'; + +const RadioDefault = () => ( + <> + + + + +); + +export default RadioDefault; diff --git a/packages/web-react/src/components/Radio/demo/RadioDisabled.tsx b/packages/web-react/src/components/Radio/demo/RadioDisabled.tsx index bb88da2ece..4ff65c3186 100644 --- a/packages/web-react/src/components/Radio/demo/RadioDisabled.tsx +++ b/packages/web-react/src/components/Radio/demo/RadioDisabled.tsx @@ -1,13 +1,19 @@ import React from 'react'; import Radio from '../Radio'; -// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const Story = (props: unknown) => ( -
- - -
+const RadioDisabled = () => ( + <> + + + + ); -export default Story; +export default RadioDisabled; diff --git a/packages/web-react/src/components/Radio/demo/RadioHelperText.tsx b/packages/web-react/src/components/Radio/demo/RadioHelperText.tsx index 7b01b54edf..59105461da 100644 --- a/packages/web-react/src/components/Radio/demo/RadioHelperText.tsx +++ b/packages/web-react/src/components/Radio/demo/RadioHelperText.tsx @@ -1,17 +1,8 @@ import React from 'react'; import Radio from '../Radio'; -import { SpiritRadioProps } from '../../../types'; -const Story = (args: SpiritRadioProps) => ; +const RadioHelperText = () => ( + +); -Story.args = { - id: 'example', - isChecked: true, - isDisabled: false, - isLabelHidden: false, - label: 'Label', - name: 'example', - helperText: 'Helper text', -}; - -export default Story; +export default RadioHelperText; diff --git a/packages/web-react/src/components/Radio/demo/RadioHiddenLabel.tsx b/packages/web-react/src/components/Radio/demo/RadioHiddenLabel.tsx new file mode 100644 index 0000000000..c7b7deec92 --- /dev/null +++ b/packages/web-react/src/components/Radio/demo/RadioHiddenLabel.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import Radio from '../Radio'; + +const RadioHiddenLabel = () => ( + +); + +export default RadioHiddenLabel; diff --git a/packages/web-react/src/components/Radio/demo/RadioItem.tsx b/packages/web-react/src/components/Radio/demo/RadioItem.tsx index 0ef4813c05..9a2ae1d8ec 100644 --- a/packages/web-react/src/components/Radio/demo/RadioItem.tsx +++ b/packages/web-react/src/components/Radio/demo/RadioItem.tsx @@ -1,13 +1,26 @@ import React from 'react'; import Radio from '../Radio'; -// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const Story = (props: unknown) => ( -
- - -
+const RadioItem = () => ( + <> + + + + + + + + + + ); -export default Story; +export default RadioItem; diff --git a/packages/web-react/src/components/Radio/demo/RadioList.tsx b/packages/web-react/src/components/Radio/demo/RadioList.tsx deleted file mode 100644 index 74010e4e7c..0000000000 --- a/packages/web-react/src/components/Radio/demo/RadioList.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, { ChangeEventHandler, useState } from 'react'; -import Radio from '../Radio'; -import { Stack } from '../../Stack'; - -// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const Story = (props: unknown) => { - const [checkedOption, setCheckedOption] = useState('value1'); - - const onValueChange: ChangeEventHandler = (event) => { - setCheckedOption(event.target.value); - }; - - const radioList = ['value1', 'value2', 'value3']; - - return ( - - {radioList.map((value) => ( - - ))} - - ); -}; - -export default Story; diff --git a/packages/web-react/src/components/Radio/demo/RadioValidation.tsx b/packages/web-react/src/components/Radio/demo/RadioValidation.tsx new file mode 100644 index 0000000000..732e351df1 --- /dev/null +++ b/packages/web-react/src/components/Radio/demo/RadioValidation.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import Radio from '../Radio'; + +const RadioValidation = () => ( + <> + + + + + + + + +); + +export default RadioValidation; diff --git a/packages/web-react/src/components/Radio/demo/RadioValidationState.tsx b/packages/web-react/src/components/Radio/demo/RadioValidationState.tsx deleted file mode 100644 index 70344de139..0000000000 --- a/packages/web-react/src/components/Radio/demo/RadioValidationState.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import Radio from '../Radio'; - -const Story = () => ( -
- - - -
-); - -export default Story; diff --git a/packages/web-react/src/components/Radio/demo/index.tsx b/packages/web-react/src/components/Radio/demo/index.tsx index a0fcb5f1ab..c2cc9028ad 100644 --- a/packages/web-react/src/components/Radio/demo/index.tsx +++ b/packages/web-react/src/components/Radio/demo/index.tsx @@ -5,36 +5,36 @@ import ReactDOM from 'react-dom/client'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment, import/extensions, import/no-unresolved // @ts-ignore: No declaration file import icons from '@lmc-eu/spirit-icons/dist/icons'; -import { IconsProvider } from '../../../context'; import DocsSection from '../../../../docs/DocsSections'; -import Radio from './Radio'; -import RadioValidationState from './RadioValidationState'; +import { IconsProvider } from '../../../context'; +import RadioDefault from './RadioDefault'; +import RadioHiddenLabel from './RadioHiddenLabel'; import RadioHelperText from './RadioHelperText'; import RadioDisabled from './RadioDisabled'; +import RadioValidation from './RadioValidation'; import RadioItem from './RadioItem'; -import RadioList from './RadioList'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - + - - + + - + + + + - - - , );