postcss-dark-theme-class icon indicating copy to clipboard operation
postcss-dark-theme-class copied to clipboard

Hope to support「preferred-color-scheme: light」🙏

Open aweiu opened this issue 5 years ago • 1 comments

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;
}

aweiu avatar Jun 30 '20 08:06 aweiu

Good idea! Can you send a pull request to save your name in the project history?

ai avatar Jul 01 '20 04:07 ai