-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid CSS generation with color-scheme and light-dark() function #873
Comments
No, they may be in any order. The syntax is
That's not how |
Ah, thank you, I tested and that's true,
I'd say it's broken, let's take this code, we're setting :root {
color-scheme: light dark;
--white: #fff;
--black: #000;
--bg: light-dark(var(--white), var(--black));
--fg: light-dark(var(--black), var(--white));
}
body {
background-color: var(--bg);
color: var(--fg);
}
.dark {
color-scheme: only dark;
background-color: var(--bg);
color: var(--fg);
}
.light {
color-scheme: only light;
background-color: var(--bg);
color: var(--fg);
}
.inverse {
background-color: var(--fg);
color: var(--bg);
} Output with simple HTML (inlining the stylesheet):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>C CSS Framework</title>
<style>:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--white:#fff;--black:#000;--bg:var(--lightningcss-light,var(--white))var(--lightningcss-dark,var(--black));--fg:var(--lightningcss-light,var(--black))var(--lightningcss-dark,var(--white))}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}body{background-color:var(--bg);color:var(--fg)}.dark{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark only;background-color:var(--bg);color:var(--fg)}.light{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light only;background-color:var(--bg);color:var(--fg)}.inverse{background-color:var(--fg);color:var(--bg)}</style>
</head>
<body>
<article class="grid">
<h1>C CSS Framework</h1>
<section class="dark">
<h2>Everytime dark</h2>
</section>
<section class="light">
<h2>Everytime light</h2>
</section>
<section class="inverse">
<h2>Everytime inverse</h2>
</section>
</article>
</body>
</html> How it should be?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>C CSS Framework</title>
<style>
:root {
color-scheme: light dark;
--white: #fff;
--black: #000;
--bg: light-dark(var(--white), var(--black));
--fg: light-dark(var(--black), var(--white));
}
body {
background-color: var(--bg);
color: var(--fg);
}
.dark {
color-scheme: only dark;
background-color: var(--bg);
color: var(--fg);
}
.light {
color-scheme: only light;
background-color: var(--bg);
color: var(--fg);
}
.inverse {
background-color: var(--fg);
color: var(--bg);
}
</style>
</head>
<body>
<article class="grid">
<h1>C CSS Framework</h1>
<section class="dark">
<h2>Everytime dark</h2>
</section>
<section class="light">
<h2>Everytime light</h2>
</section>
<section class="inverse">
<h2>Everytime inverse</h2>
</section>
</article>
</body>
</html> |
Problems:
only
anddark
||light
words, which is invalid, it has to beonly dark
||only light
. 1light-dark()
function--lightningcss-light
and--lightningcss-dark
; with theme one of them is set to initial and other one is left as none, but if you ask me the best approach would be having@media (prefers-color-scheme: dark)
and setting it there as the dark of light-dark() function's second argument and in:root
or where it's declared, creating it as normal.Input Example Code:
Output Example Code:
What it should be?
The text was updated successfully, but these errors were encountered: