/** * The site's one stylesheet: the chosen design's cotton.css (src/site/cotton.css, its words untouched), with each * app's paper written in from apps.json where the design had them, so a new app's colours are one edit there. * build.ts writes it to dist/cotton.css. */ import { readFileSync } from "node:fs"; import type { App } from "./registry.ts"; const BASE = readFileSync(new URL("./cotton.css", import.meta.url), "utf8"); const rule = (id: string, vars: Record, indent: string) => `${indent}.${id} { ${Object.entries(vars).map(([k, v]) => `${k}: ${v};`).join(" ")} }`; export function cottonCss(apps: readonly App[]): string { const light = apps.map((a) => rule(a.id, a.look.paper, "")).join("\n"); const dark = apps.map((a) => rule(a.id, a.look.paperDark, " ")).join("\n"); return BASE.replace(/^\/\* @papers:.*\*\/$/m, light).replace(/^ {2}\/\* @papers-dark:.*\*\/$/m, dark); }