@@ -253,20 +253,24 @@ export function colorCSSGenerator(
253253 if ( color ) {
254254 const result : [ CSSObject , ...CSSValueInput [ ] ] = [ css ]
255255 const isCSSVar = color . includes ( 'var(' )
256- if ( Object . values ( SpecialColorKey ) . includes ( color ) ) {
256+ const isSpecial = Object . values ( SpecialColorKey ) . includes ( color )
257+
258+ if ( isSpecial && ! alpha ) {
257259 css [ property ] = color
260+ return result
261+ }
262+
263+ const alphaKey = `--un-${ varName } -opacity`
264+ const value = ( keys && ! isCSSVar && ! isSpecial ) ? generateThemeVariable ( 'colors' , keys ) : color
265+ let method = modifier ?? ( keys ? 'in srgb' : 'in oklab' )
266+ if ( ! method . startsWith ( 'in ' ) && ! method . startsWith ( 'var(' ) ) {
267+ method = `in ${ method } `
258268 }
259- else {
260- const alphaKey = `--un-${ varName } -opacity`
261- const value = ( keys && ! isCSSVar ) ? generateThemeVariable ( 'colors' , keys ) : color
262- let method = modifier ?? ( keys ? 'in srgb' : 'in oklab' )
263- if ( ! method . startsWith ( 'in ' ) && ! method . startsWith ( 'var(' ) ) {
264- method = `in ${ method } `
265- }
266269
267- css [ property ] = `color-mix(${ method } , ${ value } ${ alpha ?? `var(${ alphaKey } )` } , transparent)${ rawColorComment } `
268- result . push ( defineProperty ( alphaKey , { syntax : '<percentage>' , initialValue : '100%' } ) )
270+ css [ property ] = `color-mix(${ method } , ${ value } ${ alpha ?? `var(${ alphaKey } )` } , transparent)${ rawColorComment } `
271+ result . push ( defineProperty ( alphaKey , { syntax : '<percentage>' , initialValue : '100%' } ) )
269272
273+ if ( ! isSpecial ) {
270274 if ( keys && ! isCSSVar ) {
271275 themeTracking ( `colors` , keys )
272276 if ( ! modifier ) {
0 commit comments