File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -66,14 +66,7 @@ export function classify(
6666 } ;
6767 }
6868
69- // hyphen variant e.g., #dark-05 → treat as base color
70- const hyphenMatch = token . match ( / ^ # ( [ a - z 0 - 9 - ] + ?) - [ 0 - 9 ] + $ / i) ;
71- if ( hyphenMatch ) {
72- return {
73- bucket : Bucket . Color ,
74- processed : `var(--${ hyphenMatch [ 1 ] } -color)` ,
75- } ;
76- }
69+ // hyphenated names like #dark-05 should keep full name
7770
7871 const name = token . slice ( 1 ) ;
7972 // valid hex → treat as hex literal with fallback
Original file line number Diff line number Diff line change @@ -86,9 +86,9 @@ describe('StyleProcessor', () => {
8686 expect ( result . groups [ 0 ] . values ) . toEqual ( [ 'calc(1 * var(--border-width))' ] ) ;
8787 expect ( result . groups [ 0 ] . colors ) . toEqual ( [ 'var(--purple-color)' ] ) ;
8888 expect ( result . groups [ 1 ] . values ) . toEqual ( [ 'calc(1 * var(--outline-width))' ] ) ;
89- expect ( result . groups [ 1 ] . colors ) . toEqual ( [ 'var(--dark-color)' ] ) ;
89+ expect ( result . groups [ 1 ] . colors ) . toEqual ( [ 'var(--dark-05- color)' ] ) ;
9090 expect ( result . output ) . toEqual (
91- 'calc(1 * var(--border-width)) top var(--purple-color), calc(1 * var(--outline-width)) right var(--dark-color)' ,
91+ 'calc(1 * var(--border-width)) top var(--purple-color), calc(1 * var(--outline-width)) right var(--dark-05- color)' ,
9292 ) ;
9393 expect ( result . groups [ 0 ] . mods ) . toEqual ( [ 'top' ] ) ;
9494 expect ( result . groups [ 1 ] . mods ) . toEqual ( [ 'right' ] ) ;
@@ -167,4 +167,9 @@ describe('StyleProcessor', () => {
167167 expect ( r . groups [ 0 ] . colors ) . toEqual ( [ 'transparent' ] ) ;
168168 expect ( r . groups [ 0 ] . values ) . toContain ( 'var(--gap)' ) ;
169169 } ) ;
170+
171+ test ( 'handles hyphenated #color names' , ( ) => {
172+ const r = parser . process ( '#dark-02' ) ;
173+ expect ( r . groups [ 0 ] . colors ) . toEqual ( [ 'var(--dark-02-color)' ] ) ;
174+ } ) ;
170175} ) ;
You can’t perform that action at this time.
0 commit comments