@@ -208,40 +208,49 @@ function createThemeRule(className) {
208
208
theme = theme [ 0 ] ;
209
209
pseudo . shift ( ) ;
210
210
}
211
+ let important = "" ;
212
+ let importantSuffix = "" ;
213
+ if ( className . includes ( '!important' ) ) {
214
+ [ className , important ] = className . split ( "!" ) ;
215
+ important = '!' + important ;
216
+ importantSuffix = parseValue ( important ) ;
217
+ important = '!important' ;
218
+ }
211
219
212
220
let res = className . split ( ':' ) ;
213
- if ( res . length > 2 ) {
214
- console . log ( 'pseudo names need to be added after theme' ) ;
215
- return ;
216
- }
221
+ // if (res.length > 2) {
222
+ // console.log('pseudo names need to be added after theme');
223
+ // return;
224
+ // }
217
225
let property = res [ 0 ] ;
218
226
let suffix = parseValue ( res [ 1 ] ) ;
219
227
let value = res [ 1 ] . replace ( / _ / g, " " ) ;
220
228
229
+ //TODO: set theme rule with pseudo and !important
221
230
let rule = "" ;
222
- if ( pseudo ) {
223
- suffix += "\\@" + theme ;
224
- for ( let i = 0 ; i < pseudo . length ; i ++ ) {
225
- suffix += ":" + pseudo [ 0 + i ] ;
226
- }
227
- rule = `.${ property } \\:${ suffix } { ${ property } : ${ value } ; }` ;
228
- }
229
- else {
231
+ if ( res . length > 2 ) {
232
+ // suffix += "\\@" + theme;
233
+ // for (let i = 0; i < res.length - 2; i++) {
234
+ suffix += "\\:" + res [ 2 ] + importantSuffix + ":" + "\\@" + theme + ":" + res [ 2 ] ;
235
+ // }
236
+ rule = `.${ property } \\:${ suffix } { ${ property } : ${ value } ${ important } ; }` ;
237
+ } else {
230
238
rule = `.${ property } \\:${ suffix } \\@${ theme } { ${ property } : ${ value } ; }` ;
231
239
}
240
+
232
241
if ( theme == 'dark' || theme == 'light' ) {
233
242
// rule = `[theme="${theme}"] ${rule}`;
234
243
// let reverseRule = `html:not([theme="${themes[1 - themes.indexOf(theme)]}"]) ${rule}`;
235
- let reverseRule = `${ rule } ` ;
236
- tempStyleList . push ( rule ) ;
237
- themeCSS [ theme ] . push ( reverseRule ) ;
244
+ // let reverseRule = `${rule}`;
245
+ // tempStyleList.push(rule);
246
+ themeCSS [ theme ] . push ( rule ) ;
238
247
classNameList . set ( classname , true ) ;
239
248
}
240
249
}
241
250
242
251
function createThemeMedia ( ) {
243
- let initial ;
244
252
if ( themeCSS . dark . length ) {
253
+ let initial ;
245
254
initial = "@media (prefers-color-scheme: dark) {" ;
246
255
for ( let c of themeCSS . dark ) {
247
256
initial += c + "\n" ;
@@ -251,6 +260,7 @@ function createThemeMedia() {
251
260
themeCSS . dark = [ ] ;
252
261
}
253
262
if ( themeCSS . light . length ) {
263
+ let initial ;
254
264
initial = "@media (prefers-color-scheme: light) {" ;
255
265
for ( let c of themeCSS . light ) {
256
266
initial += c + "\n" ;
0 commit comments