Skip to content

Commit

Permalink
docs: remove use of combobox (#3238)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Marszalek <mimarz@gmail.com>
  • Loading branch information
Barsnes and mimarz authored Feb 27, 2025
1 parent 880ccbd commit 111f715
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 22 deletions.
46 changes: 29 additions & 17 deletions apps/_components/src/Showcase/Showcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import {
Button,
Card,
Checkbox,
Combobox,
Details,
Divider,
Field,
Fieldset,
Heading,
Label,
Link,
Pagination,
Paragraph,
Radio,
Search,
Select,
EXPERIMENTAL_Suggestion as Suggestion,
Switch,
Table,
Tabs,
Expand All @@ -28,6 +30,16 @@ import cl from 'clsx/lite';
import { type HTMLAttributes, useState } from 'react';
import classes from './Showcase.module.css';

const DATA_PLACES = [
'Sogndal',
'Oslo',
'Brønnøysund',
'Stavanger',
'Trondheim',
'Bergen',
'Lillestrøm',
];

type ShowcaseProps = HTMLAttributes<HTMLDivElement>;

export function Showcase({ className, ...props }: ShowcaseProps) {
Expand Down Expand Up @@ -240,22 +252,22 @@ export function Showcase({ className, ...props }: ShowcaseProps) {
<ToggleGroup.Item value='sweden'>Sverige</ToggleGroup.Item>
<ToggleGroup.Item value='utlandet'>Utlandet</ToggleGroup.Item>
</ToggleGroup>
<Combobox
description='Velg et sted'
label='Hvor går reisen?'
portal={false}
multiple
>
<Combobox.Empty>Fant ingen treff</Combobox.Empty>
<Combobox.Option value='leikanger'>Leikanger</Combobox.Option>
<Combobox.Option value='oslo'>Oslo</Combobox.Option>
<Combobox.Option value='bronnoysund'>Brønnøysund</Combobox.Option>
<Combobox.Option value='stavanger'>Stavanger</Combobox.Option>
<Combobox.Option value='trondheim'>Trondheim</Combobox.Option>
<Combobox.Option value='tromso'>Tromsø</Combobox.Option>
<Combobox.Option value='bergen'>Bergen</Combobox.Option>
<Combobox.Option value='moirana'>Mo i Rana</Combobox.Option>
</Combobox>
<Field>
<Label>Velg en destinasjon</Label>
<Suggestion>
<Suggestion.Input />
<Suggestion.Clear />
<Suggestion.List>
<Suggestion.Empty>Tomt</Suggestion.Empty>
{DATA_PLACES.map((place) => (
<Suggestion.Option key={place} value={place}>
{place}
<div>Kommune</div>
</Suggestion.Option>
))}
</Suggestion.List>
</Suggestion>
</Field>
</div>
</div>
<div className={cl(classes.card, classes.tabs)}>
Expand Down
17 changes: 17 additions & 0 deletions apps/storybook/stories/showcase.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ export default {
},
},
},
a11y: {
// TODO: these rules should be enabled after figuring out why they occur.
// for some reason it says `aria-expanded` is not allowed
config: {
rules: [
{
id: 'aria-allowed-attr',
enabled: false,
},
/* It does not like role="combobox" either */
{
id: 'aria-allowed-role',
enabled: false,
},
],
},
},
},
} as Meta;

Expand Down
29 changes: 24 additions & 5 deletions packages/react/stories/testing.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Card,
Checkbox,
Chip,
Combobox,
Details,
Dialog,
Dropdown,
Expand All @@ -27,6 +26,7 @@ import {
Radio,
Select,
Spinner,
EXPERIMENTAL_Suggestion as Suggestion,
Switch,
Table,
Tabs,
Expand Down Expand Up @@ -57,6 +57,16 @@ export default {
},
} as Meta;

const DATA_PLACES = [
'Sogndal',
'Oslo',
'Brønnøysund',
'Stavanger',
'Trondheim',
'Bergen',
'Lillestrøm',
];

export const MediumRow: StoryFn<{
size: 'sm' | 'md' | 'lg';
direction: 'column' | 'row';
Expand Down Expand Up @@ -85,10 +95,19 @@ export const MediumRow: StoryFn<{
<Select.Option>opt3</Select.Option>
</Select>
<Button data-size={size}>Knapp</Button>
<Combobox data-size={size}>
<Combobox.Option value='sogndal'>Sogndal</Combobox.Option>
<Combobox.Option value='stavanger'>Stavanger</Combobox.Option>
</Combobox>
<Suggestion>
<Suggestion.Input />
<Suggestion.Clear />
<Suggestion.List>
<Suggestion.Empty>Tomt</Suggestion.Empty>
{DATA_PLACES.map((place) => (
<Suggestion.Option key={place} value={place}>
{place}
<div>Kommune</div>
</Suggestion.Option>
))}
</Suggestion.List>
</Suggestion>
</div>
<br />
<div
Expand Down

0 comments on commit 111f715

Please sign in to comment.