unpreset / unocss-preset-theme

The dynamic theme presets for UnoCSS.
https://unocss-preset-theme.todev.cc
119 stars 11 forks source link

feat: move generated ':root' element to themeLayer's first #48

Closed GavinXue closed 11 months ago

GavinXue commented 11 months ago

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.

move root first img

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.

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unocss-preset-theme ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2023 2:39am
Dunqing commented 11 months ago

Hello, Thank you for your contribution.

The selector option is able to change the :root to anything, so this will cause the sort function not to work, so do we need to have the option to re-order all themes in order, e.g. a themeSort option?

The option looks like this

{
  themeSort: {
     light: 0,
     dark: 1,
     other: 2
  }
}

Do you think this is ok?

GavinXue commented 11 months ago

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. Someone who want to use multi themes at same time, should manage this themselves by their code sorts. If we offer this option,developer will care about the settings (if we have many, we should set carefully) and their code class sort. Maybe giving a option at the time someone needed will be better. anyway, if we want, I can try to make it. Waiting for your reply. Thanks😄

Dunqing commented 11 months ago

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. Someone who want to use multi themes at same time, should manage this themselves by their code sorts. If we offer this option,developer will care about the settings (if we have many, we should set carefully) and their code class sort. Maybe giving a option at the time someone needed will be better. anyway, if we want, I can try to make it. Waiting for your reply. Thanks😄

Yes, I agree with you. That's what I'm worried about. It'll make it complicated.

Dunqing commented 11 months ago

Thank you for your great work, I will merge it and publish a new version later