-
Matiss Janis Aboltins authored
Moving some more components out of `common.tsx` into their own files. There are no functional changes. This is a direct copy&paste into new files.
Matiss Janis Aboltins authoredMoving some more components out of `common.tsx` into their own files. There are no functional changes. This is a direct copy&paste into new files.
CustomSelect.tsx 1.23 KiB
import {
ListboxInput,
ListboxButton,
ListboxPopover,
ListboxList,
ListboxOption,
} from '@reach/listbox';
import { type CSSProperties, css } from 'glamor';
import ExpandArrow from '../../icons/v0/ExpandArrow';
type CustomSelectProps = {
options: Array<[string, string]>;
value: string;
onChange?: (newValue: string) => void;
style?: CSSProperties;
disabledKeys?: string[];
};
export default function CustomSelect({
options,
value,
onChange,
style,
disabledKeys = [],
}: CustomSelectProps) {
return (
<ListboxInput
value={value}
onChange={onChange}
style={{ lineHeight: '1em' }}
>
<ListboxButton
{...css([{ borderWidth: 0, padding: 5, borderRadius: 4 }, style])}
arrow={<ExpandArrow style={{ width: 7, height: 7, paddingTop: 3 }} />}
/>
<ListboxPopover style={{ zIndex: 10000, outline: 0, borderRadius: 4 }}>
<ListboxList>
{options.map(([value, label]) => (
<ListboxOption
key={value}
value={value}
disabled={disabledKeys.includes(value)}
>
{label}
</ListboxOption>
))}
</ListboxList>
</ListboxPopover>
</ListboxInput>
);
}