postcss-dark-theme-class
postcss-dark-theme-class copied to clipboard
Hope to support「preferred-color-scheme: light」🙏
input:
/* no theme */
:root {
--bgColor: red;
}
/* light theme */
@media (prefers-color-scheme: light) {
:root {
--bgColor: yellow;
}
}
/* dark theme */
@media (prefers-color-scheme: dark) {
:root {
--bgColor: blue;
}
}
expect output:
/* no theme */
:root {
--bgColor: red;
}
/* light theme */
:root[data-theme="light"] {
--bgColor: yellow;
}
/* dark theme */
:root[data-theme="light"] {
--bgColor: yellow;
}
real output:
/* no theme */
:root {
--bgColor: red;
}
/* light theme */
@media (prefers-color-scheme: light) {
:root {
--bgColor: yellow;
}
}
/* dark theme */
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bgColor: blue;
}
}
:root[data-theme="dark"] {
--bgColor: blue;
}
Good idea! Can you send a pull request to save your name in the project history?