@@ -43,7 +43,33 @@ import {
4343import { mergeProps , useCombinedRefs } from '../../../utils/react/index' ;
4444import { useFocus } from '../../../utils/react/interactions' ;
4545import { getOverlayTransitionCSS } from '../../../utils/transitions' ;
46- import { DEFAULT_BUTTON_STYLES } from '../../actions/index' ;
46+ import {
47+ DANGER_CLEAR_STYLES ,
48+ DANGER_LINK_STYLES ,
49+ DANGER_NEUTRAL_STYLES ,
50+ DANGER_OUTLINE_STYLES ,
51+ DANGER_PRIMARY_STYLES ,
52+ DANGER_SECONDARY_STYLES ,
53+ DEFAULT_BUTTON_STYLES ,
54+ DEFAULT_CLEAR_STYLES ,
55+ DEFAULT_LINK_STYLES ,
56+ DEFAULT_NEUTRAL_STYLES ,
57+ DEFAULT_OUTLINE_STYLES ,
58+ DEFAULT_PRIMARY_STYLES ,
59+ DEFAULT_SECONDARY_STYLES ,
60+ SPECIAL_CLEAR_STYLES ,
61+ SPECIAL_LINK_STYLES ,
62+ SPECIAL_NEUTRAL_STYLES ,
63+ SPECIAL_OUTLINE_STYLES ,
64+ SPECIAL_PRIMARY_STYLES ,
65+ SPECIAL_SECONDARY_STYLES ,
66+ SUCCESS_CLEAR_STYLES ,
67+ SUCCESS_LINK_STYLES ,
68+ SUCCESS_NEUTRAL_STYLES ,
69+ SUCCESS_OUTLINE_STYLES ,
70+ SUCCESS_PRIMARY_STYLES ,
71+ SUCCESS_SECONDARY_STYLES ,
72+ } from '../../actions/index' ;
4773import { useFieldProps , useFormProps , wrapWithField } from '../../form' ;
4874import { OverlayWrapper } from '../../overlays/OverlayWrapper' ;
4975import { InvalidIcon } from '../../shared/InvalidIcon' ;
@@ -108,70 +134,45 @@ const SelectWrapperElement = tasty({
108134 } ,
109135} ) ;
110136
137+ type VariantType =
138+ | 'default.primary'
139+ | 'default.secondary'
140+ | 'default.outline'
141+ | 'default.neutral'
142+ | 'default.clear'
143+ | 'default.link'
144+ | 'special.primary'
145+ | 'special.secondary'
146+ | 'special.outline'
147+ | 'special.neutral'
148+ | 'special.clear'
149+ | 'special.link' ;
150+
111151const SelectElement = tasty ( {
112152 as : 'button' ,
113153 qa : 'Button' ,
114154 styles : {
115155 ...INPUT_WRAPPER_STYLES ,
116156 ...DEFAULT_BUTTON_STYLES ,
117- preset : 't3m' ,
118- cursor : 'pointer' ,
119- padding : '0' ,
120- gap : '0' ,
121- border : {
122- '' : true ,
123- valid : '#success-text.50' ,
124- invalid : '#danger-text.50' ,
125- '[data-type="primary"]' : '#clear' ,
126- '[data-type="clear"]' : '#clear' ,
127- '[data-theme="special"] & [data-type="secondary"] & pressed' : '#white.44' ,
128- disabled : true ,
129- } ,
130- fill : {
131- '' : '#clear' ,
132- '[data-type="primary"]' : '#purple' ,
133- '[data-type="primary"] & pressed' : '#purple' ,
134- '[data-type="primary"] & hovered' : '#purple-text' ,
135-
136- '[data-type="secondary"]' : '#dark.0' ,
137- '[data-type="secondary"] & hovered' : '#dark.04' ,
138- '[data-type="secondary"] & pressed' : '#dark.05' ,
139-
140- '[disabled]' : '#dark.04' ,
141-
142- '([data-type="clear"] | [data-type="outline"])' : '#purple.0' ,
143- '([data-type="clear"] | [data-type="outline"]) & hovered' : '#purple.16' ,
144- '([data-type="clear"] | [data-type="outline"]) & pressed' : '#purple.10' ,
145- '([data-type="clear"] | [data-type="outline"]) & [disabled]' : '#purple.0' ,
146-
147- // special
148- '[data-theme="special"] & [data-type="secondary"]' : '#white.12' ,
149-
150- '[data-theme="special"] & [data-type="clear"]' : '#white' ,
151- '[data-theme="special"] & [data-type="clear"] & hovered' : '#white.94' ,
152- '[data-theme="special"] & [data-type="clear"] & pressed' : '#white' ,
153-
154- '[data-theme="special"] & [disabled]' : '#white.12' ,
155-
156- '[data-theme="special"] & [data-type="clear"] & [disabled]' : '#white.0' ,
157- } ,
158- color : {
159- '' : '#white' ,
160-
161- '[data-type="secondary"]' : '#dark-02' ,
162- '[data-type="secondary"] & hovered' : '#dark-02' ,
163- '[data-type="clear"]' : '#purple-text' ,
164- '[data-type="secondary"] & pressed' : '#purple' ,
165-
166- '[disabled]' : '#dark.30' ,
167-
168- // special
169- '[data-theme="special"]' : '#white' ,
170- '[data-theme="special"] & [data-type="clear"]' : '#purple' ,
171-
172- // other
173- '[data-theme="special"] & [disabled]' : '#white.30' ,
174- } ,
157+ padding : 0 ,
158+ gap : 0 ,
159+ } ,
160+ variants : {
161+ // Default theme
162+ 'default.primary' : DEFAULT_PRIMARY_STYLES ,
163+ 'default.secondary' : DEFAULT_SECONDARY_STYLES ,
164+ 'default.outline' : DEFAULT_OUTLINE_STYLES ,
165+ 'default.neutral' : DEFAULT_NEUTRAL_STYLES ,
166+ 'default.clear' : DEFAULT_CLEAR_STYLES ,
167+ 'default.link' : DEFAULT_LINK_STYLES ,
168+
169+ // Special theme
170+ 'special.primary' : SPECIAL_PRIMARY_STYLES ,
171+ 'special.secondary' : SPECIAL_SECONDARY_STYLES ,
172+ 'special.outline' : SPECIAL_OUTLINE_STYLES ,
173+ 'special.neutral' : SPECIAL_NEUTRAL_STYLES ,
174+ 'special.clear' : SPECIAL_CLEAR_STYLES ,
175+ 'special.link' : SPECIAL_LINK_STYLES ,
175176 } ,
176177} ) ;
177178
@@ -255,8 +256,9 @@ export interface CubeSelectBaseProps<T>
255256 direction ?: 'top' | 'bottom' ;
256257 shouldFlip ?: boolean ;
257258 inputProps ?: Props ;
258- type ?: 'secondary ' | 'clear' | 'primary' | ( string & { } ) ;
259+ type ?: 'outline ' | 'clear' | 'primary' | ( string & { } ) ;
259260 suffixPosition ?: 'before' | 'after' ;
261+ theme ?: 'default' | 'special' ;
260262}
261263
262264export interface CubeSelectProps < T > extends CubeSelectBaseProps < T > {
@@ -317,7 +319,7 @@ function Select<T extends object>(
317319 tooltip,
318320 size,
319321 styles,
320- type = 'secondary ' ,
322+ type = 'outline ' ,
321323 theme = 'default' ,
322324 labelSuffix,
323325 ellipsis,
@@ -424,6 +426,7 @@ function Select<T extends object>(
424426 { ...mergeProps ( buttonProps , hoverProps , focusProps ) }
425427 ref = { triggerRef }
426428 styles = { inputStyles }
429+ variant = { `${ theme } .${ type } ` as VariantType }
427430 data-theme = { theme }
428431 data-size = { size }
429432 data-type = { type }
0 commit comments