File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/tailwindcss-language-service/src/util Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -188,8 +188,21 @@ function getColorFromRoot(state: State, css: postcss.Root): culori.Color | Keywo
188
188
return getColorFromDecls ( state , decls )
189
189
}
190
190
191
+ let isNegative = / ^ - /
192
+ let isNumericUtility =
193
+ / ^ - ? ( ( m i n - | m a x - ) ? [ w h ] | z | s t a r t | o r d e r | o p a c i t y | r o u n d e d | r o w | c o l | s i z e | b a s i s | e n d | d u r a t i o n | e a s e | f o n t | t o p | l e f t | b o t t o m | r i g h t | i n s e t | l e a d i n g | c u r s o r | ( s p a c e | s c a l e | s k e w | r o t a t e ) - [ x y z ] | g a p ( - [ x y ] ) ? | ( s c r o l l - ) ? [ p m ] [ t r b l x y s e ] ? ) - /
194
+
195
+ function isLikelyColorless ( className : string ) {
196
+ if ( isNegative . test ( className ) ) return true
197
+ if ( isNumericUtility . test ( className ) ) return true
198
+ return false
199
+ }
200
+
191
201
export function getColor ( state : State , className : string ) : culori . Color | KeywordColor | null {
192
202
if ( state . v4 ) {
203
+ // FIXME: This is a performance optimization and not strictly correct
204
+ if ( isLikelyColorless ( className ) ) return null
205
+
193
206
let css = state . designSystem . compile ( [ className ] ) [ 0 ]
194
207
195
208
let color = getColorFromRoot ( state , css )
You can’t perform that action at this time.
0 commit comments