From ddd20fe027bae1776a46faa320c2f0d5ab30da53 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sun, 23 Jun 2024 17:25:22 -0400 Subject: [PATCH] feat: create select component --- app/components/Select.tsx | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 app/components/Select.tsx diff --git a/app/components/Select.tsx b/app/components/Select.tsx new file mode 100644 index 0000000..1211ea0 --- /dev/null +++ b/app/components/Select.tsx @@ -0,0 +1,82 @@ +import { ChevronDownIcon } from '@primer/octicons-react' +import { Dispatch, ReactNode, SetStateAction } from 'react' +import { + Button, + ListBox, + ListBoxItem, + Popover, + Select as AriaSelect, + SelectValue, +} from 'react-aria-components' + +import { cn } from '~/utils/cn' + +type SelectProps = Parameters[0] & { + readonly label: string + readonly state?: [string, Dispatch>] + readonly children: ReactNode +} + +function Select(props: SelectProps) { + return ( + { + props.state?.[1](key.toString()) + }} + className={cn( + 'block w-full rounded-lg my-1', + 'border border-ui-200 dark:border-ui-600', + 'bg-white dark:bg-ui-800 dark:text-ui-300', + 'focus-within:outline-6', + props.className, + )} + > + + + + {props.children} + + + + ) +} + +type ItemProps = Parameters[0] + +function Item(props: ItemProps) { + return ( + + {props.children} + + ) +} + +export default Object.assign(Select, { Item })