postcss / postcss-dark-theme-class

PostCSS plugin to make dark/light theme switcher by copying styles from media query to special class
MIT License
160 stars 16 forks source link

Plugin breaks complex values when `light-dark` is nested #30

Closed romainmenke closed 6 months ago

romainmenke commented 6 months ago
.light-dark-function-mix-a {
    color: light-dark(color-mix(in oklch, red, light-dark(cyan, rgb(0, 0, 0))), blue);
}

becomes

@media (prefers-color-scheme:dark) {

    :where(html:not(.is-light)) .light-dark-function-mix-a {
        color: blue;
    }
}

:where(html.is-dark) .light-dark-function-mix-a {
    color: blue;
}

@media (prefers-color-scheme:light) {

    :where(html:not(.is-dark)) .light-dark-function-mix-a {
        color: color-mix(in oklch, red, cyan;
    }
}

:where(html.is-light) .light-dark-function-mix-a {
    color: color-mix(in oklch, red, cyan;
}

color: color-mix(in oklch, red, cyan;


Might be better to use a value parser for the value replacements :)

But as the title suggests, these are complex values that are unlikely to be used by authors.

ai commented 6 months ago

Can I ask you to do it? I am too busy on another project right now.

romainmenke commented 6 months ago

Equally too busy and not blocking for me personally :) This only surfaced because I was noticed the sourcemaps issue.

You can just leave the issue open. If someone needs it they can fix it and submit a patch.

ai commented 6 months ago

@VladBrok maybe you have a time for fix light-dark() by moving to postcss-value-parser?

ai commented 6 months ago

The both fixes was released in 1.2.3. Thanks to everyone.

romainmenke commented 6 months ago

Awesome! Super speedy fix @VladBrok 🚀