Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: remove use of combobox #3238

Merged
merged 5 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading