aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/generate.ts107
1 files changed, 104 insertions, 3 deletions
diff --git a/scripts/generate.ts b/scripts/generate.ts
index f922a9d..c78831a 100644
--- a/scripts/generate.ts
+++ b/scripts/generate.ts
@@ -7,8 +7,8 @@ import { mkdir, writeFile } from "node:fs/promises";
/*** UTILITY ------------------------------------------ ***/
-import { palette, raw, yang, yin } from "../src/colors";
-import { reduced } from "../src/index";
+import { palette, pastelPalette, pastelRaw, raw, yang, yin } from "../src/colors";
+import { pastelReduced, reduced } from "../src/index";
const buildScss = (): string => {
const lines: string[] = ["// Generated from src/colors.ts — do not edit by hand", ""];
@@ -46,6 +46,42 @@ const buildScss = (): string => {
return lines.join("\n");
};
+const buildPastelScss = (): string => {
+ const lines: string[] = ["// Generated from src/colors.ts — do not edit by hand", ""];
+
+ for (const hue of Object.keys(pastelPalette).sort()) {
+ const shades = pastelPalette[hue as keyof typeof pastelPalette];
+
+ for (const shade of Object.keys(shades).sort()) {
+ const value = shades[Number(shade) as 1];
+ lines.push(`$uchu-${hue}-${shade}-raw: ${raw[hue][shade]};`);
+ lines.push(`$uchu-${hue}-${shade}: ${value};`);
+ }
+
+ lines.push("");
+ }
+
+ lines.push(`$uchu-yang: ${yang};`);
+ lines.push(`$uchu-yin: ${yin};`);
+ lines.push("");
+ lines.push(":root {");
+
+ for (const hue of Object.keys(pastelPalette).sort()) {
+ const shades = pastelPalette[hue as keyof typeof pastelPalette];
+
+ for (const shade of Object.keys(shades).sort()) {
+ lines.push(` --uchu-${hue}-${shade}-raw: #{$uchu-${hue}-${shade}-raw};`);
+ lines.push(` --uchu-${hue}-${shade}: #{$uchu-${hue}-${shade}};`);
+ }
+ }
+
+ lines.push(` --uchu-yang: #{$uchu-yang};`);
+ lines.push(` --uchu-yin: #{$uchu-yin};`);
+ lines.push("}", "");
+
+ return lines.join("\n");
+};
+
const buildCss = (): string => {
const lines: string[] = ["/* Generated from src/colors.ts — do not edit by hand */", "", ":root {"];
@@ -66,6 +102,26 @@ const buildCss = (): string => {
return lines.join("\n");
};
+const buildPastelCss = (): string => {
+ const lines: string[] = ["/* Generated from src/colors.ts — do not edit by hand */", "", ":root {"];
+
+ for (const hue of Object.keys(pastelPalette).sort()) {
+ const shades = pastelPalette[hue as keyof typeof pastelPalette];
+
+ for (const shade of Object.keys(shades).sort()) {
+ const value = shades[Number(shade) as 1];
+ lines.push(` --uchu-${hue}-${shade}-raw: ${raw[hue][shade]};`);
+ lines.push(` --uchu-${hue}-${shade}: ${value};`);
+ }
+ }
+
+ lines.push(` --uchu-yang: ${yang};`);
+ lines.push(` --uchu-yin: ${yin};`);
+ lines.push("}", "");
+
+ return lines.join("\n");
+};
+
const buildCssReduced = (): string => {
const lines: string[] = ["/* Generated from src/index.ts — do not edit by hand */", "", ":root {"];
@@ -104,13 +160,58 @@ const buildCssReduced = (): string => {
return lines.join("\n");
};
+const buildPastelCssReduced = (): string => {
+ const lines: string[] = ["/* Generated from src/index.ts — do not edit by hand */", "", ":root {"];
+
+ for (const hue of Object.keys(pastelReduced).sort()) {
+ const shades = pastelReduced[hue as keyof typeof pastelReduced];
+
+ for (const shade of Object.keys(shades).sort()) {
+ const value = shades[Number(shade) as 1];
+
+ switch(Number(shade)) {
+ case 1: {
+ lines.push(` --uchu-light-${hue}-raw: ${raw[hue][shade]};`);
+ lines.push(` --uchu-light-${hue}: ${value};`);
+ break;
+ }
+
+ case 2: {
+ lines.push(` --uchu-${hue}-raw: ${raw[hue][shade]};`);
+ lines.push(` --uchu-${hue}: ${value};`);
+ break;
+ }
+
+ case 3: {
+ lines.push(` --uchu-dark-${hue}-raw: ${raw[hue][shade]};`);
+ lines.push(` --uchu-dark-${hue}: ${value};`);
+ break;
+ }
+ }
+ }
+ }
+
+ lines.push(` --uchu-yang: ${yang};`);
+ lines.push(` --uchu-yin: ${yin};`);
+ lines.push("}", "");
+
+ return lines.join("\n");
+};
+
/*** RUNTIME ------------------------------------------ ***/
await mkdir("dist", { recursive: true });
+
await writeFile("dist/_palette.scss", buildScss());
await writeFile("dist/uchu.css", buildCss());
await writeFile("dist/uchu-reduced.css", buildCssReduced());
await writeFile("demo/asset/style/uchu.css", buildCss());
await writeFile("demo/asset/style/uchu-reduced.css", buildCssReduced());
-console.log("Generated dist/_palette.scss and dist/uchu.css");
+await writeFile("dist/_pastel-palette.scss", buildPastelScss());
+await writeFile("dist/uchu-pastel.css", buildPastelCss());
+await writeFile("dist/uchu-pastel-reduced.css", buildPastelCssReduced());
+await writeFile("demo/asset/style/uchu-pastel.css", buildPastelCss());
+await writeFile("demo/asset/style/uchu-pastel-reduced.css", buildPastelCssReduced());
+
+console.log("Generated stylesheets");