💄(frontend) add dark variant prop to Select primitive

Add dark variant to Select component following same approach as Popover
primitive. Same design inconsistency as other variant patterns.

Quick implementation pending UI v2 refactoring for unified variant
system across all components.
This commit is contained in:
lebaudantoine
2025-08-21 16:51:17 +02:00
committed by aleb_the_flash
parent 7b89395f42
commit 59e0643dde

View File

@@ -42,6 +42,31 @@ const StyledButton = styled(Button, {
boxShadow: '0 1px 2px rgba(0 0 0 / 0.02)', boxShadow: '0 1px 2px rgba(0 0 0 / 0.02)',
}, },
}, },
variants: {
variant: {
light: {},
dark: {
backgroundColor: 'primaryDark.100',
fontWeight: 'medium !important',
color: 'white',
'&[data-pressed]': {
backgroundColor: 'primaryDark.900',
color: 'primaryDark.100',
},
'&[data-hovered]': {
backgroundColor: 'primaryDark.300',
color: 'white',
},
'&[data-selected]': {
backgroundColor: 'primaryDark.700 !important',
color: 'primaryDark.100 !important',
},
},
},
},
defaultVariants: {
variant: 'light',
},
}) })
const StyledSelectValue = styled(SelectValue, { const StyledSelectValue = styled(SelectValue, {
@@ -69,6 +94,7 @@ export const Select = <T extends string | number>({
items, items,
errors, errors,
placement, placement,
variant = 'light',
...props ...props
}: Omit<SelectProps<object>, 'items' | 'label' | 'errors'> & { }: Omit<SelectProps<object>, 'items' | 'label' | 'errors'> & {
iconComponent?: RemixiconComponentType iconComponent?: RemixiconComponentType
@@ -76,12 +102,13 @@ export const Select = <T extends string | number>({
items: Array<{ value: T; label: ReactNode }> items: Array<{ value: T; label: ReactNode }>
errors?: ReactNode errors?: ReactNode
placement?: Placement placement?: Placement
variant?: 'light' | 'dark'
}) => { }) => {
const IconComponent = iconComponent const IconComponent = iconComponent
return ( return (
<RACSelect {...props}> <RACSelect {...props}>
{label} {label}
<StyledButton> <StyledButton variant={variant}>
{!!IconComponent && ( {!!IconComponent && (
<StyledIcon> <StyledIcon>
<IconComponent size={18} /> <IconComponent size={18} />
@@ -94,12 +121,15 @@ export const Select = <T extends string | number>({
/> />
</StyledButton> </StyledButton>
<StyledPopover placement={placement}> <StyledPopover placement={placement}>
<Box size="sm" type="popover" variant="control"> <Box size="sm" type="popover" variant={variant}>
<ListBox> <ListBox>
{items.map((item) => ( {items.map((item) => (
<ListBoxItem <ListBoxItem
className={ className={
menuRecipe({ extraPadding: true, variant: 'light' }).item menuRecipe({
extraPadding: true,
variant: variant,
}).item
} }
id={item.value} id={item.value}
key={item.value} key={item.value}