@@ -99,6 +99,28 @@ const internal: Record<string, string> = {
9999 '--tw-scale-x' : 'scale' ,
100100 '--tw-scale-y' : 'scale' ,
101101}
102+ /** Split authored border geometry and style from its colour input. */
103+ export function borderDeclarations ( property : string , value : string ) : Declaration [ ] | null {
104+ if ( ! / ^ (?: b o r d e r (?: - (?: t o p | b o t t o m | l e f t | r i g h t ) ) ? | o u t l i n e ) $ / . test ( property ) ) return null
105+ const prefix = property . startsWith ( 'outline' ) ? 'outline' : 'border'
106+ return valueParser ( value )
107+ . nodes . filter ( ( node ) => node . type !== 'space' && node . type !== 'comment' )
108+ . map ( ( node ) => {
109+ const part = valueParser . stringify ( node )
110+ const suffix = / ^ (?: n o n e | h i d d e n | s o l i d | d a s h e d | d o t t e d | d o u b l e | g r o o v e | r i d g e | i n s e t | o u t s e t ) $ / . test (
111+ part
112+ )
113+ ? 'style'
114+ : / ^ (?: [ \d . ] + (?: p x | e m ) | 0 | t h i n | m e d i u m | t h i c k ) $ / . test ( part ) || part . includes ( '--border-width' )
115+ ? 'width'
116+ : 'color'
117+ return {
118+ property : `${ prefix } -${ suffix } ` ,
119+ value : part ,
120+ category : suffix === 'color' ? 'colours' : 'borders' ,
121+ }
122+ } )
123+ }
102124export function declarations (
103125 atom : Atom ,
104126 system : Compiler ,
@@ -163,23 +185,11 @@ export function declarations(
163185 if ( / ^ (?: p a d d i n g | m a r g i n | g a p | b o r d e r - r a d i u s ) $ / . test ( family ( prop ) ) ) {
164186 for ( const part of parts . filter ( ( x ) => x !== '/' ) )
165187 found . push ( { property : family ( prop ) , value : part , category : cat } )
166- } else if ( / ^ (?: b o r d e r (?: - (?: t o p | b o t t o m | l e f t | r i g h t ) ) ? | o u t l i n e ) $ / . test ( prop ) ) {
167- const prefix = prop . startsWith ( 'outline' ) ? 'outline' : 'border'
168- for ( const part of parts ) {
169- const suffix =
170- / ^ (?: n o n e | h i d d e n | s o l i d | d a s h e d | d o t t e d | d o u b l e | g r o o v e | r i d g e | i n s e t | o u t s e t ) $ / . test ( part )
171- ? 'style'
172- : / ^ (?: [ \d . ] + (?: p x | e m ) | 0 | t h i n | m e d i u m | t h i c k ) $ / . test ( part ) ||
173- part . includes ( '--border-width' )
174- ? 'width'
175- : 'color'
176- found . push ( {
177- property : `${ prefix } -${ suffix } ` ,
178- value : part ,
179- category : suffix === 'color' ? 'colours' : 'borders' ,
180- } )
181- }
182- } else found . push ( { property : family ( prop ) , value, category : cat } )
188+ } else {
189+ const border = borderDeclarations ( prop , value )
190+ if ( border ) found . push ( ...border )
191+ else found . push ( { property : family ( prop ) , value, category : cat } )
192+ }
183193 } )
184194 return [ ...new Map ( found . map ( ( x ) => [ JSON . stringify ( x ) , x ] ) ) . values ( ) ]
185195}
0 commit comments