From 4a18383e2748913a8b181fc8c3a4db5f22025f64 Mon Sep 17 00:00:00 2001 From: winston Date: Sun, 19 Mar 2023 06:02:08 +0100 Subject: [PATCH] build: add build system --- build.ts | 45 +++++++++++++++++++ deps.ts | 2 + {theme => src}/_chroma.scss | 0 .../_theme.scss | 14 +++--- {theme => src}/catppuccin/_catppuccin.scss | 0 {theme => src}/catppuccin/_frappe.scss | 0 {theme => src}/catppuccin/_latte.scss | 0 {theme => src}/catppuccin/_macchiato.scss | 0 {theme => src}/catppuccin/_mocha.scss | 0 9 files changed, 55 insertions(+), 6 deletions(-) create mode 100755 build.ts create mode 100644 deps.ts rename {theme => src}/_chroma.scss (100%) rename theme/theme-catppuccin-mocha.scss => src/_theme.scss (98%) rename {theme => src}/catppuccin/_catppuccin.scss (100%) rename {theme => src}/catppuccin/_frappe.scss (100%) rename {theme => src}/catppuccin/_latte.scss (100%) rename {theme => src}/catppuccin/_macchiato.scss (100%) rename {theme => src}/catppuccin/_mocha.scss (100%) diff --git a/build.ts b/build.ts new file mode 100755 index 0000000..f500242 --- /dev/null +++ b/build.ts @@ -0,0 +1,45 @@ +#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env + +import { path, sass } from "./deps.ts"; + +const accents = [ + "rosewater", + "flamingo", + "pink", + "mauve", + "red", + "maroon", + "peach", + "yellow", + "green", + "teal", + "sky", + "sapphire", + "blue", + "lavender", +]; + +const flavors = ["latte", "frappe", "macchiato", "mocha"]; + +const dirname = path.dirname(path.fromFileUrl(import.meta.url)); +const builder = (flavor: string, accent: string) => ` +@import "catppuccin/${flavor}"; +$accent: $${accent}; +$is-dark: ${flavor !== "latte"}; +@import "theme"; +`; + +for (const flavor of flavors) { + for (const accent of accents) { + const input = builder(flavor, accent); + const result = await sass.compileStringAsync(input, { + loadPaths: [path.join(dirname, "src")], + }); + + Deno.mkdirSync(path.join(dirname, "dist"), { recursive: true }); + await Deno.writeTextFile( + path.join(dirname, "dist", `theme-catppuccin-${flavor}-${accent}.css`), + result.css + ); + } +} diff --git a/deps.ts b/deps.ts new file mode 100644 index 0000000..b76c539 --- /dev/null +++ b/deps.ts @@ -0,0 +1,2 @@ +export * as path from "https://deno.land/std@0.180.0/path/mod.ts"; +export * as sass from "npm:sass-embedded"; diff --git a/theme/_chroma.scss b/src/_chroma.scss similarity index 100% rename from theme/_chroma.scss rename to src/_chroma.scss diff --git a/theme/theme-catppuccin-mocha.scss b/src/_theme.scss similarity index 98% rename from theme/theme-catppuccin-mocha.scss rename to src/_theme.scss index d45af82..0681e5d 100644 --- a/theme/theme-catppuccin-mocha.scss +++ b/src/_theme.scss @@ -1,12 +1,14 @@ @use "sass:color"; -@import "catppuccin/mocha"; - -$accent: $mauve; :root { - color-scheme: dark; + @if $is-dark { + color-schema: dark; + } @else { + color-schema: light; + } + --is-dark-theme: $is-dark; + accent-color: #{$accent}; - --is-dark-theme: true; --color-primary: #{$accent}; --color-primary-contrast: #{$crust}; @@ -239,4 +241,4 @@ $accent: $mauve; } @import "chroma"; -@import "../src/codemirror/dark"; +// @import "../src/codemirror/dark"; diff --git a/theme/catppuccin/_catppuccin.scss b/src/catppuccin/_catppuccin.scss similarity index 100% rename from theme/catppuccin/_catppuccin.scss rename to src/catppuccin/_catppuccin.scss diff --git a/theme/catppuccin/_frappe.scss b/src/catppuccin/_frappe.scss similarity index 100% rename from theme/catppuccin/_frappe.scss rename to src/catppuccin/_frappe.scss diff --git a/theme/catppuccin/_latte.scss b/src/catppuccin/_latte.scss similarity index 100% rename from theme/catppuccin/_latte.scss rename to src/catppuccin/_latte.scss diff --git a/theme/catppuccin/_macchiato.scss b/src/catppuccin/_macchiato.scss similarity index 100% rename from theme/catppuccin/_macchiato.scss rename to src/catppuccin/_macchiato.scss diff --git a/theme/catppuccin/_mocha.scss b/src/catppuccin/_mocha.scss similarity index 100% rename from theme/catppuccin/_mocha.scss rename to src/catppuccin/_mocha.scss