import { Listbox, ListboxOption } from '@reach/listbox'; import VisuallyHidden from '@reach/visually-hidden'; import { FunctionComponent } from 'preact'; import { IconType } from './Icon'; import '@reach/listbox/styles.css'; import { useState } from 'preact/hooks'; export type DropdownItem = { icon?: IconType; label: string; value: string; }; type Props = { id: string; srLabel: string; items: DropdownItem[]; defaultValue: string; }; export const Dropdown: FunctionComponent = ({ id, srLabel, items, defaultValue, }) => { const [value, setValue] = useState(defaultValue); const labelId = `${id}-label`; return ( <> {srLabel} setValue(value)} aria-labelledby={labelId} > {items.map((item) => ( {item.label} ))} ); };