From 45b5d5aeaa1931f92e5695034328b88f2d248173 Mon Sep 17 00:00:00 2001 From: Peter Hellstrand Date: Wed, 18 Sep 2024 15:40:49 +0200 Subject: [PATCH] docs(ffe-form-react): storybook examples --- .../ffe-form-react/src/Checkbox.stories.tsx | 31 ++++++++++++++ packages/ffe-form-react/src/Checkbox.tsx | 1 + packages/ffe-form-react/src/Input.stories.tsx | 25 +++++++++++ .../ffe-form-react/src/InputGroup.stories.tsx | 24 +++++++++++ .../src/InputTextLike.stories.tsx | 25 +++++++++++ packages/ffe-form-react/src/Label.stories.tsx | 19 +++++++++ .../src/PhoneNumber.stories.tsx | 25 +++++++++++ .../ffe-form-react/src/RadioBlock.stories.tsx | 27 ++++++++++++ .../src/RadioButton.stories.tsx | 28 +++++++++++++ .../src/RadioButtonInputGroup.stories.tsx | 41 +++++++++++++++++++ .../src/RadioSwitch.stories.tsx | 25 +++++++++++ packages/ffe-form-react/src/RadioSwitch.tsx | 3 +- .../ffe-form-react/src/TextArea.stories.tsx | 24 +++++++++++ .../src/ToggleSwitch.stories.tsx | 21 ++++++++++ .../ffe-form-react/src/Tooltip.stories.tsx | 21 ++++++++++ .../src/message/ErrorFieldMessage.stories.tsx | 19 +++++++++ .../src/message/InfoFieldMessage.stories.tsx | 19 +++++++++ .../message/SuccessFieldMessage.stories.tsx | 19 +++++++++ packages/ffe-form-react/src/message/index.tsx | 12 +++--- 19 files changed, 402 insertions(+), 7 deletions(-) create mode 100644 packages/ffe-form-react/src/Checkbox.stories.tsx create mode 100644 packages/ffe-form-react/src/Input.stories.tsx create mode 100644 packages/ffe-form-react/src/InputGroup.stories.tsx create mode 100644 packages/ffe-form-react/src/InputTextLike.stories.tsx create mode 100644 packages/ffe-form-react/src/Label.stories.tsx create mode 100644 packages/ffe-form-react/src/PhoneNumber.stories.tsx create mode 100644 packages/ffe-form-react/src/RadioBlock.stories.tsx create mode 100644 packages/ffe-form-react/src/RadioButton.stories.tsx create mode 100644 packages/ffe-form-react/src/RadioButtonInputGroup.stories.tsx create mode 100644 packages/ffe-form-react/src/RadioSwitch.stories.tsx create mode 100644 packages/ffe-form-react/src/TextArea.stories.tsx create mode 100644 packages/ffe-form-react/src/ToggleSwitch.stories.tsx create mode 100644 packages/ffe-form-react/src/Tooltip.stories.tsx create mode 100644 packages/ffe-form-react/src/message/ErrorFieldMessage.stories.tsx create mode 100644 packages/ffe-form-react/src/message/InfoFieldMessage.stories.tsx create mode 100644 packages/ffe-form-react/src/message/SuccessFieldMessage.stories.tsx diff --git a/packages/ffe-form-react/src/Checkbox.stories.tsx b/packages/ffe-form-react/src/Checkbox.stories.tsx new file mode 100644 index 0000000000..50af0ebb1a --- /dev/null +++ b/packages/ffe-form-react/src/Checkbox.stories.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { Checkbox } from './Checkbox'; +import type { StoryObj, Meta } from '@storybook/react'; + +const meta: Meta = { + title: 'components/form/Checkbox', + component: Checkbox, + tags: ['autodocs'], +}; +export default meta; + +type Story = StoryObj; + +export const Standard: Story = { + args: { + noMargins: false, + hiddenLabel: false, + inline: false, + onColoredBg: false, + }, + render: args => ( +
+ + Hvilke aviser leser du? + + + VG + +
+ ), +}; diff --git a/packages/ffe-form-react/src/Checkbox.tsx b/packages/ffe-form-react/src/Checkbox.tsx index ea759af9b3..4897f5c7c9 100644 --- a/packages/ffe-form-react/src/Checkbox.tsx +++ b/packages/ffe-form-react/src/Checkbox.tsx @@ -7,6 +7,7 @@ export interface CheckboxProps noMargins?: boolean; /** If you plan to render the checkbox without a visible label */ hiddenLabel?: boolean; + /** Display inline */ inline?: boolean; children: | React.ReactNode diff --git a/packages/ffe-form-react/src/Input.stories.tsx b/packages/ffe-form-react/src/Input.stories.tsx new file mode 100644 index 0000000000..61df6b7bce --- /dev/null +++ b/packages/ffe-form-react/src/Input.stories.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Input } from './Input'; +import { InputGroup } from './InputGroup'; +import type { StoryObj, Meta } from '@storybook/react'; + +const meta: Meta = { + title: 'components/form/Input', + component: Input, + tags: ['autodocs'], +}; +export default meta; + +type Story = StoryObj; + +export const Standard: Story = { + args: { + inline: false, + textRightAlign: false, + }, + render: args => ( + + + + ), +}; diff --git a/packages/ffe-form-react/src/InputGroup.stories.tsx b/packages/ffe-form-react/src/InputGroup.stories.tsx new file mode 100644 index 0000000000..12669e2b21 --- /dev/null +++ b/packages/ffe-form-react/src/InputGroup.stories.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Input } from './Input'; +import { InputGroup } from './InputGroup'; +import type { StoryObj, Meta } from '@storybook/react'; + +const meta: Meta = { + title: 'components/form/InputGroup', + component: InputGroup, + tags: ['autodocs'], +}; +export default meta; + +type Story = StoryObj; + +export const Standard: Story = { + args: { + label: 'Navn', + }, + render: args => ( + + + + ), +}; diff --git a/packages/ffe-form-react/src/InputTextLike.stories.tsx b/packages/ffe-form-react/src/InputTextLike.stories.tsx new file mode 100644 index 0000000000..7d55f6f5a8 --- /dev/null +++ b/packages/ffe-form-react/src/InputTextLike.stories.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import type { StoryObj, Meta } from '@storybook/react'; +import { Paragraph } from '@sb1/ffe-core-react'; +import { InputTextLike } from './InputTextLike'; + +const meta: Meta = { + title: 'components/form/InputTextLike', + component: InputTextLike, + tags: ['autodocs'], +}; +export default meta; + +type Story = StoryObj; + +export const Standard: Story = { + args: { + ariaLabel: 'Skriv inn alder', + style: { width: 47 }, + }, + render: args => ( + + Jeg er år gammel + + ), +}; diff --git a/packages/ffe-form-react/src/Label.stories.tsx b/packages/ffe-form-react/src/Label.stories.tsx new file mode 100644 index 0000000000..30bed893eb --- /dev/null +++ b/packages/ffe-form-react/src/Label.stories.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import type { StoryObj, Meta } from '@storybook/react'; +import { Label } from './Label'; + +const meta: Meta = { + title: 'components/form/Label', + component: Label, + tags: ['autodocs'], +}; +export default meta; + +type Story = StoryObj; + +export const Standard: Story = { + args: { + children: 'Skriv inn alder', + }, + render: args =>