Skip to content

Commit

Permalink
chore(storybook): 🪧 Add fieldset preview (#2047)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Marszalek <[email protected]>
  • Loading branch information
poi33 and mimarz authored May 23, 2024
1 parent 0a60499 commit 17f19f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/react/src/components/form/Fieldset/Fieldset.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { Meta, Controls, Primary } from '@storybook/blocks';

import * as FieldsetStories from './Fieldset.stories';

<Meta of={FieldsetStories} />

<Primary />
<Controls />

# Fieldset

`Fieldset` er et [fieldset](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset)-element med diverse hjelpfunksjoner for å hjelpe med bruk og gruppering av kontrollelementer i et skjema.

<ArgTypes />

## Referanser

[Providing a description for groups of form controls using fieldset and legend elements](https://www.w3.org/WAI/WCAG21/Techniques/html/H71)
22 changes: 21 additions & 1 deletion packages/react/src/components/form/Fieldset/Fieldset.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Meta, StoryFn } from '@storybook/react';

import { Textfield } from '../Textfield';
import { Textarea } from '../Textarea';

import { Fieldset } from '.';

type Story = StoryFn<typeof Fieldset>;
Expand All @@ -9,4 +12,21 @@ export default {
component: Fieldset,
} as Meta;

export const Preview: Story = (args) => <Fieldset {...args}></Fieldset>;
export const Preview: Story = (args) => (
<form>
<Fieldset {...args}>
<Textfield label='Kort beskrivelse'></Textfield>
<Textarea label='Lang beskrivelse'></Textarea>
</Fieldset>
</form>
);

Preview.args = {
description:
'Gi en kort beskrivelse i begge feltene',
disabled: false,
error: '',
legend: 'Skriv inn dine svar',
readOnly: false,
hideLegend: false,
};

0 comments on commit 17f19f2

Please sign in to comment.