@@ -21,17 +21,6 @@ import { IconCheck } from './IconCheck'
2121type SelectType = 'default' | 'radio' | 'checkbox'
2222type SelectValue < T extends SelectType > = T extends 'radio' ? string : string [ ]
2323
24- interface SelectProps extends ComponentProps < 'div' > {
25- defaultValue ?: SelectValue < SelectType >
26- value ?: SelectValue < SelectType >
27- onValueChange ?: ( value : string ) => void
28- defaultOpen ?: boolean
29- open ?: boolean
30- onOpenChange ?: ( open : boolean ) => void
31- children : React . ReactNode
32- type ?: SelectType
33- }
34-
3524const SelectContext = createContext < {
3625 open : boolean
3726 setOpen : ( open : boolean ) => void
@@ -48,6 +37,26 @@ export const useSelect = () => {
4837 return context
4938}
5039
40+ interface SelectProps extends ComponentProps < 'div' > {
41+ defaultValue ?: SelectValue < SelectType >
42+ value ?: SelectValue < SelectType >
43+ onValueChange ?: ( value : string ) => void
44+ defaultOpen ?: boolean
45+ open ?: boolean
46+ onOpenChange ?: ( open : boolean ) => void
47+ children : React . ReactNode
48+ type ?: SelectType
49+ colors ?: {
50+ primary ?: string
51+ border ?: string
52+ inputBg ?: string
53+ base10 ?: string
54+ title ?: string
55+ selectDisabled ?: string
56+ primaryBg ?: string
57+ }
58+ }
59+
5160export function Select ( {
5261 type = 'default' ,
5362 children,
@@ -57,6 +66,7 @@ export function Select({
5766 defaultOpen,
5867 open : openProp ,
5968 onOpenChange,
69+ colors,
6070 ...props
6171} : SelectProps ) {
6272 const ref = useRef < HTMLDivElement > ( null )
@@ -111,7 +121,22 @@ export function Select({
111121 type,
112122 } }
113123 >
114- < Box ref = { ref } display = "inline-block" pos = "relative" { ...props } >
124+ < Box
125+ ref = { ref }
126+ display = "inline-block"
127+ pos = "relative"
128+ styleOrder = { 1 }
129+ styleVars = { {
130+ primary : colors ?. primary ,
131+ border : colors ?. border ,
132+ inputBg : colors ?. inputBg ,
133+ base10 : colors ?. base10 ,
134+ title : colors ?. title ,
135+ selectDisabled : colors ?. selectDisabled ,
136+ primaryBg : colors ?. primaryBg ,
137+ } }
138+ { ...props }
139+ >
115140 { children }
116141 </ Box >
117142 </ SelectContext . Provider >
@@ -172,11 +197,11 @@ export function SelectContainer({ children, ...props }: ComponentProps<'div'>) {
172197 return (
173198 < VStack
174199 aria-label = "Select container"
175- bg = "$ inputBg"
176- border = "1px solid $ border"
200+ bg = "var(-- inputBg, light-dark(#FFF,#2E2E2E)) "
201+ border = "1px solid var(-- border, light-dark(#E4E4E4,#434343)) "
177202 borderRadius = "8px"
178203 bottom = "-4px"
179- boxShadow = "0 2px 2px 0 $ base10"
204+ boxShadow = "0 2px 2px 0 var(-- base10, light-dark(#0000001A,#FFFFFF1A)) "
180205 gap = "6px"
181206 h = "fit-content"
182207 p = "10px"
@@ -242,12 +267,18 @@ export function SelectOption({
242267 < Flex
243268 _hover = {
244269 changesOnHover && {
245- bg : '$ primaryBg' ,
270+ bg : 'var(-- primaryBg, light-dark(#F4F3FA, #F4F3FA0D)) ' ,
246271 }
247272 }
248273 alignItems = "center"
249274 borderRadius = "8px"
250- color = { disabled ? '$selectDisabled' : isSelected ? '$primary' : '$title' }
275+ color = {
276+ disabled
277+ ? 'var(--selectDisabled, light-dark(#C4C5D1, #45464D))'
278+ : isSelected
279+ ? 'var(--primary, light-dark(#674DC7, #8163E1)'
280+ : 'var(--title, light-dark(#1A1A1A,#FAFAFA))'
281+ }
251282 cursor = { changesOnHover ? 'pointer' : 'default' }
252283 data-value = { value }
253284 gap = {
@@ -269,7 +300,11 @@ export function SelectOption({
269300 {
270301 checkbox : (
271302 < Box
272- bg = { isSelected ? '$primary' : '$border' }
303+ bg = {
304+ isSelected
305+ ? 'var(--primary, light-dark(#674DC7, #8163E1)'
306+ : 'var(--border, light-dark(#E4E4E4, #434343))'
307+ }
273308 borderRadius = "4px"
274309 boxSize = "18px"
275310 pos = "relative"
@@ -317,5 +352,13 @@ export function SelectOption({
317352}
318353
319354export function SelectDivider ( { ...props } : ComponentProps < 'div' > ) {
320- return < Box bg = "$border" h = "1px" styleOrder = { 1 } w = "100%" { ...props } />
355+ return (
356+ < Box
357+ bg = "var(--border, light-dark(#E4E4E4,#434343)"
358+ h = "1px"
359+ styleOrder = { 1 }
360+ w = "100%"
361+ { ...props }
362+ />
363+ )
321364}
0 commit comments