File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ export function buildPluginApi({
154154
155155 // CSS-in-JS object
156156 else if ( typeof variant === 'object' ) {
157- designSystem . variants . fromAst ( name , objectToAst ( variant ) )
157+ designSystem . variants . fromAst ( name , objectToAst ( variant ) , designSystem )
158158 }
159159 } ,
160160 matchVariant ( name , fn , options ) {
Original file line number Diff line number Diff line change @@ -83,12 +83,15 @@ export class Variants {
8383 } )
8484 }
8585
86- fromAst ( name : string , ast : AstNode [ ] ) {
86+ fromAst ( name : string , ast : AstNode [ ] , designSystem : DesignSystem ) {
8787 let selectors : string [ ] = [ ]
8888
89+ let usesAtVariant = false
8990 walk ( ast , ( node ) => {
9091 if ( node . kind === 'rule' ) {
9192 selectors . push ( node . selector )
93+ } else if ( node . kind === 'at-rule' && node . name === '@variant' ) {
94+ usesAtVariant = true
9295 } else if ( node . kind === 'at-rule' && node . name !== '@slot' ) {
9396 selectors . push ( `${ node . name } ${ node . params } ` )
9497 }
@@ -98,12 +101,11 @@ export class Variants {
98101 name ,
99102 ( r ) => {
100103 let body = structuredClone ( ast )
104+ if ( usesAtVariant ) substituteAtVariant ( body , designSystem )
101105 substituteAtSlot ( body , r . nodes )
102106 r . nodes = body
103107 } ,
104- {
105- compounds : compoundsForSelectors ( selectors ) ,
106- } ,
108+ { compounds : compoundsForSelectors ( selectors ) } ,
107109 )
108110 }
109111
You can’t perform that action at this time.
0 commit comments