const sort = (a, b) => (a < b ? -1 : 1); function generateVars(theme) { let cssParts = []; for (const [key, val] of Object.entries(theme.variables)) { if (typeof val === "string") { cssParts.push(`--${key}: ${val};`); } else if (typeof val === "object") { for (const [key2, val2] of Object.entries(val)) { cssParts.push(`--${key}-${key2}: ${val2};`); } } } return `:root { ${cssParts .sort(sort) .map(part => ` ${part}`) .join("\n")} }`; }