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

Suggestion: use `:not(.is-dark)` as lightSelector by default #35

Open aletorrado opened 6 months ago

aletorrado commented 6 months ago

Hi,

This is a very subjective matter, but I wanted to suggest you for the sake of simplicity, to just use a negated :not(.is-dark) selector as the default lightSelector. Even, the plugin may compute something like :not(<darkSelector>), so that the user can safely override darkSelector preserving the same behavior.

Using a single class or attribute seems like a good idea to simplify JS manipulation and avoid invalid states if by any means both is-light and is-dark are triggered.

If you agree with this, I would be glad to submit a PR.

Thanks!

ai commented 6 months ago

Theme has 3 states: force light, force dark, and system theme.

You can't do 3 state with 1 class. So in CSS mode we need 2 classes and :not() will not see a difference between light and system theme.

aletorrado commented 6 months ago

You're totally correct. This only makes sense with the preserve: false functionality that I proposed.

Thanks