-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: move generated ':root' element to themeLayer's first #48
feat: move generated ':root' element to themeLayer's first #48
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hello, Thank you for your contribution. The The option looks like this {
themeSort: {
light: 0,
dark: 1,
other: 2
}
} Do you think this is ok? |
Hi,in my opinion,Add a theme sort maybe make the preset a bit more complicated. Because two themes will not used at same time in most of circumstances. Except the root. |
Yes, I agree with you. That's what I'm worried about. It'll make it complicated. |
src/index.ts
Outdated
@@ -167,6 +167,10 @@ export function presetTheme<T extends Record<string, any>>(options: PresetThemeO | |||
line = line.replace(/\..*?\s(.*\{)/, '$1') | |||
} | |||
return line | |||
}).sort((a, b) => { | |||
if (a.match(/^:root|^@media|^\}/)?.length) | |||
return b.match(/^:root|^@media|^\}/)?.length ? 0 : -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here two lines of code use the same RegExp, So we should store the RegExp to a new variable and then use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll make it clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix it, please have a check.
merge from main to fix last pr's test code
Thank you for your great work, I will merge it and publish a new version later |
With last version, When we put
class="dark"
(or other themes) in html root element, It will not change the theme, because the dark theme will covered by:root
vars. Just like under image display.Maybe moving the
:root
element to first make more sense (also changed the test case). if there is any problem I didn't care about, please let me know.