.
This commit is contained in:
1 parent
77a5f5248c
commit
f0bba7e7b9
68 files changed
+5149
-142
No files matched your search
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { generatePalette } from "./generator.mjs";
|
||||
|
||||
function parseArgs(argv) {
|
||||
const supported = new Set(["help", "key-color", "mode", "character", "harmony", "temperature", "format", "out"]);
|
||||
const options = {};
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const token = argv[index];
|
||||
if (!token.startsWith("--")) throw new Error(`Unexpected argument: ${token}`);
|
||||
const key = token.slice(2);
|
||||
if (!supported.has(key)) throw new Error(`Unknown option: --${key}`);
|
||||
if (key === "help") {
|
||||
options.help = true;
|
||||
continue;
|
||||
}
|
||||
const value = argv[index + 1];
|
||||
if (!value || value.startsWith("--")) throw new Error(`Missing value for --${key}`);
|
||||
options[key] = value;
|
||||
index += 1;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function help() {
|
||||
return `StyleSeed Palette Engine
|
||||
|
||||
Usage:
|
||||
generate-palette.mjs --key-color <hex> [options]
|
||||
|
||||
Options:
|
||||
--key-color <hex> Brand/product key color (required)
|
||||
--mode light|dark default: light
|
||||
--character calm|balanced|vivid|deep
|
||||
--harmony auto|tonal|adjacent|contrast
|
||||
--temperature neutral|warm|cool
|
||||
--format json|css|summary default: json
|
||||
--out <path> write output instead of stdout
|
||||
`;
|
||||
}
|
||||
|
||||
try {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
if (args.help) {
|
||||
console.log(help());
|
||||
process.exit(0);
|
||||
}
|
||||
if (!args["key-color"]) throw new Error("--key-color is required");
|
||||
const palette = generatePalette({
|
||||
keyColor: args["key-color"],
|
||||
mode: args.mode,
|
||||
character: args.character,
|
||||
harmony: args.harmony,
|
||||
temperature: args.temperature,
|
||||
});
|
||||
const format = args.format || "json";
|
||||
if (!["json", "css", "summary"].includes(format)) {
|
||||
throw new Error(`Invalid format: ${format}. Supported: json, css, summary`);
|
||||
}
|
||||
const output = format === "css"
|
||||
? `${palette.css}\n`
|
||||
: format === "summary"
|
||||
? `${JSON.stringify({ input: palette.input, roles: palette.roles, valid: palette.valid, contrast: palette.contrast, decisions: palette.decisions }, null, 2)}\n`
|
||||
: `${JSON.stringify(palette, null, 2)}\n`;
|
||||
if (args.out) {
|
||||
const target = resolve(args.out);
|
||||
mkdirSync(dirname(target), { recursive: true });
|
||||
writeFileSync(target, output);
|
||||
console.log(target);
|
||||
} else {
|
||||
process.stdout.write(output);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Palette generation failed: ${error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
export type PaletteMode = "light" | "dark";
|
||||
export type PaletteCharacter = "calm" | "balanced" | "vivid" | "deep";
|
||||
export type PaletteHarmony = "auto" | "tonal" | "adjacent" | "contrast";
|
||||
export type PaletteTemperature = "neutral" | "warm" | "cool";
|
||||
|
||||
export type PaletteGenerationOptions = {
|
||||
keyColor?: string;
|
||||
mode?: PaletteMode;
|
||||
character?: PaletteCharacter;
|
||||
harmony?: PaletteHarmony;
|
||||
temperature?: PaletteTemperature;
|
||||
};
|
||||
|
||||
export type GeneratedPalette = {
|
||||
schemaVersion: number;
|
||||
generator: { name: string; version: string; colorSpace: string; targetGamut: string };
|
||||
input: Required<PaletteGenerationOptions>;
|
||||
normalizedKey: { hex: string; oklch: { l: number; c: number; h: number } };
|
||||
decisions: {
|
||||
character: string;
|
||||
accent: { hue: number; offset: number; method: PaletteHarmony; avoidsStatusCollisionBy: number };
|
||||
primaryAdjustedForContrast: boolean;
|
||||
accentAdjustedForContrast: boolean;
|
||||
allocation: { dominant: string; secondary: string; accent: string };
|
||||
};
|
||||
ramps: { primary: Record<string, string>; accent: Record<string, string> };
|
||||
roles: Record<string, string>;
|
||||
contrast: Array<{ foreground: string; background: string; ratio: number; minimum: number; pass: boolean }>;
|
||||
valid: boolean;
|
||||
assetBrief: { anchors: string[]; hierarchy: string; avoid: string[] };
|
||||
reasoning: string[];
|
||||
css: string;
|
||||
};
|
||||
|
||||
export function generatePalette(options?: PaletteGenerationOptions): GeneratedPalette;
|
||||
export function contrast(a: string, b: string): number;
|
||||
export function hexToOklch(hex: string): { l: number; c: number; h: number };
|
||||
export function normalizeHex(hex: string): string;
|
||||
export function oklchToHex(color: { l: number; c: number; h: number }): string;
|
||||
export function generatePaletteCss(result: GeneratedPalette): string;
|
||||
@@ -0,0 +1,308 @@
|
||||
const VERSION = "1.0.0";
|
||||
|
||||
const CHARACTER = {
|
||||
calm: { label: "Calm", chroma: 0.72, accent: 0.78, surface: 0.010, primaryLight: 0.48, primaryDark: 0.76 },
|
||||
balanced: { label: "Balanced", chroma: 0.94, accent: 0.96, surface: 0.014, primaryLight: 0.50, primaryDark: 0.75 },
|
||||
vivid: { label: "Vivid", chroma: 1.14, accent: 1.15, surface: 0.018, primaryLight: 0.53, primaryDark: 0.78 },
|
||||
deep: { label: "Deep", chroma: 0.90, accent: 0.92, surface: 0.014, primaryLight: 0.42, primaryDark: 0.70 },
|
||||
};
|
||||
|
||||
const TEMPERATURE_HUE = { neutral: null, warm: 65, cool: 245 };
|
||||
const STATUS_HUES = { success: 148, warning: 78, danger: 27 };
|
||||
const RAMP_LIGHTNESS = [0.98, 0.94, 0.88, 0.80, 0.70, 0.61, 0.53, 0.45, 0.36, 0.27, 0.18];
|
||||
const RAMP_KEYS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
||||
|
||||
function option(value, fallback, supported, label) {
|
||||
if (value === undefined || value === null || value === "") return fallback;
|
||||
if (!supported.includes(value)) {
|
||||
throw new Error(`Invalid ${label}: ${value}. Supported: ${supported.join(", ")}`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function clamp(value, min = 0, max = 1) {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
|
||||
function wrapHue(value) {
|
||||
return ((value % 360) + 360) % 360;
|
||||
}
|
||||
|
||||
function hueDistance(a, b) {
|
||||
const direct = Math.abs(wrapHue(a) - wrapHue(b));
|
||||
return Math.min(direct, 360 - direct);
|
||||
}
|
||||
|
||||
function normalizeHex(input) {
|
||||
const value = String(input || "").trim();
|
||||
const expanded = /^#[0-9a-f]{3}$/i.test(value)
|
||||
? `#${value.slice(1).split("").map((part) => part + part).join("")}`
|
||||
: value;
|
||||
if (!/^#[0-9a-f]{6}$/i.test(expanded)) throw new Error(`Invalid key color: ${input}`);
|
||||
return expanded.toUpperCase();
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
const value = normalizeHex(hex);
|
||||
return [1, 3, 5].map((index) => Number.parseInt(value.slice(index, index + 2), 16) / 255);
|
||||
}
|
||||
|
||||
function linearize(value) {
|
||||
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
||||
}
|
||||
|
||||
function delinearize(value) {
|
||||
return value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
||||
}
|
||||
|
||||
function rgbToOklab(rgb) {
|
||||
const [r, g, b] = rgb.map(linearize);
|
||||
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
||||
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
||||
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
||||
return {
|
||||
l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
||||
a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
||||
b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
||||
};
|
||||
}
|
||||
|
||||
function oklabToLinearRgb({ l, a, b }) {
|
||||
const ll = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
||||
const mm = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
||||
const ss = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
||||
return [
|
||||
4.0767416621 * ll - 3.3077115913 * mm + 0.2309699292 * ss,
|
||||
-1.2684380046 * ll + 2.6097574011 * mm - 0.3413193965 * ss,
|
||||
-0.0041960863 * ll - 0.7034186147 * mm + 1.707614701 * ss,
|
||||
];
|
||||
}
|
||||
|
||||
function oklchToOklab({ l, c, h }) {
|
||||
const radians = wrapHue(h) * Math.PI / 180;
|
||||
return { l, a: c * Math.cos(radians), b: c * Math.sin(radians) };
|
||||
}
|
||||
|
||||
function hexToOklch(hex) {
|
||||
const lab = rgbToOklab(hexToRgb(hex));
|
||||
const c = Math.sqrt(lab.a ** 2 + lab.b ** 2);
|
||||
return { l: lab.l, c, h: c < 0.0001 ? 0 : wrapHue(Math.atan2(lab.b, lab.a) * 180 / Math.PI) };
|
||||
}
|
||||
|
||||
function inSrgb(linearRgb) {
|
||||
return linearRgb.every((value) => value >= -0.000001 && value <= 1.000001);
|
||||
}
|
||||
|
||||
function fitOklch(color) {
|
||||
const target = { l: clamp(color.l), c: Math.max(0, color.c), h: wrapHue(color.h) };
|
||||
if (inSrgb(oklabToLinearRgb(oklchToOklab(target)))) return target;
|
||||
let low = 0;
|
||||
let high = target.c;
|
||||
for (let index = 0; index < 24; index += 1) {
|
||||
const c = (low + high) / 2;
|
||||
if (inSrgb(oklabToLinearRgb(oklchToOklab({ ...target, c })))) low = c;
|
||||
else high = c;
|
||||
}
|
||||
return { ...target, c: low };
|
||||
}
|
||||
|
||||
function oklchToHex(input) {
|
||||
const color = fitOklch(input);
|
||||
const rgb = oklabToLinearRgb(oklchToOklab(color)).map((value) => clamp(delinearize(value)));
|
||||
return `#${rgb.map((value) => Math.round(value * 255).toString(16).padStart(2, "0")).join("")}`.toUpperCase();
|
||||
}
|
||||
|
||||
function luminance(hex) {
|
||||
const [r, g, b] = hexToRgb(hex).map(linearize);
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
}
|
||||
|
||||
function contrast(a, b) {
|
||||
const values = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
||||
return (values[0] + 0.05) / (values[1] + 0.05);
|
||||
}
|
||||
|
||||
function readableForeground(background, dark, light, target = 4.5) {
|
||||
const candidates = [dark, light].map((hex) => ({ hex, ratio: contrast(hex, background) }));
|
||||
candidates.sort((a, b) => b.ratio - a.ratio);
|
||||
return { ...candidates[0], pass: candidates[0].ratio >= target };
|
||||
}
|
||||
|
||||
function accessibleFill(color, dark, light, target = 4.5) {
|
||||
const firstHex = oklchToHex(color);
|
||||
const firstForeground = readableForeground(firstHex, dark, light, target);
|
||||
if (firstForeground.pass) return { color: fitOklch(color), hex: firstHex, foreground: firstForeground.hex, ratio: firstForeground.ratio, adjusted: false };
|
||||
|
||||
let winner = null;
|
||||
for (let step = 3; step <= 97; step += 1) {
|
||||
const candidate = fitOklch({ ...color, l: step / 100 });
|
||||
const hex = oklchToHex(candidate);
|
||||
const foreground = readableForeground(hex, dark, light, target);
|
||||
if (!foreground.pass) continue;
|
||||
const distance = Math.abs(candidate.l - color.l) + Math.abs(candidate.c - color.c) * 0.25;
|
||||
if (!winner || distance < winner.distance) winner = { color: candidate, hex, foreground: foreground.hex, ratio: foreground.ratio, distance };
|
||||
}
|
||||
if (!winner) throw new Error("Unable to derive an accessible fill");
|
||||
return { ...winner, adjusted: true };
|
||||
}
|
||||
|
||||
function rolePair(roles, foreground, background, minimum) {
|
||||
const ratio = contrast(roles[foreground], roles[background]);
|
||||
return { foreground, background, ratio: Number(ratio.toFixed(2)), minimum, pass: ratio >= minimum };
|
||||
}
|
||||
|
||||
function chooseAccentHue(keyHue, harmony, character) {
|
||||
const offsets = {
|
||||
tonal: [0, 24, -24],
|
||||
adjacent: [42, -42, 68, -68],
|
||||
contrast: [145, -145, 180, 118, -118],
|
||||
auto: character === "calm" ? [42, -42, 68, -68] : character === "deep" ? [-72, 72, 132, -132] : [118, -118, 148, -148, 42],
|
||||
}[harmony];
|
||||
const candidates = offsets.map((offset, index) => {
|
||||
const hue = wrapHue(keyHue + offset);
|
||||
const semanticDistance = Math.min(...Object.values(STATUS_HUES).map((statusHue) => hueDistance(hue, statusHue)));
|
||||
const keyDistance = hueDistance(hue, keyHue);
|
||||
const separationTarget = harmony === "tonal" ? 12 : harmony === "adjacent" ? 46 : 130;
|
||||
const score = semanticDistance * 0.75 - Math.abs(keyDistance - separationTarget) * 0.3 - index * 0.5;
|
||||
return { hue, offset, score, semanticDistance };
|
||||
});
|
||||
candidates.sort((a, b) => b.score - a.score);
|
||||
return candidates[0];
|
||||
}
|
||||
|
||||
function surfaceColor(lightness, hue, chroma) {
|
||||
return oklchToHex({ l: lightness, c: chroma, h: hue });
|
||||
}
|
||||
|
||||
function makeRamp(hue, chroma) {
|
||||
return Object.fromEntries(RAMP_LIGHTNESS.map((lightness, index) => {
|
||||
const centerWeight = 0.62 + 0.38 * (1 - Math.abs(lightness - 0.56) / 0.5);
|
||||
return [RAMP_KEYS[index], oklchToHex({ l: lightness, c: chroma * clamp(centerWeight, 0.5, 1), h: hue })];
|
||||
}));
|
||||
}
|
||||
|
||||
function tokenCss(result) {
|
||||
const declarations = Object.entries(result.roles)
|
||||
.map(([role, value]) => ` --ss-${role.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)}: ${value};`)
|
||||
.join("\n");
|
||||
const ramps = Object.entries(result.ramps)
|
||||
.flatMap(([name, ramp]) => Object.entries(ramp)
|
||||
.map(([step, value]) => ` --ss-${name}-${step}: ${value};`))
|
||||
.join("\n");
|
||||
return `:root {\n${declarations}\n${ramps}\n}`;
|
||||
}
|
||||
|
||||
export function generatePalette(options = {}) {
|
||||
const keyColor = normalizeHex(options.keyColor || "#276B5E");
|
||||
const mode = option(options.mode, "light", ["light", "dark"], "mode");
|
||||
const character = option(options.character, "balanced", Object.keys(CHARACTER), "character");
|
||||
const harmony = option(options.harmony, "auto", ["auto", "tonal", "adjacent", "contrast"], "harmony");
|
||||
const temperature = option(options.temperature, "neutral", Object.keys(TEMPERATURE_HUE), "temperature");
|
||||
const config = CHARACTER[character];
|
||||
const key = hexToOklch(keyColor);
|
||||
const keyHue = key.c < 0.025 ? 250 : key.h;
|
||||
const neutralHue = TEMPERATURE_HUE[temperature] ?? keyHue;
|
||||
const neutralChroma = temperature === "neutral" ? Math.min(config.surface, Math.max(0.004, key.c * 0.08)) : config.surface;
|
||||
const darkInk = surfaceColor(mode === "dark" ? 0.10 : 0.15, neutralHue, neutralChroma * 0.55);
|
||||
const lightPaper = surfaceColor(mode === "dark" ? 0.96 : 0.99, neutralHue, neutralChroma * 0.42);
|
||||
|
||||
const primaryChroma = clamp(Math.max(key.c, 0.095) * config.chroma, 0.075, character === "vivid" ? 0.25 : 0.19);
|
||||
const primary = accessibleFill({ l: mode === "dark" ? config.primaryDark : config.primaryLight, c: primaryChroma, h: keyHue }, darkInk, lightPaper);
|
||||
const accentChoice = chooseAccentHue(keyHue, harmony, character);
|
||||
const accentChroma = clamp(Math.max(primary.color.c * config.accent, 0.085), 0.075, character === "vivid" ? 0.22 : 0.17);
|
||||
const accent = accessibleFill({ l: mode === "dark" ? 0.79 : 0.48, c: accentChroma, h: accentChoice.hue }, darkInk, lightPaper);
|
||||
|
||||
const levels = mode === "dark"
|
||||
? { background: 0.105, surface: 0.155, chrome: 0.215, muted: 0.72, border: 0.34 }
|
||||
: { background: 0.965, surface: 0.992, chrome: 0.91, muted: 0.43, border: 0.79 };
|
||||
const background = surfaceColor(levels.background, neutralHue, neutralChroma);
|
||||
const surface = surfaceColor(levels.surface, neutralHue, neutralChroma * 0.55);
|
||||
const chrome = surfaceColor(levels.chrome, neutralHue, neutralChroma * 1.25);
|
||||
const foreground = mode === "dark" ? lightPaper : darkInk;
|
||||
const mutedForegroundCandidate = surfaceColor(levels.muted, neutralHue, neutralChroma * 0.7);
|
||||
const mutedForeground = contrast(mutedForegroundCandidate, background) >= 4.5
|
||||
? mutedForegroundCandidate
|
||||
: readableForeground(background, darkInk, lightPaper, 4.5).hex;
|
||||
const chromeForeground = readableForeground(chrome, darkInk, lightPaper, 4.5).hex;
|
||||
|
||||
const status = Object.fromEntries(Object.entries(STATUS_HUES).map(([role, hue]) => {
|
||||
const chroma = role === "warning" ? 0.12 : 0.14;
|
||||
return [role, accessibleFill({ l: mode === "dark" ? 0.78 : 0.44, c: chroma, h: hue }, darkInk, lightPaper)];
|
||||
}));
|
||||
|
||||
const focusCandidates = [accent.hex, primary.hex, surfaceColor(mode === "dark" ? 0.82 : 0.48, 250, 0.16)];
|
||||
const focus = focusCandidates
|
||||
.map((hex) => ({ hex, score: Math.min(contrast(hex, background), contrast(hex, surface)) }))
|
||||
.sort((a, b) => b.score - a.score)[0].hex;
|
||||
|
||||
const roles = {
|
||||
background,
|
||||
surface,
|
||||
chrome,
|
||||
foreground,
|
||||
mutedForeground,
|
||||
chromeForeground,
|
||||
border: surfaceColor(levels.border, neutralHue, neutralChroma * 1.4),
|
||||
primary: primary.hex,
|
||||
primaryForeground: primary.foreground,
|
||||
accent: accent.hex,
|
||||
accentForeground: accent.foreground,
|
||||
focus,
|
||||
success: status.success.hex,
|
||||
successForeground: status.success.foreground,
|
||||
warning: status.warning.hex,
|
||||
warningForeground: status.warning.foreground,
|
||||
danger: status.danger.hex,
|
||||
dangerForeground: status.danger.foreground,
|
||||
};
|
||||
|
||||
const contrastChecks = [
|
||||
rolePair(roles, "foreground", "background", 4.5),
|
||||
rolePair(roles, "mutedForeground", "background", 4.5),
|
||||
rolePair(roles, "foreground", "surface", 4.5),
|
||||
rolePair(roles, "chromeForeground", "chrome", 4.5),
|
||||
rolePair(roles, "primaryForeground", "primary", 4.5),
|
||||
rolePair(roles, "accentForeground", "accent", 4.5),
|
||||
rolePair(roles, "successForeground", "success", 4.5),
|
||||
rolePair(roles, "warningForeground", "warning", 4.5),
|
||||
rolePair(roles, "dangerForeground", "danger", 4.5),
|
||||
rolePair(roles, "focus", "background", 3),
|
||||
rolePair(roles, "focus", "surface", 3),
|
||||
];
|
||||
|
||||
const result = {
|
||||
schemaVersion: 1,
|
||||
generator: { name: "StyleSeed Palette Engine", version: VERSION, colorSpace: "OKLCH", targetGamut: "sRGB" },
|
||||
input: { keyColor, mode, character, harmony, temperature },
|
||||
normalizedKey: {
|
||||
hex: keyColor,
|
||||
oklch: { l: Number(key.l.toFixed(4)), c: Number(key.c.toFixed(4)), h: Number(keyHue.toFixed(2)) },
|
||||
},
|
||||
decisions: {
|
||||
character: `${config.label} character controls lightness/chroma before hue harmony.`,
|
||||
accent: { hue: Number(accentChoice.hue.toFixed(2)), offset: accentChoice.offset, method: harmony, avoidsStatusCollisionBy: Number(accentChoice.semanticDistance.toFixed(2)) },
|
||||
primaryAdjustedForContrast: primary.adjusted,
|
||||
accentAdjustedForContrast: accent.adjusted,
|
||||
allocation: { dominant: "60% canvas and surfaces", secondary: "30% chrome, type, and supporting structure", accent: "10% primary/accent emphasis combined" },
|
||||
},
|
||||
ramps: { primary: makeRamp(keyHue, primaryChroma), accent: makeRamp(accentChoice.hue, accentChroma) },
|
||||
roles,
|
||||
contrast: contrastChecks,
|
||||
valid: contrastChecks.every((item) => item.pass),
|
||||
assetBrief: {
|
||||
anchors: [background, primary.hex, accent.hex],
|
||||
hierarchy: "background dominant; primary identifies the product/action; accent is rare supporting emphasis",
|
||||
avoid: ["equal-area competing accents", "rainbow category decoration", "text baked into generated imagery"],
|
||||
},
|
||||
reasoning: [
|
||||
"Character is chosen before harmony: lightness and chroma drive perceived calm or intensity more reliably than hue geometry alone.",
|
||||
"The key hue is preserved while chroma is reduced to the sRGB gamut boundary instead of clipping RGB channels.",
|
||||
`The ${harmony} accent candidate is scored for separation from the key and reserved success, warning, and danger hues.`,
|
||||
"Reference colors are mapped through semantic roles; components should never consume raw ramp values directly.",
|
||||
"Every text, action, status, and focus pair is checked after generation; failing fills are moved in lightness while preserving hue identity.",
|
||||
],
|
||||
};
|
||||
return { ...result, css: tokenCss(result) };
|
||||
}
|
||||
|
||||
export { contrast, hexToOklch, normalizeHex, oklchToHex, tokenCss as generatePaletteCss };
|
||||
@@ -0,0 +1,12 @@
|
||||
import palettes from "./palettes.json";
|
||||
|
||||
export * from "./generator.mjs";
|
||||
|
||||
export type PaletteRecipe = (typeof palettes)[number];
|
||||
export type PaletteRecipeId = PaletteRecipe["id"];
|
||||
|
||||
export const PALETTE_RECIPES = palettes;
|
||||
|
||||
export const PALETTE_BY_ID = Object.fromEntries(
|
||||
palettes.map((palette) => [palette.id, palette]),
|
||||
) as Record<PaletteRecipeId, PaletteRecipe>;
|
||||
@@ -0,0 +1,234 @@
|
||||
[
|
||||
{
|
||||
"id": "quiet-mineral",
|
||||
"name": "Quiet mineral",
|
||||
"mode": "light",
|
||||
"bestFor": "Calm consumer products, health, benefits, and personal utilities",
|
||||
"recipeBias": ["calm-consumer", "native-mobile"],
|
||||
"roles": {
|
||||
"background": "#F3F0E8",
|
||||
"surface": "#FFFDF8",
|
||||
"chrome": "#DCE7E0",
|
||||
"foreground": "#19211F",
|
||||
"mutedForeground": "#56635F",
|
||||
"chromeForeground": "#19211F",
|
||||
"border": "#BFC9C2",
|
||||
"primary": "#276B5E",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#D56A45",
|
||||
"accentForeground": "#211713",
|
||||
"focus": "#155EEF",
|
||||
"success": "#1E6F50",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#8A5700",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#B42318",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Let warm neutrals carry most of the canvas. Reserve green for the primary action and current-state reassurance; keep coral below ten percent.",
|
||||
"assetBrief": { "anchors": ["#F3F0E8", "#276B5E", "#D56A45"], "avoid": ["neon blue", "rainbow gradients", "blue-purple AI glow"] }
|
||||
},
|
||||
{
|
||||
"id": "deep-lime-studio",
|
||||
"name": "Deep lime studio",
|
||||
"mode": "dark",
|
||||
"bestFor": "Creative work, focused productivity, and high-craft prototypes",
|
||||
"recipeBias": ["creative-professional", "expressive-brand"],
|
||||
"roles": {
|
||||
"background": "#0B0D0F",
|
||||
"surface": "#15191D",
|
||||
"chrome": "#262C31",
|
||||
"foreground": "#F5F4ED",
|
||||
"mutedForeground": "#A8AFAB",
|
||||
"chromeForeground": "#F5F4ED",
|
||||
"border": "#465057",
|
||||
"primary": "#B8FF5A",
|
||||
"primaryForeground": "#10140C",
|
||||
"accent": "#7AA7FF",
|
||||
"accentForeground": "#0B1020",
|
||||
"focus": "#B8FF5A",
|
||||
"success": "#75E6A4",
|
||||
"successForeground": "#0B1A10",
|
||||
"warning": "#FFC857",
|
||||
"warningForeground": "#1B1300",
|
||||
"danger": "#FF766E",
|
||||
"dangerForeground": "#200704"
|
||||
},
|
||||
"usage": "Use lime for selection and one decisive action, never as body text. Layer chrome one step lighter than the canvas; let generated imagery remain low-luminance.",
|
||||
"assetBrief": { "anchors": ["#0B0D0F", "#B8FF5A", "#7AA7FF"], "avoid": ["pure-white bloom", "multicolor neon", "lime on light backgrounds"] }
|
||||
},
|
||||
{
|
||||
"id": "cobalt-instrument",
|
||||
"name": "Cobalt instrument",
|
||||
"mode": "light",
|
||||
"bestFor": "Developer platforms, data products, and operational workbenches",
|
||||
"recipeBias": ["developer-platform", "enterprise-workbench"],
|
||||
"roles": {
|
||||
"background": "#F1F5FA",
|
||||
"surface": "#FFFFFF",
|
||||
"chrome": "#101828",
|
||||
"foreground": "#101828",
|
||||
"mutedForeground": "#475467",
|
||||
"chromeForeground": "#F9FAFB",
|
||||
"border": "#C7D1E0",
|
||||
"primary": "#175CD3",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#6941C6",
|
||||
"accentForeground": "#FFFFFF",
|
||||
"focus": "#175CD3",
|
||||
"success": "#067647",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#934F00",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#B42318",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Use neutral layers for evidence and cobalt for action/selection. Violet belongs to secondary categorization, not a second primary action.",
|
||||
"assetBrief": { "anchors": ["#101828", "#175CD3", "#F1F5FA"], "avoid": ["cyan terminal glow", "decorative gradients", "low-contrast gray text"] }
|
||||
},
|
||||
{
|
||||
"id": "warm-clay-commerce",
|
||||
"name": "Warm clay commerce",
|
||||
"mode": "light",
|
||||
"bestFor": "Commerce, hospitality, booking, and human service brands",
|
||||
"recipeBias": ["commerce-operator", "calm-consumer"],
|
||||
"roles": {
|
||||
"background": "#FFF8F2",
|
||||
"surface": "#FFFFFF",
|
||||
"chrome": "#2B201B",
|
||||
"foreground": "#2B201B",
|
||||
"mutedForeground": "#6B5549",
|
||||
"chromeForeground": "#FFF8F2",
|
||||
"border": "#DCCBC0",
|
||||
"primary": "#A64005",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#6441C4",
|
||||
"accentForeground": "#FFFFFF",
|
||||
"focus": "#1D5FD0",
|
||||
"success": "#187451",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#8A5700",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#B42318",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Let product imagery and warm paper carry identity. Clay marks purchase intent; violet is reserved for saved or personalized context.",
|
||||
"assetBrief": { "anchors": ["#FFF8F2", "#A64005", "#2B201B"], "avoid": ["orange sale walls", "high-saturation red urgency", "generic purple gradient"] }
|
||||
},
|
||||
{
|
||||
"id": "civic-blue",
|
||||
"name": "Civic blue",
|
||||
"mode": "light",
|
||||
"bestFor": "Public services, regulated applications, and consequential workflows",
|
||||
"recipeBias": ["public-service", "enterprise-workbench"],
|
||||
"roles": {
|
||||
"background": "#F3F5F7",
|
||||
"surface": "#FFFFFF",
|
||||
"chrome": "#003078",
|
||||
"foreground": "#0B0C0C",
|
||||
"mutedForeground": "#4C6272",
|
||||
"chromeForeground": "#FFFFFF",
|
||||
"border": "#B1B4B6",
|
||||
"primary": "#1D5F91",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#00703C",
|
||||
"accentForeground": "#FFFFFF",
|
||||
"focus": "#B45F06",
|
||||
"success": "#00703C",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#8A5700",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#B42318",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Use blue for institution and primary action, green only for confirmed success, and amber focus with a visible outline. Pair every status with text.",
|
||||
"assetBrief": { "anchors": ["#003078", "#F3F5F7", "#00703C"], "avoid": ["pastel minimalism", "glass navigation", "color-only status"] }
|
||||
},
|
||||
{
|
||||
"id": "editorial-ink",
|
||||
"name": "Editorial ink",
|
||||
"mode": "light",
|
||||
"bestFor": "Research, journalism, reports, and authoritative reading",
|
||||
"recipeBias": ["editorial-authority", "public-service"],
|
||||
"roles": {
|
||||
"background": "#F5F1E8",
|
||||
"surface": "#FFFCF6",
|
||||
"chrome": "#111111",
|
||||
"foreground": "#111111",
|
||||
"mutedForeground": "#5B564E",
|
||||
"chromeForeground": "#FFFFFF",
|
||||
"border": "#C9C0B2",
|
||||
"primary": "#8F2C21",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#1D4E9E",
|
||||
"accentForeground": "#FFFFFF",
|
||||
"focus": "#1D4E9E",
|
||||
"success": "#176B45",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#805200",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#A12B22",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Use ink and paper for the reading field. Red marks editorial emphasis sparingly; blue owns links and focus.",
|
||||
"assetBrief": { "anchors": ["#F5F1E8", "#111111", "#8F2C21"], "avoid": ["fake newspaper texture", "sepia photos", "card-grid chrome"] }
|
||||
},
|
||||
{
|
||||
"id": "signal-coral",
|
||||
"name": "Signal coral",
|
||||
"mode": "light",
|
||||
"bestFor": "Expressive launches, social products, and consumer discovery",
|
||||
"recipeBias": ["expressive-brand", "native-mobile"],
|
||||
"roles": {
|
||||
"background": "#FFF3EC",
|
||||
"surface": "#FFFFFF",
|
||||
"chrome": "#1A1423",
|
||||
"foreground": "#1A1423",
|
||||
"mutedForeground": "#645A6C",
|
||||
"chromeForeground": "#FFFFFF",
|
||||
"border": "#D8C9D0",
|
||||
"primary": "#C83D2C",
|
||||
"primaryForeground": "#FFFFFF",
|
||||
"accent": "#5B3EC8",
|
||||
"accentForeground": "#FFFFFF",
|
||||
"focus": "#5B3EC8",
|
||||
"success": "#19724E",
|
||||
"successForeground": "#FFFFFF",
|
||||
"warning": "#875400",
|
||||
"warningForeground": "#FFFFFF",
|
||||
"danger": "#A92924",
|
||||
"dangerForeground": "#FFFFFF"
|
||||
},
|
||||
"usage": "Let coral own the hook and selected moment. Violet supports spatial or media context; never let both compete as primary actions.",
|
||||
"assetBrief": { "anchors": ["#FFF3EC", "#C83D2C", "#5B3EC8"], "avoid": ["pink-purple gradient wash", "rainbow icon chips", "coral body text"] }
|
||||
},
|
||||
{
|
||||
"id": "nocturne-violet",
|
||||
"name": "Nocturne violet",
|
||||
"mode": "dark",
|
||||
"bestFor": "Media, AI, experimental professional tools, and immersive utilities",
|
||||
"recipeBias": ["creative-professional", "developer-platform"],
|
||||
"roles": {
|
||||
"background": "#0D0B16",
|
||||
"surface": "#171327",
|
||||
"chrome": "#2A2341",
|
||||
"foreground": "#F6F2FF",
|
||||
"mutedForeground": "#B3A9C9",
|
||||
"chromeForeground": "#F6F2FF",
|
||||
"border": "#554A70",
|
||||
"primary": "#A98BFF",
|
||||
"primaryForeground": "#160F28",
|
||||
"accent": "#4BE0C3",
|
||||
"accentForeground": "#06251F",
|
||||
"focus": "#D1C2FF",
|
||||
"success": "#65D6A2",
|
||||
"successForeground": "#062118",
|
||||
"warning": "#F4BF55",
|
||||
"warningForeground": "#241700",
|
||||
"danger": "#FF8078",
|
||||
"dangerForeground": "#2A0705"
|
||||
},
|
||||
"usage": "Use violet for primary control and mint for creation/progress. Keep media dark enough to preserve chrome and avoid synthetic AI-glow overload.",
|
||||
"assetBrief": { "anchors": ["#0D0B16", "#A98BFF", "#4BE0C3"], "avoid": ["electric blue haze", "purple gradient headlines", "white bloom behind text"] }
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user