@@ -39,13 +39,12 @@ export type KeywordColor = 'transparent' | 'currentColor'
3939
4040function getKeywordColor ( value : unknown ) : KeywordColor | null {
4141 if ( typeof value !== 'string' ) return null
42- let lowercased = value . toLowerCase ( )
43- if ( lowercased === 'transparent' ) {
44- return 'transparent'
45- }
46- if ( lowercased === 'currentcolor' ) {
47- return 'currentColor'
48- }
42+
43+ value = value . toLowerCase ( )
44+
45+ if ( value === 'transparent' ) return 'transparent'
46+ if ( value === 'currentcolor' ) return 'currentColor'
47+
4948 return null
5049}
5150
@@ -122,11 +121,6 @@ function getColorFromDecls(
122121 ensureArray ( decls [ prop ] ) . flatMap ( ( str ) => getColorsInString ( state , str ) ) ,
123122 )
124123
125- // check that all of the values are valid colors
126- // if (colors.some((color) => color instanceof TinyColor && !color.isValid)) {
127- // return null
128- // }
129-
130124 // check that all of the values are the same color, ignoring alpha
131125 const colorStrings = dedupe (
132126 colors . map ( ( color ) =>
@@ -138,9 +132,7 @@ function getColorFromDecls(
138132 }
139133
140134 let keyword = getKeywordColor ( colorStrings [ 0 ] )
141- if ( keyword ) {
142- return keyword
143- }
135+ if ( keyword ) return keyword
144136
145137 const nonKeywordColors = colors . filter (
146138 ( color ) : color is culori . Color => typeof color !== 'string' ,
@@ -216,7 +208,6 @@ export function getColor(state: State, className: string): culori.Color | Keywor
216208 if ( isLikelyColorless ( className ) ) return null
217209
218210 let css = state . designSystem . compile ( [ className ] ) [ 0 ]
219-
220211 let color = getColorFromRoot ( state , css )
221212
222213 let prefix = state . designSystem . theme . prefix ?? ''
@@ -279,13 +270,11 @@ export function getColor(state: State, className: string): culori.Color | Keywor
279270
280271export function getColorFromValue ( value : unknown ) : culori . Color | KeywordColor | null {
281272 if ( typeof value !== 'string' ) return null
282- const trimmedValue = value . trim ( )
283- if ( trimmedValue . toLowerCase ( ) === 'transparent' ) {
284- return 'transparent'
285- }
286- if ( trimmedValue . toLowerCase ( ) === 'currentcolor' ) {
287- return 'currentColor'
288- }
273+
274+ let trimmedValue = value . trim ( )
275+ let keyword = getKeywordColor ( trimmedValue )
276+ if ( keyword ) return keyword
277+
289278 if (
290279 ! / ^ \s * (?: r g b a ? | h s l a ? | (?: o k ) ? (?: l a b | l c h ) ) \s * \( [ ^ ) ] + \) \s * $ / . test ( trimmedValue ) &&
291280 ! / ^ \s * # [ 0 - 9 a - f ] + \s * $ / i. test ( trimmedValue ) &&
0 commit comments