fix: need :root with @media queries

This commit is contained in:
D. Moonfire 2024-02-24 18:39:41 -06:00
parent e9389c5666
commit 89c338b6dd

View file

@ -56,20 +56,20 @@ require("yargs")
function build(argv) {
// Load in all the files.
let light = load(argv, "light");
let lightMoreContrast = load(argv, "light-more-contrast");
let lightLessContrast = load(argv, "light-less-contrast");
let dark = load(argv, "dark");
let darkMoreContrast = load(argv, "dark-more-contrast");
let darkLessContrast = load(argv, "dark-less-contrast");
const light = load(argv, "light");
const lightMoreContrast = load(argv, "light-more-contrast");
const lightLessContrast = load(argv, "light-less-contrast");
const dark = load(argv, "dark");
const darkMoreContrast = load(argv, "dark-more-contrast");
const darkLessContrast = load(argv, "dark-less-contrast");
// Figure out the default.
let auto = argv.default === "light" ? light : dark;
const auto = argv.default === "light" ? light : dark;
let autoMoreContrast =
const autoMoreContrast =
argv.default === "light" ? lightMoreContrast : darkMoreContrast;
let autoLessContrast =
const autoLessContrast =
argv.default === "light" ? lightLessContrast : darkLessContrast;
// Build up the components of the style.
@ -121,10 +121,18 @@ function block(selector, ...lines) {
let blockLines = [selector + " {"];
if (selector.indexOf("@media") >= 0) {
blockLines.push(":root {");
}
for (const line of lines) {
blockLines.push(line);
}
if (selector.indexOf("@media") >= 0) {
blockLines.push("}");
}
blockLines.push("}");
return blockLines.join("\n");