@@ -138,6 +138,7 @@ const getForegroundColor = (
138
138
const paletteColorRegex =
139
139
/ ^ ( n e u t r a l | p r i m a r y | i n f o | s u c c e s s | w a r n i n g | d a n g e r ) - ( \d + ) ( - ( \d + ) ) ? $ / ;
140
140
141
+ const cssSupportsVariable = cssSupports ( '(--foo: bar)' ) ;
141
142
export const color = memoize ( ( value ) => {
142
143
if ( typeof value !== 'string' ) {
143
144
return ;
@@ -159,25 +160,40 @@ export const color = memoize((value) => {
159
160
160
161
const [ customProperty , color ] = getPaletteColor ( type , grade , alpha ) ;
161
162
162
- if ( customProperty && cssSupports ( '(--foo: bar)' ) ) {
163
+ if ( customProperty && cssSupportsVariable ) {
163
164
return `var(${ customProperty } , ${ color } )` ;
164
165
}
165
166
166
167
return color ;
167
168
}
168
169
169
- if ( value === 'surface' ) {
170
- if ( cssSupports ( '(--foo: bar)' ) ) {
171
- return ' var(--rcx-color-surface, white)' ;
170
+ if ( value === 'surface' || value === 'surface-light' ) {
171
+ if ( cssSupportsVariable ) {
172
+ return ` var(--rcx-color-surface-light, ${ tokenColors . white } )` ;
172
173
}
173
174
174
- return 'white' ;
175
+ return tokenColors . white ;
176
+ }
177
+
178
+ if ( value === 'surface-tint' ) {
179
+ if ( cssSupportsVariable ) {
180
+ return `var(--rcx-color-surface-tint, ${ tokenColors . n100 } )` ;
181
+ }
182
+
183
+ return tokenColors . n100 ;
184
+ }
185
+
186
+ if ( value === 'surface-neutral' ) {
187
+ if ( cssSupportsVariable ) {
188
+ return `var(--rcx-color-surface-neutral, ${ tokenColors . n400 } )` ;
189
+ }
190
+ return tokenColors . n400 ;
175
191
}
176
192
177
193
if ( isForegroundColorRef ( value ) ) {
178
194
const [ customProperty , color ] = getForegroundColor ( value ) ;
179
195
180
- if ( customProperty && cssSupports ( '(--foo: bar)' ) ) {
196
+ if ( customProperty && cssSupportsVariable ) {
181
197
return `var(${ customProperty } , ${ color } )` ;
182
198
}
183
199
@@ -237,7 +253,7 @@ export const fontFamily = memoize((value: unknown): string | undefined => {
237
253
. map ( ( fontFace ) => ( fontFace . includes ( ' ' ) ? `'${ fontFace } '` : fontFace ) )
238
254
. join ( ', ' ) ;
239
255
240
- if ( cssSupports ( '(--foo: bar)' ) ) {
256
+ if ( cssSupportsVariable ) {
241
257
return `var(--rcx-font-family-${ value } , ${ fontFamily } )` ;
242
258
}
243
259
0 commit comments