Skip to content

Commit

Permalink
docs(Textfield): better prefix and suffix story (#2375)
Browse files Browse the repository at this point in the history
resolves #2299

Also removed full width story, as this was not adding anything useful to
the docs

---------

Co-authored-by: Michael Marszalek <[email protected]>
  • Loading branch information
Barsnes and mimarz authored Sep 6, 2024
1 parent 4abf5e6 commit 5efdf2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
8 changes: 4 additions & 4 deletions packages/react/src/components/form/Textfield/Textfield.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import * as TextfieldStories from './Textfield.stories';

## Prefix/Suffix

Prefixer og suffixer er nyttige for å vise enheter, valuta eller andre typer informasjon som er relevant for feltet.
Du skal **ikke** bruke disse alene, siden skjermlesere ikke leser dem opp.
Det er viktig at samme informasjon som vises i prefixet eller suffixet også er inkludert i ledeteksten.

<Canvas of={TextfieldStories.Adornments} />

## Antall tegn
Expand All @@ -23,10 +27,6 @@ import * as TextfieldStories from './Textfield.stories';

<Canvas of={TextfieldStories.Controlled} />

## Full bredde

<Canvas of={TextfieldStories.FullWidth} />

## Html Size

<Canvas of={TextfieldStories.HtmlSize} />
Expand Down
22 changes: 7 additions & 15 deletions packages/react/src/components/form/Textfield/Textfield.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,22 @@ export const WithCharacterCounter: Story = {
},
};

export const FullWidth: Story = {
export const HtmlSize: Story = {
args: {
label: 'Label',
},
parameters: {
layout: 'padded',
htmlSize: 10,
},
};

export const HtmlSize: Story = {
export const Adornments: Story = {
args: {
label: 'Label',
htmlSize: 10,
prefix: 'NOK',
suffix: 'pr. mnd',
size: 'md',
label: 'Hvor mange kroner koster det per måned?',
},
};

export const Adornments: StoryFn<typeof Textfield> = () => (
<div style={{ display: 'grid', gap: 'var(--ds-spacing-2)' }}>
<Textfield prefix='prefix' suffix='suffix' size='sm' />
<Textfield prefix='prefix' suffix='suffix' size='md' />
<Textfield prefix='prefix' suffix='suffix' size='lg' />
</div>
);

export const Controlled: StoryFn<typeof Textfield> = () => {
const [value, setValue] = useState<string>();
return (
Expand Down

0 comments on commit 5efdf2e

Please sign in to comment.