From 4411eafbf7522c6ec41df2441eb3e7f903632912 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 1 Nov 2024 23:31:07 +0000 Subject: [PATCH 1/2] wip: generate ansi css --- scripts/builders/npm/css.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/builders/npm/css.ts b/scripts/builders/npm/css.ts index 7bd816a..9705820 100644 --- a/scripts/builders/npm/css.ts +++ b/scripts/builders/npm/css.ts @@ -4,11 +4,10 @@ import { ensureDir } from "std/fs/mod.ts"; import { flavorEntries } from "@catppuccin/palette"; const template = flavorEntries - .map(([flavorName, { colorEntries }]) => { + .map(([flavorName, { colorEntries, ansiColorEntries }]) => { const colors = colorEntries .map(([colorName, { hex, rgb, hsl: { h, s, l } }]) => { const name = `--ctp-${flavorName}-${colorName}`; - return [ sprintf(" %s: %s;", name, hex), sprintf(" %s-rgb: %d %d %d;", name, ...Object.values(rgb)), @@ -16,12 +15,21 @@ const template = flavorEntries ].join("\n"); }) .join("\n"); - return `:root {\n${colors}\n}`; + + const ansiColors = ansiColorEntries.map( + ([ansiColorName, { normal, bright }]) => { + return [normal, bright].map((group) => { + const name = `--ctp-${flavorName}-ansi-${group}-${ansiColorName}`; + return sprintf(" %s: %s;", name, group.hex); + }).join("\n"); + }, + ); + + return `:root {\n${colors}\n${ansiColors}\n}`; }) .join("\n\n"); export const compileCss = async (outDir: string) => { await ensureDir(`${outDir}/css`); - Deno.writeTextFile(`${outDir}/css/catppuccin.css`, template); }; From 16ff8bde8029d44ac6ef17a06649930e5fa47f91 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 1 Nov 2024 23:46:07 +0000 Subject: [PATCH 2/2] feat(css/scss/less): add ansi colours --- scripts/builders/npm/css.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/builders/npm/css.ts b/scripts/builders/npm/css.ts index 9705820..3ef20f1 100644 --- a/scripts/builders/npm/css.ts +++ b/scripts/builders/npm/css.ts @@ -19,11 +19,12 @@ const template = flavorEntries const ansiColors = ansiColorEntries.map( ([ansiColorName, { normal, bright }]) => { return [normal, bright].map((group) => { - const name = `--ctp-${flavorName}-ansi-${group}-${ansiColorName}`; - return sprintf(" %s: %s;", name, group.hex); + const name = + `--ctp-${flavorName}-ansi-${group.name.toLowerCase()}-${ansiColorName}`; + return sprintf(" %s: %s;", name, group.hex); }).join("\n"); }, - ); + ).join("\n"); return `:root {\n${colors}\n${ansiColors}\n}`; })