import tokens from "./tokens.toml"; const out: string[] = []; const scales = ["space", "radius", "stroke", "text", "size", "leading"] as const; out.push(":root{" + scales.flatMap(scale => Object.entries(tokens[scale]).map(([name, value]) => `--${scale}-${name}:${value}${scale === "leading" ? "" : "px"}`)).join(";") + "}"); const themes = Object.entries(tokens.theme) as [string, Record][]; themes.forEach(([name, theme], index) => { const selector = index === 0 ? `:root,[data-theme=${name}]` : `[data-theme=${name}]`; const colors = Object.entries(theme).filter(([key]) => key !== "dark" && key !== "hue").map(([key, value]) => `--${key}:${value}`); const hues = (theme.hue as string[]).map((value, hue) => `--h-${tokens.hues[hue]}:${value}`); out.push(`${selector}{color-scheme:${theme.dark ? "dark" : "light"};${[...colors, ...hues].join(";")}}`); }); await Bun.write(new URL("./tokens.css", import.meta.url), out.join("\n") + "\n");