Skip to content

Commit

Permalink
$mol_style: + [attr] syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Dec 16, 2023
1 parent 2e990ae commit 1eabbb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions style/guard/guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace $ {
: key extends '@media'
? Medias< View , Config[key] >

: key extends `[${string}]`
? { [ val in keyof Config[key] ]: $mol_style_guard< View , Config[key][val] > }

: key extends `--${string}`
? any

Expand Down
9 changes: 9 additions & 0 deletions style/sheet/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ namespace $ {

}

} else if( key[0] === '[' && key[key.length-1] === ']' ) {

const attr = key.slice( 1, -1 )
const vals = config[ key as any ] as Record< string, any >

for( let val in vals ) {
make_class( selector( prefix , path ) + ':where([' + attr + '=' + JSON.stringify( val ) + '])' , [] , vals[val] )
}

} else {

make_class( selector( prefix , path ) + key , [] , (config as any)[key] )
Expand Down

0 comments on commit 1eabbb5

Please sign in to comment.