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

`!important` declaration is not being respected #28

Closed yuheiy closed 6 months ago

yuheiy commented 6 months ago

When I include the !important declaration in a property value, it gets removed during the processing. Below is the CSS where this issue occurs:

section {
  background: light-dark(white, black) !important;
}

will be processed to:

@media (prefers-color-scheme:dark) {
    :where(html:not(.is-light)) section {
        background: black
    }
}
:where(html.is-dark) section {
    background: black
}
@media (prefers-color-scheme:light) {
    :where(html:not(.is-dark)) section {
        background: white
    }
}
:where(html.is-light) section {
    background: white
}

I believe the !important declaration should be preserved after transformation to ensure the intended styles remain prioritized.

ai commented 6 months ago

Sure. Can you send PR? I am busy on another project right now.

yuheiy commented 6 months ago

OK. I will give it a try when I have some free time.