Files
web/packages/design-system/example/components/ThemeSwitcher.tsx
Michael Zetterberg 56973888c9 feat(SW-375): new tokens
new asset generation logic

BREAKING CHANGE: New tokens.
2025-03-07 07:24:37 +00:00

41 lines
969 B
TypeScript

import { ComponentPropsWithoutRef } from 'react'
import {
Button,
Label,
ListBox,
ListBoxItem,
Popover,
Select,
SelectValue,
} from 'react-aria-components'
import { themes } from '../../.storybook/preview'
type ThemeSwitcherProps = Pick<
ComponentPropsWithoutRef<typeof Select>,
'defaultSelectedKey' | 'onSelectionChange'
>
export function ThemeSwitcher(props: ThemeSwitcherProps) {
return (
<Select {...props}>
<Label>Theme: </Label>
<Button>
<SelectValue />
<span aria-hidden="true"></span>
</Button>
<Popover style={{ border: 'solid 1px #000', background: '#fff' }}>
<ListBox>
{Array.from(Object.entries(themes.themes)).map(([label, key]) => {
return (
<ListBoxItem key={key} id={key} style={{ padding: '0.5em' }}>
{label}
</ListBoxItem>
)
})}
</ListBox>
</Popover>
</Select>
)
}