From 15621441ff44ba9375d6e91a82e2a2f59a8c9885 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 11:19:04 +0000 Subject: [PATCH 01/14] fix(design-system): correct brand yellow to #f2ff59 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `--color-electric-400` held `#f0ff41`, the pre-2026 brand yellow. The Figma Design System and the live comfy.org both use `#f2ff59`, confirmed against the Brand Guidelines 2026 page. Correcting the token fixes every consumer of `brand-yellow` / `electric-400` at once, including the newly published `@comfyorg/design-system` package. Audit of hardcoded copies of the same color: - apps/website hand-copied `#f2ff59` into `--color-primary-comfy-yellow`; it now aliases `--color-brand-yellow`, so the site follows the package instead of holding its own copy. - The cloud onboarding views carried `#f0ff41` in `:deep(.p-checkbox-checked .p-checkbox-box)` rules. Neither view — nor anything in their subtrees — renders a PrimeVue Checkbox, and none ever did; the rules arrived wholesale in #6564. Removed as dead CSS rather than updated. - `comfy-cloud-logo.svg` and `comfy-brand-mark.svg` still filled with the old yellow, while `comfy-logo-single.svg` beside them already used the new one. Standalone assets can't read a CSS token, so the value is corrected in place. - The LogoComfyWaveLoader brand story labelled its swatches with literal hexes, one of them stale. Labels now name the tokens. AGENTS.md gains a matching rule so new code reaches for the token. --- AGENTS.md | 4 ++++ apps/website/src/styles/global.css | 2 +- packages/design-system/src/css/_palette.css | 2 +- public/assets/images/comfy-cloud-logo.svg | 4 ++-- src/components/loader/LogoComfyWaveLoader.stories.ts | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 333ada868eb..0415c798826 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -254,6 +254,10 @@ When working from a TDD or design doc, record its tradeoffs, alternatives consid - NEVER use the `dark:` tailwind variant - Instead use a semantic value from the `style.css` theme - e.g. `bg-node-component-surface` +- NEVER hardcode a brand color hex value + - `packages/design-system` is the single source of truth, published as `@comfyorg/design-system` and consumed by downstream apps + - Use the token — `bg-brand-yellow` in a class, `var(--color-brand-yellow)` in CSS + - A copied hex silently drifts when the design system changes; brand yellow was already stale by one revision (`#f0ff41` vs `#f2ff59`) before this rule existed - NEVER use `:class="[]"` to merge class names - Always use `import { cn } from '@comfyorg/tailwind-utils'` - e.g. `
` diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index c0b51ac5c2c..aa75141653a 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -74,7 +74,7 @@ var(--color-primary-comfy-ink) 88%, black 12% ); - --color-primary-comfy-yellow: #f2ff59; + --color-primary-comfy-yellow: var(--color-brand-yellow); --color-primary-comfy-orange: #fabc25; --color-primary-comfy-ink: #211927; --color-primary-comfy-ink-light: #2a2330; diff --git a/packages/design-system/src/css/_palette.css b/packages/design-system/src/css/_palette.css index 0974d7baa72..12844c22564 100644 --- a/packages/design-system/src/css/_palette.css +++ b/packages/design-system/src/css/_palette.css @@ -55,7 +55,7 @@ --color-black: #000000; /* Brand Colors */ - --color-electric-400: #f0ff41; + --color-electric-400: #f2ff59; --color-sapphire-700: #172dd7; --color-brand-yellow: var(--color-electric-400); --color-brand-blue: var(--color-sapphire-700); diff --git a/public/assets/images/comfy-cloud-logo.svg b/public/assets/images/comfy-cloud-logo.svg index 4a701878c5f..ddde65b4139 100644 --- a/public/assets/images/comfy-cloud-logo.svg +++ b/public/assets/images/comfy-cloud-logo.svg @@ -1,4 +1,4 @@ - - + + diff --git a/src/components/loader/LogoComfyWaveLoader.stories.ts b/src/components/loader/LogoComfyWaveLoader.stories.ts index 7057b1a12eb..46370e1a1b1 100644 --- a/src/components/loader/LogoComfyWaveLoader.stories.ts +++ b/src/components/loader/LogoComfyWaveLoader.stories.ts @@ -59,11 +59,11 @@ export const BrandColors: Story = { template: `
- #F0FF41 (Yellow) + electric-400 (Yellow)
- #172DD7 (Blue) + sapphire-700 (Blue)
From 3c3098019448b19fdc04e4e478a03623e02c325c Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 12:22:31 +0000 Subject: [PATCH 02/14] refactor: consume design-system tokens instead of matching their values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to the brand-yellow correction. Matching a token's value is not enough — a literal that merely equals the token today drifts the day the token changes, invisibly. These call sites now read the value from @comfyorg/design-system rather than restating it. Design system: --color-primary-comfy-ink and --color-primary-comfy-canvas moved from style.css into _palette.css. They are brand colours, but they only shipped through style.css, which carries the PrimeVue and node-editor theme. base.css — the entry point marketing sites are told to import — did not expose them, so apps/website had no way to reference them and had hand-copied both. The package now serves the consumer it documents. apps/website: - global.css stops redeclaring comfy-ink/comfy-canvas and inherits them, aliases comfy-plum to plum-600, and derives transparency-ink-t80 from the ink token instead of a pre-mixed rgb(). This is the leveraged fix: every bg-/text-/fill-primary-comfy-* utility across the site now resolves through the package. - 96 illustration fills across four product heroes, OrchestrationSection and 404 became fill-*/stroke-* utilities. OrchestrationSection tiles are keyed by tone rather than by hex, since the hex doubled as a glow-map key. Its glow values stay literal on purpose — they are brighter than the fills, so deriving them from the tokens would change the visuals. - Canvas and three.js need a concrete string, so useHeroLogo, api/HeroSection and BrandBackground read the token at runtime via a new readDesignToken helper; snakeGame drops its literal fallbacks. - Gradient stop-colors and the Hubspot style map use var() directly. Frontend src/: charcoal-500 input surfaces in cloud onboarding, azure-600 on the subscribe button (its --color-accent-blue fallback never resolved — that token does not exist), --font-inter in WhatsNewPopup, and token-valued fallbacks in useChart in place of #ffffff/#8a8a8a. Three literals stay, deliberately. brandColors.ts is copyable text and the theme-color meta is parsed by the browser, so neither can hold a var(); brandColors.test.ts pins both, plus the standalone brand SVGs, to the token values so CI catches the drift instead. The minimap's #d9d9d9 is left alone: it coincidentally equals smoke-400 but is not a brand colour, and coupling it would change the minimap on the next brand tweak. Verified pixel-identical: token-colour pixel counts across nine pages are unchanged (ratios 0.986-1.002, within animation noise measured by an after-vs-after control). --- AGENTS.md | 18 +++- .../components/common/HubspotFormEmbed.vue | 26 ++--- .../components/product/cloud/HeroSection.vue | 68 ++++++------- .../components/product/local/HeroSection.vue | 18 ++-- apps/website/src/composables/useHeroLogo.ts | 6 +- apps/website/src/data/brandColors.test.ts | 97 +++++++++++++++++++ apps/website/src/pages/404.astro | 14 +-- apps/website/src/scripts/snakeGame.ts | 13 ++- apps/website/src/styles/global.css | 9 +- .../src/templates/brand/BrandBackground.vue | 5 +- .../src/templates/drops/LaunchesHeroLogo.vue | 5 +- apps/website/src/utils/designTokens.ts | 43 ++++++++ packages/design-system/src/css/_palette.css | 2 + packages/design-system/src/css/style.css | 2 - src/components/ui/chart/useChart.ts | 13 ++- .../SubscriptionRequiredDialogContent.vue | 2 +- .../updates/components/WhatsNewPopup.vue | 12 +-- 17 files changed, 248 insertions(+), 105 deletions(-) create mode 100644 apps/website/src/data/brandColors.test.ts create mode 100644 apps/website/src/utils/designTokens.ts diff --git a/AGENTS.md b/AGENTS.md index 0415c798826..334929fa3d1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -254,10 +254,22 @@ When working from a TDD or design doc, record its tradeoffs, alternatives consid - NEVER use the `dark:` tailwind variant - Instead use a semantic value from the `style.css` theme - e.g. `bg-node-component-surface` -- NEVER hardcode a brand color hex value +- NEVER write out a design-system value — consume the token - `packages/design-system` is the single source of truth, published as `@comfyorg/design-system` and consumed by downstream apps - - Use the token — `bg-brand-yellow` in a class, `var(--color-brand-yellow)` in CSS - - A copied hex silently drifts when the design system changes; brand yellow was already stale by one revision (`#f0ff41` vs `#f2ff59`) before this rule existed + - Applies to every token it ships: colors, fonts, icons, spacing, radii, shadows, text sizes + - Matching the value is not enough. A literal that merely equals the token today still drifts the day the token changes, and it is invisible when it does. What matters is that the value is _read_ from the package, not that it happens to agree with it + - How to consume it, by context: + - Tailwind class — `bg-brand-yellow`, `fill-primary-comfy-ink`, `font-inter` + - CSS, including `style` attributes and inline SVG — `var(--color-brand-yellow)` + - Deriving a variant — `rgb(from var(--color-primary-comfy-ink) r g b / 0.8)`, never a pre-mixed literal + - Canvas / WebGL / any API needing a concrete string — read it at runtime, e.g. `readDesignToken('--color-primary-comfy-yellow')` in `apps/website` + - A token-valued fallback beats a literal one — `getCssVar('--color-muted-foreground') || getCssVar('--color-smoke-800')` + - NEVER use `fill="var(--token)"` as an SVG presentation attribute. Substitution functions there were only resolved into SVG2 in Nov 2025 and Chromium support is uneven — use a `fill-*` utility class or a `style="fill: var(...)"` declaration + - Two things this rule does NOT mean: + - A value that coincidentally equals a token is not a token usage. `#d9d9d9` as a minimap node fill is not `smoke-400`; rewriting it would couple unrelated UI to the brand and change it on the next brand tweak + - Where a literal is unavoidable — a ``, a copyable hex on the brand page, a standalone `.svg` fetched as an image — pin it with a test instead, as `apps/website/src/data/brandColors.test.ts` does + - If the token you need is missing from the entry point you import, add it to the design system rather than copying the value. `base.css` is the marketing-site entry point and deliberately excludes the PrimeVue and node-editor theme + - Brand yellow was stale by a full revision (`#f0ff41` vs `#f2ff59`) purely because copies existed - NEVER use `:class="[]"` to merge class names - Always use `import { cn } from '@comfyorg/tailwind-utils'` - e.g. `
` diff --git a/apps/website/src/components/common/HubspotFormEmbed.vue b/apps/website/src/components/common/HubspotFormEmbed.vue index f1c7891d3f6..61c06d8d4d0 100644 --- a/apps/website/src/components/common/HubspotFormEmbed.vue +++ b/apps/website/src/components/common/HubspotFormEmbed.vue @@ -19,29 +19,29 @@ const hasEmbedLoadError = ref(false) const hubspotFormStyles: Record<`--${string}`, string> = { '--hsf-global__font-family': "'PP Formula', sans-serif", - '--hsf-global__color': '#c2bfb9', - '--hsf-background__background-color': '#211927', + '--hsf-global__color': 'var(--color-primary-comfy-canvas)', + '--hsf-background__background-color': 'var(--color-primary-comfy-ink)', '--hsf-background__border-width': '0', '--hsf-background__padding': '0', '--hsf-button__font-family': "'PP Formula', sans-serif", '--hsf-button__font-size': '14px', - '--hsf-button__color': '#211927', - '--hsf-button__background-color': '#f2ff59', + '--hsf-button__color': 'var(--color-primary-comfy-ink)', + '--hsf-button__background-color': 'var(--color-primary-comfy-yellow)', '--hsf-button__border-radius': '16px', '--hsf-button__padding': '10px 24px', '--hsf-richtext__font-family': "'PP Formula', sans-serif", - '--hsf-richtext__color': '#c2bfb9', + '--hsf-richtext__color': 'var(--color-primary-comfy-canvas)', '--hsf-heading__font-family': "'PP Formula', sans-serif", - '--hsf-heading__color': '#c2bfb9', + '--hsf-heading__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-label__font-family': "'PP Formula', sans-serif", '--hsf-field-label__font-size': '12px', - '--hsf-field-label__color': '#c2bfb9', + '--hsf-field-label__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-description__font-family': "'PP Formula', sans-serif", - '--hsf-field-description__color': '#c2bfb9', + '--hsf-field-description__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-footer__font-family': "'PP Formula', sans-serif", - '--hsf-field-footer__color': '#c2bfb9', + '--hsf-field-footer__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-input__font-family': "'PP Formula', sans-serif", - '--hsf-field-input__color': '#c2bfb9', + '--hsf-field-input__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-input__background-color': '#2a2230', '--hsf-field-input__placeholder-color': '#585159', '--hsf-field-input__border-color': '#3b3539', @@ -50,7 +50,7 @@ const hubspotFormStyles: Record<`--${string}`, string> = { '--hsf-field-input__border-radius': '16px', '--hsf-field-input__padding': '16px', '--hsf-field-textarea__font-family': "'PP Formula', sans-serif", - '--hsf-field-textarea__color': '#c2bfb9', + '--hsf-field-textarea__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-textarea__background-color': '#2a2230', '--hsf-field-textarea__placeholder-color': '#585159', '--hsf-field-textarea__border-color': '#3b3539', @@ -58,12 +58,12 @@ const hubspotFormStyles: Record<`--${string}`, string> = { '--hsf-field-textarea__border-style': 'solid', '--hsf-field-textarea__border-radius': '16px', '--hsf-field-textarea__padding': '16px', - '--hsf-field-checkbox__color': '#c2bfb9', + '--hsf-field-checkbox__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-checkbox__background-color': '#2a2230', '--hsf-field-checkbox__border-color': '#464147', '--hsf-field-checkbox__border-width': '1px', '--hsf-field-checkbox__border-style': 'solid', - '--hsf-field-radio__color': '#c2bfb9', + '--hsf-field-radio__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-radio__background-color': '#2a2230', '--hsf-field-radio__border-color': '#464147', '--hsf-field-radio__border-width': '1px', diff --git a/apps/website/src/components/product/cloud/HeroSection.vue b/apps/website/src/components/product/cloud/HeroSection.vue index 1426cfa3789..151d68e182d 100644 --- a/apps/website/src/components/product/cloud/HeroSection.vue +++ b/apps/website/src/components/product/cloud/HeroSection.vue @@ -29,55 +29,51 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="510.823" rx="81.9867" transform="matrix(-0.866025 0.5 -0.866025 -0.5 924.132 890.858)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -90,55 +86,51 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="432.47" rx="48.7555" transform="matrix(-0.866025 0.5 0 1 387.119 24.7041)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -151,55 +143,51 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="432.47" rx="48.7555" transform="matrix(0.866025 0.5 0 1 578.635 23.4051)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -209,7 +197,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -217,19 +205,19 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -238,7 +226,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -246,7 +234,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -260,7 +248,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() /> @@ -290,7 +278,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="326.373" rx="52.0171" transform="matrix(-0.866025 0.5 -0.866025 -0.5 764.39 519.23)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -300,7 +288,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -314,13 +302,13 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() /> @@ -337,7 +325,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -351,7 +339,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() /> diff --git a/apps/website/src/components/product/local/HeroSection.vue b/apps/website/src/components/product/local/HeroSection.vue index ea552f71c88..a40f6fd4d74 100644 --- a/apps/website/src/components/product/local/HeroSection.vue +++ b/apps/website/src/components/product/local/HeroSection.vue @@ -187,7 +187,7 @@ onUnmounted(() => { height="491.852" rx="65.5036" transform="matrix(-0.866025 -0.5 0 -1 620.969 1058.01)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" visibility="hidden" @@ -200,7 +200,7 @@ onUnmounted(() => { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -212,7 +212,7 @@ onUnmounted(() => { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -224,7 +224,7 @@ onUnmounted(() => { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - fill="#211927" + class="fill-primary-comfy-ink" stroke="#4D3762" stroke-width="3" /> @@ -234,7 +234,7 @@ onUnmounted(() => { { { { diff --git a/apps/website/src/composables/useHeroLogo.ts b/apps/website/src/composables/useHeroLogo.ts index 6ed12fb04c2..3fa35e6fa92 100644 --- a/apps/website/src/composables/useHeroLogo.ts +++ b/apps/website/src/composables/useHeroLogo.ts @@ -4,6 +4,7 @@ import { onMounted, onUnmounted, ref } from 'vue' import * as THREE from 'three' import { SVGLoader } from 'three/addons/loaders/SVGLoader.js' +import { readDesignToken } from '../utils/designTokens' import { prefersReducedMotion } from './useReducedMotion' const IMAGE_COUNT = 16 @@ -17,7 +18,7 @@ interface HeroLogoConfig { tiltZ: number zoom: number fov: number - logoColor: string + logoColor?: string extrudeDepth: number cursorTiltStrength: number bgScale: number @@ -36,7 +37,6 @@ const DEFAULTS: HeroLogoConfig = { tiltZ: -0.1, zoom: 7, fov: 50, - logoColor: '#F2FF59', extrudeDepth: 200, cursorTiltStrength: 0.5, bgScale: 0.8, @@ -207,7 +207,7 @@ export function useHeroLogo( shapeGeo.translate(-cx, -cy, 0) shapeGeo.scale(s, -s, s) const shapeMat = new THREE.MeshBasicMaterial({ - color: cfg.logoColor, + color: cfg.logoColor ?? readDesignToken('--color-primary-comfy-yellow'), side: THREE.DoubleSide, depthTest: false, depthWrite: false, diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts new file mode 100644 index 00000000000..c7ea111cbea --- /dev/null +++ b/apps/website/src/data/brandColors.test.ts @@ -0,0 +1,97 @@ +import { readFileSync } from 'node:fs' +import { createRequire } from 'node:module' +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' + +import { brandColors } from './brandColors' + +const require = createRequire(import.meta.url) +const paletteCss = readFileSync( + require.resolve('@comfyorg/design-system/css/_palette.css'), + 'utf-8' +) + +function token(name: string): string { + const match = new RegExp(`--${name}:\\s*(#[0-9a-fA-F]{6})\\s*;`).exec( + paletteCss + ) + if (!match) throw new Error(`token --${name} not found in the design system`) + return match[1].toLowerCase() +} + +const websiteRoot = join(import.meta.dirname, '..', '..') +const read = (relative: string) => + readFileSync(join(websiteRoot, relative), 'utf-8') + +/* + * Everything asserted here is a place a design-system colour has to be written + * out as a literal, because the consumer cannot read a CSS custom property: + * a data table rendered as copyable text, a value the browser parses + * itself, and standalone SVGs fetched as images. Since they cannot reference + * the token, these tests are what stops them drifting from it. + */ +describe('brand colours that cannot reference a token', () => { + it('the /brand palette table matches the design system', () => { + const expected: Record = { + 'Comfy Yellow': token('color-electric-400'), + 'Comfy Ink': token('color-primary-comfy-ink'), + 'Comfy Canvas': token('color-primary-comfy-canvas'), + 'Comfy Plum': token('color-plum-600') + } + + for (const [name, hex] of Object.entries(expected)) { + const entry = brandColors.find((c) => c.name === name) + expect(entry, `${name} missing from brandColors`).toBeDefined() + expect(entry!.hex.toLowerCase(), `${name} hex`).toBe(hex) + } + }) + + it('the /brand palette table rgb values agree with its own hex values', () => { + for (const colour of brandColors) { + const hex = colour.hex.replace('#', '') + const fromHex = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16)) + const declared = colour.rgb.split(',').map((n) => Number(n.trim())) + expect(declared, `${colour.name} rgb`).toEqual(fromHex) + } + }) + + it('the theme-color meta tag matches comfy-ink', () => { + const html = read('src/layouts/BaseLayout.astro') + const meta = /name="theme-color"\s+content="(#[0-9a-fA-F]{6})"/.exec(html) + expect(meta, 'theme-color meta tag not found').not.toBeNull() + expect(meta![1].toLowerCase()).toBe(token('color-primary-comfy-ink')) + }) + + it('standalone brand SVGs use the brand yellow', () => { + const yellow = token('color-electric-400') + const files = [ + 'public/favicon.svg', + 'public/icons/logo.svg', + 'public/icons/logomark.svg', + 'public/icons/comfyicon.svg', + 'public/affiliates/brand/comfy-full-logo-yellow.svg', + 'public/affiliates/brand/comfy-color-combo-yellow.svg', + 'public/affiliates/brand/comfy-amplified-logo-mark.svg' + ] + + for (const file of files) { + const svg = read(file).toLowerCase() + expect(svg, `${file} should use ${yellow}`).toContain(yellow) + } + }) + + it('standalone brand SVGs use comfy-ink where they are two-tone', () => { + const ink = token('color-primary-comfy-ink') + const files = [ + 'public/favicon.svg', + 'public/icons/comfyicon.svg', + 'public/affiliates/brand/comfy-color-combo-ink.svg', + 'public/affiliates/brand/comfy-full-logo-ink.svg' + ] + + for (const file of files) { + const svg = read(file).toLowerCase() + expect(svg, `${file} should use ${ink}`).toContain(ink) + } + }) +}) diff --git a/apps/website/src/pages/404.astro b/apps/website/src/pages/404.astro index 9fff35c63c6..5ef67ebb82a 100644 --- a/apps/website/src/pages/404.astro +++ b/apps/website/src/pages/404.astro @@ -15,13 +15,13 @@ import BaseLayout from '../layouts/BaseLayout.astro' xmlns="http://www.w3.org/2000/svg" aria-label="404 Page Not Found" class="block h-auto w-full"> - - - - - - - + + + + + + +

diff --git a/apps/website/src/scripts/snakeGame.ts b/apps/website/src/scripts/snakeGame.ts index 224d0fe046d..75f24c500e7 100644 --- a/apps/website/src/scripts/snakeGame.ts +++ b/apps/website/src/scripts/snakeGame.ts @@ -35,15 +35,14 @@ const TICK_MS = 200 function readColors() { const style = getComputedStyle(document.documentElement) - const get = (name: string, fallback: string): string => - style.getPropertyValue(name).trim() || fallback + const get = (name: string): string => style.getPropertyValue(name).trim() return { - bg: get('--color-primary-comfy-ink', '#211927'), - fieldStroke: get('--color-secondary-mauve', '#4D3762'), - snakeA: get('--color-primary-comfy-plum', '#49378B'), - snakeB: get('--color-secondary-mauve', '#4D3762'), - accent: get('--color-primary-comfy-yellow', '#F2FF59') + bg: get('--color-primary-comfy-ink'), + fieldStroke: get('--color-secondary-mauve'), + snakeA: get('--color-primary-comfy-plum'), + snakeB: get('--color-secondary-mauve'), + accent: get('--color-primary-comfy-yellow') } } diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index aa75141653a..6a06750116a 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -74,25 +74,26 @@ var(--color-primary-comfy-ink) 88%, black 12% ); + /* comfy-ink and comfy-canvas are provided by base.css — never redeclare them */ --color-primary-comfy-yellow: var(--color-brand-yellow); --color-primary-comfy-orange: #fabc25; - --color-primary-comfy-ink: #211927; --color-primary-comfy-ink-light: #2a2330; - --color-primary-comfy-canvas: #c2bfb9; --color-primary-warm-white: #f0efed; --color-primary-warm-gray: #7e7c78; --color-secondary-mauve: #4d3762; --color-destructive: #f44336; /* Legible on the dark ink surfaces; --color-destructive is too dark there. */ --color-destructive-light: #ffb4a8; - --color-primary-comfy-plum: #49378b; + --color-primary-comfy-plum: var(--color-plum-600); --color-secondary-deep-plum: #2b2040; --color-secondary-cool-gray: #3c3c3c; --color-illustration-forest: #20464c; --color-transparency-white-t4: rgb(255 255 255 / 0.04); --color-transparency-white-t8: rgb(255 255 255 / 0.08); --color-transparency-white-t20: rgb(255 255 255 / 0.2); - --color-transparency-ink-t80: rgb(33 25 39 / 0.8); + --color-transparency-ink-t80: rgb( + from var(--color-primary-comfy-ink) r g b / 0.8 + ); --font-formula: 'PP Formula', sans-serif; --font-formula-narrow: 'PP Formula Narrow', sans-serif; --text-2xs: 0.6875rem; diff --git a/apps/website/src/templates/brand/BrandBackground.vue b/apps/website/src/templates/brand/BrandBackground.vue index 94b63a162b0..f851abc112d 100644 --- a/apps/website/src/templates/brand/BrandBackground.vue +++ b/apps/website/src/templates/brand/BrandBackground.vue @@ -7,6 +7,7 @@ import { import { onMounted, ref } from 'vue' import { prefersReducedMotion } from '../../composables/useReducedMotion' +import { readDesignTokenRgba } from '../../utils/designTokens' interface Node { x: number @@ -43,7 +44,7 @@ function draw() { if (n.y < 0 || n.y > 1) n.vy *= -1 } - ctx.strokeStyle = 'rgba(242, 255, 89, 0.18)' + ctx.strokeStyle = readDesignTokenRgba('--color-primary-comfy-yellow', 0.18) ctx.lineWidth = dpr const max = Math.min(w, h) * 0.22 for (let i = 0; i < nodes.length; i++) { @@ -65,7 +66,7 @@ function draw() { } ctx.globalAlpha = 1 - ctx.fillStyle = 'rgba(242, 255, 89, 0.9)' + ctx.fillStyle = readDesignTokenRgba('--color-primary-comfy-yellow', 0.9) for (const n of nodes) { ctx.beginPath() ctx.arc(n.x * w, n.y * h, 2.5 * dpr, 0, Math.PI * 2) diff --git a/apps/website/src/templates/drops/LaunchesHeroLogo.vue b/apps/website/src/templates/drops/LaunchesHeroLogo.vue index 86c461119f3..0fae458d5be 100644 --- a/apps/website/src/templates/drops/LaunchesHeroLogo.vue +++ b/apps/website/src/templates/drops/LaunchesHeroLogo.vue @@ -9,8 +9,7 @@ const { label } = defineProps<{ label: string }>() const WORDMARK_VIEWBOX = '0 0 173 48' const WORDMARK_PATH = 'M170.474 8.75283C170.474 8.75283 167.118 8.75283 164.685 8.75283C162.252 8.75283 160.206 10.3959 159.582 12.6326L156.526 23.2971C156.401 23.7157 156.008 24.0219 155.553 24.0219H154.474C153.912 24.0219 153.457 23.5658 153.457 23.0035C153.457 22.9036 153.469 22.8098 153.501 22.7161L156.563 12.0141C156.626 11.7891 156.663 11.558 156.663 11.3143C156.663 9.90238 155.522 8.75908 154.112 8.75908H148.354C145.922 8.75908 143.869 10.4084 143.252 12.6513L140.351 22.7911C140.226 23.2097 139.84 23.5221 139.378 23.5221H138.268C137.706 23.5221 137.251 23.066 137.251 22.5037C137.251 22.4037 137.263 22.31 137.288 22.2226L137.731 20.6794C137.787 20.4733 137.812 20.2546 137.812 20.0297C137.812 18.6177 136.671 17.4744 135.261 17.4744H131.849C131.288 17.4744 130.832 17.0183 130.832 16.4561C130.832 16.3624 130.845 16.2686 130.87 16.1812L131.512 13.9383C131.649 13.4697 132.08 13.1324 132.591 13.1324H135.904C138.318 13.1324 140.351 11.5143 140.994 9.30886L142.715 3.30496C142.778 3.08004 142.815 2.84264 142.815 2.59898C142.815 1.18704 141.674 0.0437327 140.264 0.0437327H134.581C132.167 0.0437327 130.134 1.66185 129.491 3.87348L128.325 7.94689C128.194 8.42171 127.757 8.76532 127.246 8.76532H123.858C121.432 8.76532 119.392 10.3959 118.762 12.6263L115.855 22.7786C115.737 23.2097 115.344 23.5283 114.876 23.5283H113.766C113.204 23.5283 112.749 23.0722 112.749 22.51C112.749 22.4162 112.761 22.3225 112.786 22.2351L113.229 20.6982C113.285 20.4857 113.316 20.2671 113.316 20.0359C113.316 18.624 112.175 17.4807 110.765 17.4807H107.378C106.817 17.4807 106.361 17.0246 106.361 16.4623C106.361 16.3561 106.374 16.2561 106.405 16.1624L107.584 12.0328C107.646 11.8079 107.684 11.5705 107.684 11.3268C107.684 9.91487 106.542 8.77157 105.132 8.77157H99.3749C96.9546 8.77157 94.9148 10.3959 94.2848 12.6138L93.1059 16.7372C92.9874 17.1683 92.5944 17.4807 92.1265 17.4807H90.9975C90.4361 17.4807 89.9807 17.0246 89.9807 16.4623C89.9807 16.3686 89.9932 16.2749 90.0181 16.1874L91.1971 12.064C91.2657 11.8329 91.3031 11.5892 91.3031 11.3331C91.3031 9.92112 90.1616 8.77782 88.7519 8.77782H74.8165C72.3838 8.77782 70.3378 10.4209 69.714 12.6576L64.312 31.5127C64.1935 31.9438 63.8005 32.2686 63.3265 32.2686H62.2099C61.6485 32.2686 61.1931 31.8126 61.1931 31.2503C61.1931 31.1628 61.2056 31.0754 61.2243 30.9941L64.1499 20.7669C64.2185 20.5357 64.2559 20.2921 64.2559 20.0422C64.2559 18.6302 63.1144 17.4869 61.7046 17.4869H58.2551C57.6937 17.4869 57.2383 17.0308 57.2383 16.4686C57.2383 16.3749 57.2508 16.2811 57.2758 16.1874L58.4485 12.0828C58.5233 11.8454 58.5608 11.5955 58.5608 11.3331C58.5608 9.92112 57.4192 8.77782 56.0095 8.77782H50.2457C47.8379 8.77782 45.8044 10.3897 45.1619 12.5951L44.0017 16.6435C43.8769 17.1246 43.4403 17.4807 42.9163 17.4807H39.5416C37.1089 17.4807 35.0628 19.1238 34.4391 21.3604L31.5322 31.5189C31.4137 31.95 31.0207 32.2624 30.5529 32.2624H29.5548C28.9934 32.2624 28.5381 31.8063 28.5381 31.244C28.5381 31.1503 28.5506 31.0566 28.5755 30.9629L28.9934 29.4947C29.0621 29.2636 29.0995 29.0199 29.0995 28.7638C29.0995 27.3456 27.9517 26.196 26.5357 26.196H15.0456C14.4281 26.2023 13.9228 25.7025 13.9228 25.084C13.9228 24.9715 13.9416 24.8653 13.9665 24.7653L17.0605 13.9695C17.1915 13.4947 17.6281 13.1449 18.1396 13.1449L29.6734 13.1324C32.1061 13.1324 34.1584 11.4893 34.7759 9.24639L36.51 3.22999C36.5662 3.01757 36.5974 2.78641 36.5974 2.55525C36.5974 1.1433 35.4558 0 34.0461 0H20.0921C17.6718 0 15.6258 1.63061 14.9957 3.8485L13.823 7.95314C13.6858 8.42171 13.2554 8.76532 12.7439 8.76532H9.39417C6.99261 8.76532 4.96531 10.3647 4.31658 12.5576L0.0935684 27.3081C0.0311901 27.5267 0 27.7642 0 28.0016C0 29.4198 1.14776 30.5693 2.56375 30.5693H5.85732C6.47487 30.5693 6.98013 31.0691 6.98013 31.6939C6.98013 31.8001 6.96766 31.9063 6.93647 32.0062L5.76999 36.0734C5.71385 36.2921 5.67642 36.517 5.67642 36.7481C5.67642 38.1601 6.81795 39.3034 8.2277 39.3034L22.188 39.2909C24.6145 39.2909 26.6605 37.654 27.2843 35.4237L27.6835 34.018C27.802 33.5869 28.195 33.2683 28.6628 33.2683H29.6609C30.2223 33.2683 30.6777 33.7243 30.6777 34.2866C30.6777 34.3866 30.6652 34.4803 30.634 34.574L30.2098 36.0484C30.1474 36.2671 30.1163 36.492 30.1163 36.7294C30.1163 38.1413 31.2578 39.2846 32.6675 39.2846H36.1358C36.6972 39.2846 37.1525 39.7407 37.1525 40.303C37.1525 40.403 37.14 40.4967 37.1089 40.5904L35.9112 44.7638C35.8488 44.9824 35.8176 45.2073 35.8176 45.4447C35.8176 46.8567 36.9591 48 38.3689 48H44.1327C46.5467 48 48.5802 46.3819 49.2227 44.1702L50.383 40.1156C50.5077 39.6345 50.9444 39.2846 51.4683 39.2846H54.8181C57.2259 39.2846 59.2656 37.6728 59.9019 35.4674L60.3136 34.0242C60.4321 33.5869 60.8251 33.2683 61.2992 33.2683H62.4157C62.9771 33.2683 63.4325 33.7243 63.4325 34.2866C63.4325 34.3803 63.42 34.474 63.3951 34.5615L62.9771 36.0109C62.9148 36.2358 62.8773 36.4732 62.8773 36.7169C62.8773 38.1288 64.0189 39.2722 65.4286 39.2722H71.1549C73.569 39.2784 75.6025 37.6665 76.245 35.4549L79.9253 22.5912C80.0501 22.1663 80.4368 21.854 80.9047 21.854H81.9838C82.5452 21.854 83.0006 22.31 83.0006 22.8723C83.0006 22.9723 82.9881 23.066 82.9632 23.1597L79.2766 36.0359C79.2142 36.2546 79.183 36.4857 79.183 36.7232C79.183 38.1351 80.3245 39.2784 81.7343 39.2784H87.5043C89.9121 39.2784 91.9394 37.6728 92.5881 35.4736L96.2747 22.5912C96.3932 22.1663 96.7862 21.8477 97.254 21.8477H98.3456C98.907 21.8477 99.3624 22.3038 99.3624 22.8661C99.3624 22.966 99.3499 23.0597 99.325 23.1472L95.6446 36.0047C95.5823 36.2296 95.5449 36.467 95.5449 36.7169C95.5449 38.1288 96.6864 39.2722 98.0961 39.2722H103.866C106.286 39.2722 108.326 37.6478 108.956 35.4299L111.869 25.2651C111.994 24.8403 112.381 24.5342 112.849 24.5342H113.959C114.52 24.5342 114.976 24.9902 114.976 25.5525C114.976 25.6525 114.963 25.7524 114.932 25.8399L109.524 44.7325C109.461 44.9512 109.43 45.1886 109.43 45.426C109.43 46.838 110.572 47.9813 111.982 47.9813H117.739C120.159 47.9813 122.205 46.3506 122.835 44.1328L126.491 31.3565C126.628 30.8879 127.058 30.5443 127.57 30.5443H130.882C133.29 30.5443 135.317 28.9387 135.966 26.7333L136.384 25.2776C136.502 24.8465 136.895 24.5279 137.363 24.5279H138.474C139.035 24.5279 139.49 24.984 139.49 25.5463C139.49 25.64 139.478 25.7274 139.453 25.8149L139.035 27.2831C138.973 27.508 138.935 27.7454 138.935 27.9891C138.935 29.401 140.077 30.5443 141.486 30.5443L153.076 30.5568C153.638 30.5568 154.093 31.0129 154.093 31.5752C154.093 31.6751 154.081 31.7751 154.049 31.8626L153.394 34.1492C153.276 34.5802 152.883 34.8926 152.415 34.8926H148.934C146.508 34.8926 144.468 36.5232 143.838 38.7474L142.135 44.7013C142.067 44.9324 142.029 45.1699 142.029 45.426C142.029 46.838 143.171 47.9813 144.58 47.9813H150.338C152.758 47.9813 154.798 46.3569 155.428 44.139L156.607 40.0281C156.719 39.5908 157.118 39.2722 157.593 39.2722H161.111C163.518 39.2722 165.546 37.6665 166.195 35.4611L172.9 12.0266C172.969 11.8016 173 11.558 173 11.3081C173 9.89613 171.858 8.75283 170.449 8.75283H170.474ZM50.2707 23.1347L47.1081 34.1804C46.9833 34.599 46.5904 34.8989 46.135 34.8989H45.0621C44.5007 34.8989 44.0453 34.4428 44.0453 33.8805C44.0453 33.793 44.0578 33.7056 44.0765 33.6244L47.2391 22.5912C47.3576 22.1601 47.7506 21.8477 48.2184 21.8477H49.2851C49.8465 21.8477 50.3019 22.3038 50.3019 22.8661C50.3019 22.9598 50.2894 23.0535 50.2644 23.141L50.2707 23.1347Z' -const LOGO_COLOR = '#F2FF59' -const WORDMARK_SVG = `` +const WORDMARK_SVG = `` const logoContainer = ref() const { loaded } = useHeroLogo(logoContainer, { @@ -49,7 +48,7 @@ const { loaded } = useHeroLogo(logoContainer, { aria-hidden="true" xmlns="http://www.w3.org/2000/svg" > - +

diff --git a/apps/website/src/utils/designTokens.ts b/apps/website/src/utils/designTokens.ts new file mode 100644 index 00000000000..1ab67982b32 --- /dev/null +++ b/apps/website/src/utils/designTokens.ts @@ -0,0 +1,43 @@ +/** + * Reads a design-system token off the document so canvas and WebGL code can use + * the same value CSS does. Both need a concrete colour string, so they cannot + * reference `var(--token)` directly the way a stylesheet can. + */ +export function readDesignToken(name: `--${string}`): string { + if (typeof document === 'undefined') return '' + return getComputedStyle(document.documentElement) + .getPropertyValue(name) + .trim() +} + +/** Same value as `rgb(from var(name) r g b / alpha)`, for canvas fill/stroke. */ +export function readDesignTokenRgba( + name: `--${string}`, + alpha: number +): string { + const rgb = parseRgb(readDesignToken(name)) + if (!rgb) return '' + return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})` +} + +function parseRgb( + color: string +): { r: number; g: number; b: number } | undefined { + const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim()) + if (hex) { + const digits = + hex[1].length === 3 ? [...hex[1]].map((c) => c + c).join('') : hex[1] + return { + r: parseInt(digits.slice(0, 2), 16), + g: parseInt(digits.slice(2, 4), 16), + b: parseInt(digits.slice(4, 6), 16) + } + } + const fn = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec( + color.trim() + ) + if (fn) { + return { r: Number(fn[1]), g: Number(fn[2]), b: Number(fn[3]) } + } + return undefined +} diff --git a/packages/design-system/src/css/_palette.css b/packages/design-system/src/css/_palette.css index 12844c22564..299ccbe99b2 100644 --- a/packages/design-system/src/css/_palette.css +++ b/packages/design-system/src/css/_palette.css @@ -57,6 +57,8 @@ /* Brand Colors */ --color-electric-400: #f2ff59; --color-sapphire-700: #172dd7; + --color-primary-comfy-ink: #211927; + --color-primary-comfy-canvas: #c2bfb9; --color-brand-yellow: var(--color-electric-400); --color-brand-blue: var(--color-sapphire-700); } diff --git a/packages/design-system/src/css/style.css b/packages/design-system/src/css/style.css index 60300b08537..1858267fc87 100644 --- a/packages/design-system/src/css/style.css +++ b/packages/design-system/src/css/style.css @@ -67,8 +67,6 @@ --color-ocean-600: #2f687a; --color-ocean-900: #253236; - --color-primary-comfy-ink: #211927; - --color-primary-comfy-canvas: #c2bfb9; --color-primary-warm-white: #f0efed; --color-primary-warm-gray: #7e7c78; diff --git a/src/components/ui/chart/useChart.ts b/src/components/ui/chart/useChart.ts index ec641cef94c..15af498af18 100644 --- a/src/components/ui/chart/useChart.ts +++ b/src/components/ui/chart/useChart.ts @@ -36,8 +36,11 @@ function getCssVar(name: string): string { } function getDefaultOptions(type: ChartType): ChartOptions { - const foreground = getCssVar('--color-base-foreground') || '#ffffff' - const muted = getCssVar('--color-muted-foreground') || '#8a8a8a' + const foreground = + getCssVar('--color-base-foreground') || getCssVar('--color-white') + const muted = + getCssVar('--color-muted-foreground') || getCssVar('--color-smoke-800') + const fontFamily = getCssVar('--font-inter') return { responsive: true, @@ -52,7 +55,7 @@ function getDefaultOptions(type: ChartType): ChartOptions { boxWidth: 8, boxHeight: 8, padding: 16, - font: { family: 'Inter', size: 11 }, + font: { family: fontFamily, size: 11 }, generateLabels(chart) { const datasets = chart.data.datasets return datasets.map((dataset, i) => { @@ -87,7 +90,7 @@ function getDefaultOptions(type: ChartType): ChartOptions { x: { ticks: { color: muted, - font: { family: 'Inter', size: 11 }, + font: { family: fontFamily, size: 11 }, padding: 8 }, grid: { @@ -100,7 +103,7 @@ function getDefaultOptions(type: ChartType): ChartOptions { y: { ticks: { color: muted, - font: { family: 'Inter', size: 11 }, + font: { family: fontFamily, size: 11 }, padding: 4 }, grid: { diff --git a/src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue b/src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue index 55136e49f88..f625a36e783 100644 --- a/src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue +++ b/src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue @@ -135,7 +135,7 @@ class="rounded-lg px-4 py-2" :pt="{ root: { - style: 'background: var(--color-accent-blue, #0B8CE9);' + style: 'background: var(--color-azure-600);' }, label: { class: 'font-inter font-[700] text-sm' diff --git a/src/platform/updates/components/WhatsNewPopup.vue b/src/platform/updates/components/WhatsNewPopup.vue index bd513670c92..3362d89117a 100644 --- a/src/platform/updates/components/WhatsNewPopup.vue +++ b/src/platform/updates/components/WhatsNewPopup.vue @@ -221,7 +221,7 @@ defineExpose({ .content-text :deep(h1) { color: var(--text-secondary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); font-size: 14px; font-weight: 400; margin-top: 1rem; @@ -235,7 +235,7 @@ defineExpose({ /* stylelint-disable-next-line selector-max-type -- generated markdown offers no class hooks */ .content-text :deep(h1 + p strong) { color: var(--text-primary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); font-size: 14px; font-weight: 600; margin: 0 0 8px; @@ -245,7 +245,7 @@ defineExpose({ /* Regular paragraphs - short description */ .content-text :deep(p) { color: var(--text-secondary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); margin: 1rem 0; } @@ -272,7 +272,7 @@ defineExpose({ position: relative; padding-left: 18px; color: var(--text-secondary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); font-size: 14px; font-weight: 400; line-height: 1.2102; @@ -296,7 +296,7 @@ defineExpose({ .content-text :deep(li strong) { color: var(--text-secondary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); font-size: 14px; font-weight: 400; line-height: 1.2102; @@ -354,7 +354,7 @@ defineExpose({ /* Secondary headings */ .content-text :deep(h3) { color: var(--text-primary); - font-family: Inter, sans-serif; + font-family: var(--font-inter); font-size: 16px; font-weight: 600; margin: 16px 0 8px; From 163ce7db0dba5eb576ce0d8c4105a1b20c17275f Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 12:35:46 +0000 Subject: [PATCH 03/14] perf(website): resolve BrandBackground token colours once at mount draw() runs on every animation frame, so reading the token there meant two getComputedStyle calls and a parse per frame. --- apps/website/src/templates/brand/BrandBackground.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/website/src/templates/brand/BrandBackground.vue b/apps/website/src/templates/brand/BrandBackground.vue index f851abc112d..30196dfbf21 100644 --- a/apps/website/src/templates/brand/BrandBackground.vue +++ b/apps/website/src/templates/brand/BrandBackground.vue @@ -29,6 +29,8 @@ const nodes: Node[] = Array.from({ length: 14 }, () => ({ })) let ctx: CanvasRenderingContext2D | null = null +let linkColor = '' +let nodeColor = '' function draw() { const el = canvasEl.value @@ -44,7 +46,7 @@ function draw() { if (n.y < 0 || n.y > 1) n.vy *= -1 } - ctx.strokeStyle = readDesignTokenRgba('--color-primary-comfy-yellow', 0.18) + ctx.strokeStyle = linkColor ctx.lineWidth = dpr const max = Math.min(w, h) * 0.22 for (let i = 0; i < nodes.length; i++) { @@ -66,7 +68,7 @@ function draw() { } ctx.globalAlpha = 1 - ctx.fillStyle = readDesignTokenRgba('--color-primary-comfy-yellow', 0.9) + ctx.fillStyle = nodeColor for (const n of nodes) { ctx.beginPath() ctx.arc(n.x * w, n.y * h, 2.5 * dpr, 0, Math.PI * 2) @@ -100,6 +102,8 @@ useEventListener('resize', resize) onMounted(() => { ctx = canvasEl.value?.getContext('2d') ?? null + linkColor = readDesignTokenRgba('--color-primary-comfy-yellow', 0.18) + nodeColor = readDesignTokenRgba('--color-primary-comfy-yellow', 0.9) resize() }) From 1717c98a78177c706364051a3c527488017b0415 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 12:53:13 +0000 Subject: [PATCH 04/14] fix: address review on the token refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three follow-ups from review. brandColors.test.ts asserted only that a brand SVG contained the current yellow, which still passes if a stale one survives on another path — exactly how #f0ff41 lingered. Generalised to assert the only yellow-family colour in the file IS the token, so any stale or near-duplicate value fails, without a denylist to maintain. Containment is implied and was dropped as redundant. global.css derived --color-transparency-white-t4 from a white literal while its sibling --color-transparency-ink-t80 three lines below derived from a token. Now reads --color-white. Renders pixel-identical: (41, 34, 47) over the ink backdrop either way, the computed form just shifts to color(srgb). Dropped !important from the three input backgrounds this branch touched. Measured it first: with the declaration demoted, the background is rgb(45, 46, 50) at rest, on hover, on focus, when filled and after blur — identical, so nothing in PrimeVue was relying on it. The remaining !important on border, box-shadow and color in those blocks predates this branch and is left alone rather than removed unverified. --- apps/website/src/data/brandColors.test.ts | 12 ++++++++++-- apps/website/src/styles/global.css | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index c7ea111cbea..1f45e0c2f14 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -23,6 +23,15 @@ const websiteRoot = join(import.meta.dirname, '..', '..') const read = (relative: string) => readFileSync(join(websiteRoot, relative), 'utf-8') +function yellowsIn(svg: string): string[] { + const hexes = svg.toLowerCase().match(/#[0-9a-f]{6}/g) ?? [] + const isYellow = (hex: string) => + parseInt(hex.slice(1, 3), 16) > 200 && + parseInt(hex.slice(3, 5), 16) > 200 && + parseInt(hex.slice(5, 7), 16) < 200 + return [...new Set(hexes.filter(isYellow))].sort() +} + /* * Everything asserted here is a place a design-system colour has to be written * out as a literal, because the consumer cannot read a CSS custom property: @@ -75,8 +84,7 @@ describe('brand colours that cannot reference a token', () => { ] for (const file of files) { - const svg = read(file).toLowerCase() - expect(svg, `${file} should use ${yellow}`).toContain(yellow) + expect(yellowsIn(read(file)), `${file} yellows`).toEqual([yellow]) } }) diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index 6a06750116a..d710fa5157a 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -88,7 +88,7 @@ --color-secondary-deep-plum: #2b2040; --color-secondary-cool-gray: #3c3c3c; --color-illustration-forest: #20464c; - --color-transparency-white-t4: rgb(255 255 255 / 0.04); + --color-transparency-white-t4: rgb(from var(--color-white) r g b / 0.04); --color-transparency-white-t8: rgb(255 255 255 / 0.08); --color-transparency-white-t20: rgb(255 255 255 / 0.2); --color-transparency-ink-t80: rgb( From 812d34e3b3bdc50c367722ceae17b794145057e5 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 13:03:22 +0000 Subject: [PATCH 05/14] test: make the brand SVG yellow check syntax-complete yellowsIn only matched six-digit hex, so a stale yellow written as #ff0, rgb(240 255 65) or #f0ff41ff was invisible to it and the assertion passed with two yellows in the file. A guard a format change can slip past is a weak guard, which matters here because these assets cannot reference the token and this test is the only thing holding them to it. Colour literals are now parsed from 3-, 4-, 6- and 8-digit hex plus rgb()/rgba(), normalised to six-digit hex before comparison. Parsing every CSS colour syntax is unbounded, so instead of attempting it the readable set is pinned: unreadableColoursIn reports any colour literal the parser does not understand, and a new test asserts brand SVGs contain none. If an export or an SVGO pass introduces hsl() or a named colour, CI says so rather than silently skipping it. The nine covered assets use only six-digit hex and `none` today, so the contract is real. Verified against a real asset by injecting each format into favicon.svg: #fd4 -> yellows [#f2ff59, #ffdd44] fails rgb(240, 255, 65) -> yellows [#f0ff41, #f2ff59] fails #f0ff41ff -> yellows [#f0ff41, #f2ff59] fails hsl(65 100% 67%) -> colour syntax [hsl(...)] fails Five unit tests cover the same cases directly. --- apps/website/src/data/brandColors.test.ts | 110 ++++++++++++++++++++-- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index 1f45e0c2f14..37d404ba150 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -23,13 +23,55 @@ const websiteRoot = join(import.meta.dirname, '..', '..') const read = (relative: string) => readFileSync(join(websiteRoot, relative), 'utf-8') +interface Rgb { + r: number + g: number + b: number +} + +const COLOUR_LITERAL = + /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|(?:ok)?l(?:ab|ch)|color|color-mix)\([^)]*\)/gi + +function parseColour(literal: string): Rgb | undefined { + const hex = /^#([0-9a-f]{3,8})$/i.exec(literal) + if (hex) { + const digits = hex[1] + const channels = + digits.length === 3 || digits.length === 4 + ? [...digits.slice(0, 3)].map((c) => c + c) + : digits.length === 6 || digits.length === 8 + ? [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 6)] + : undefined + if (!channels) return undefined + const [r, g, b] = channels.map((pair) => parseInt(pair, 16)) + return { r, g, b } + } + const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(literal) + if (rgb) return { r: +rgb[1], g: +rgb[2], b: +rgb[3] } + return undefined +} + +const toHex = ({ r, g, b }: Rgb) => + '#' + + [r, g, b].map((n) => Math.round(n).toString(16).padStart(2, '0')).join('') + +const isYellow = ({ r, g, b }: Rgb) => r > 200 && g > 200 && b < 200 + +const coloursIn = (svg: string) => svg.match(COLOUR_LITERAL) ?? [] + function yellowsIn(svg: string): string[] { - const hexes = svg.toLowerCase().match(/#[0-9a-f]{6}/g) ?? [] - const isYellow = (hex: string) => - parseInt(hex.slice(1, 3), 16) > 200 && - parseInt(hex.slice(3, 5), 16) > 200 && - parseInt(hex.slice(5, 7), 16) < 200 - return [...new Set(hexes.filter(isYellow))].sort() + const yellows = coloursIn(svg) + .map(parseColour) + .filter((colour): colour is Rgb => colour !== undefined && isYellow(colour)) + .map(toHex) + return [...new Set(yellows)].sort() +} + +function unreadableColoursIn(svg: string): string[] { + const unreadable = coloursIn(svg).filter( + (literal) => parseColour(literal) === undefined + ) + return [...new Set(unreadable.map((c) => c.toLowerCase()))].sort() } /* @@ -88,6 +130,62 @@ describe('brand colours that cannot reference a token', () => { } }) + it('every colour in a brand SVG is one the yellow check can read', () => { + const files = [ + 'public/favicon.svg', + 'public/icons/logo.svg', + 'public/icons/logomark.svg', + 'public/icons/comfyicon.svg', + 'public/affiliates/brand/comfy-full-logo-yellow.svg', + 'public/affiliates/brand/comfy-color-combo-yellow.svg', + 'public/affiliates/brand/comfy-amplified-logo-mark.svg', + 'public/affiliates/brand/comfy-color-combo-ink.svg', + 'public/affiliates/brand/comfy-full-logo-ink.svg' + ] + + for (const file of files) { + expect(unreadableColoursIn(read(file)), `${file} colour syntax`).toEqual( + [] + ) + } + }) +}) + +describe('yellowsIn', () => { + const yellow = '#f2ff59' + + it('catches a stale yellow written as shorthand hex', () => { + expect(yellowsIn(``)).toEqual([ + '#f2ff59', + '#ffff00' + ]) + }) + + it('catches a stale yellow written as rgb()', () => { + expect( + yellowsIn(``) + ).toEqual(['#f0ff41', '#f2ff59']) + }) + + it('catches a stale yellow written as 8-digit hex', () => { + expect( + yellowsIn(``) + ).toEqual(['#f0ff41', '#f2ff59']) + }) + + it('ignores colours outside the yellow family', () => { + expect( + yellowsIn(``) + ).toEqual([yellow]) + }) + + it('reports a colour syntax it cannot read rather than ignoring it', () => { + expect(unreadableColoursIn('')).toEqual([ + 'hsl(65 100% 67%)' + ]) + expect(unreadableColoursIn(``)).toEqual([]) + }) + it('standalone brand SVGs use comfy-ink where they are two-tone', () => { const ink = token('color-primary-comfy-ink') const files = [ From 9dcf07d0e6c228730fadfdc6a045fb4ccfc879ef Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 13:10:38 +0000 Subject: [PATCH 06/14] test: derive the yellowsIn fixtures from the design-system token The helper tests hardcoded the active brand yellow and ink. That is the rule this branch introduces, applied to its own test, and it had a real failure mode: had the palette moved, these tests would have kept asserting the old value and passed while validating a colour the design system no longer ships. Active values now come from token(); the retired yellow and the synthetic second yellow stay literal because they are the negative controls. Expected arrays are built with .sort() so a token whose value sorts differently does not break them. Demonstrated by moving --color-electric-400 to #f5ff70: yellowsIn (5 tests) pass - they follow the token brand palette table fail - brandColors.ts still holds the old hex standalone brand SVGs fail - assets still hold the old fill The helper keeps working, and the two drift detectors fire, which is the split the file is for. Also moves the comfy-ink two-tone test back into the brand-colours describe. A stray closing brace from the previous commit had left it nested inside describe('yellowsIn'). --- apps/website/src/data/brandColors.test.ts | 58 ++++++++++++----------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index 37d404ba150..ae8a7886921 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -149,33 +149,50 @@ describe('brand colours that cannot reference a token', () => { ) } }) + + it('standalone brand SVGs use comfy-ink where they are two-tone', () => { + const ink = token('color-primary-comfy-ink') + const files = [ + 'public/favicon.svg', + 'public/icons/comfyicon.svg', + 'public/affiliates/brand/comfy-color-combo-ink.svg', + 'public/affiliates/brand/comfy-full-logo-ink.svg' + ] + + for (const file of files) { + const svg = read(file).toLowerCase() + expect(svg, `${file} should use ${ink}`).toContain(ink) + } + }) }) describe('yellowsIn', () => { - const yellow = '#f2ff59' - - it('catches a stale yellow written as shorthand hex', () => { - expect(yellowsIn(``)).toEqual([ - '#f2ff59', - '#ffff00' - ]) + const yellow = token('color-electric-400') + const ink = token('color-primary-comfy-ink') + const retiredYellow = '#f0ff41' + const someOtherYellow = '#ffff00' + + it('catches a second yellow written as shorthand hex', () => { + expect(yellowsIn(``)).toEqual( + [yellow, someOtherYellow].sort() + ) }) - it('catches a stale yellow written as rgb()', () => { + it('catches a retired yellow written as rgb()', () => { expect( yellowsIn(``) - ).toEqual(['#f0ff41', '#f2ff59']) + ).toEqual([yellow, retiredYellow].sort()) }) - it('catches a stale yellow written as 8-digit hex', () => { + it('catches a retired yellow written as 8-digit hex', () => { expect( - yellowsIn(``) - ).toEqual(['#f0ff41', '#f2ff59']) + yellowsIn(``) + ).toEqual([yellow, retiredYellow].sort()) }) it('ignores colours outside the yellow family', () => { expect( - yellowsIn(``) + yellowsIn(``) ).toEqual([yellow]) }) @@ -185,19 +202,4 @@ describe('yellowsIn', () => { ]) expect(unreadableColoursIn(``)).toEqual([]) }) - - it('standalone brand SVGs use comfy-ink where they are two-tone', () => { - const ink = token('color-primary-comfy-ink') - const files = [ - 'public/favicon.svg', - 'public/icons/comfyicon.svg', - 'public/affiliates/brand/comfy-color-combo-ink.svg', - 'public/affiliates/brand/comfy-full-logo-ink.svg' - ] - - for (const file of files) { - const svg = read(file).toLowerCase() - expect(svg, `${file} should use ${ink}`).toContain(ink) - } - }) }) From dd27bbdd49cea5b25c7defc68b7f479cdc9411a6 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Fri, 31 Jul 2026 13:19:40 +0000 Subject: [PATCH 07/14] fix(test): do not read a url() reference as a colour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chasing the request for malformed-input coverage turned up a real bug in the helper rather than just a gap in the tests. coloursIn scanned the raw markup, so an SVG reference like url(#ffee00) was matched as a six-digit hex and counted as a colour: yellowsIn -> [ '#f2ff59', '#ffee00' ] None of the covered assets use url() today, so nothing was failing, but Figma and Illustrator emit it for gradients and clip paths — the first re-export with a gradient whose id happened to look like hex would have failed the brand-yellow check for a colour that was never in the file. A guard that cries wolf gets deleted, so this matters as much as a miss. url(...) is now stripped before colour scanning, and the case is pinned: reverting the strip fails the new test with the exact output above. Boundary coverage added alongside it — empty input, markup with no colour attribute, path data, fill="none", and a malformed five-digit hex, which is reported as unreadable rather than silently skipped. --- apps/website/src/data/brandColors.test.ts | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index ae8a7886921..015ba6ac058 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -57,7 +57,8 @@ const toHex = ({ r, g, b }: Rgb) => const isYellow = ({ r, g, b }: Rgb) => r > 200 && g > 200 && b < 200 -const coloursIn = (svg: string) => svg.match(COLOUR_LITERAL) ?? [] +const coloursIn = (svg: string) => + svg.replace(/url\([^)]*\)/gi, '').match(COLOUR_LITERAL) ?? [] function yellowsIn(svg: string): string[] { const yellows = coloursIn(svg) @@ -202,4 +203,28 @@ describe('yellowsIn', () => { ]) expect(unreadableColoursIn(``)).toEqual([]) }) + + it('reports a malformed hex literal as unreadable', () => { + expect(unreadableColoursIn('')).toEqual(['#12345']) + expect(yellowsIn('')).toEqual([]) + }) + + it('finds nothing in markup that carries no colour', () => { + expect(yellowsIn('')).toEqual([]) + expect(unreadableColoursIn('')).toEqual([]) + expect(yellowsIn('')).toEqual( + [] + ) + expect(unreadableColoursIn('')).toEqual( + [] + ) + }) + + it('does not mistake a url() reference for a colour', () => { + const gradientRef = + '' + + `` + expect(yellowsIn(gradientRef)).toEqual([yellow]) + expect(unreadableColoursIn(gradientRef)).toEqual([]) + }) }) From aef89b8bfdefc019eef924e005c14312d992abc8 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Sun, 2 Aug 2026 19:26:27 +0000 Subject: [PATCH 08/14] refactor: share the design-token reader, move token guidance to design-system - move readDesignToken/readDesignTokenRgba into @comfyorg/shared-frontend-utils so the chart, the website canvases and the snake game read tokens the same way - readDesignToken takes fallback token names, so a fallback stays a token - extract DesignTokenName, name the regex matches in parseRgb - shrink the AGENTS.md rule to three lines and document consuming tokens in the design-system README - American spellings in brandColors.test.ts --- AGENTS.md | 18 +---- apps/website/src/composables/useHeroLogo.ts | 3 +- apps/website/src/data/brandColors.test.ts | 68 +++++++++---------- apps/website/src/scripts/snakeGame.ts | 15 ++-- .../src/templates/brand/BrandBackground.vue | 3 +- apps/website/src/utils/designTokens.ts | 43 ------------ packages/design-system/README.md | 40 +++++++++++ packages/shared-frontend-utils/package.json | 1 + .../src/designTokens.test.ts | 57 ++++++++++++++++ .../shared-frontend-utils/src/designTokens.ts | 55 +++++++++++++++ src/components/ui/chart/useChart.ts | 15 ++-- 11 files changed, 204 insertions(+), 114 deletions(-) delete mode 100644 apps/website/src/utils/designTokens.ts create mode 100644 packages/shared-frontend-utils/src/designTokens.test.ts create mode 100644 packages/shared-frontend-utils/src/designTokens.ts diff --git a/AGENTS.md b/AGENTS.md index 334929fa3d1..99eaff8b355 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -255,21 +255,9 @@ When working from a TDD or design doc, record its tradeoffs, alternatives consid - Instead use a semantic value from the `style.css` theme - e.g. `bg-node-component-surface` - NEVER write out a design-system value — consume the token - - `packages/design-system` is the single source of truth, published as `@comfyorg/design-system` and consumed by downstream apps - - Applies to every token it ships: colors, fonts, icons, spacing, radii, shadows, text sizes - - Matching the value is not enough. A literal that merely equals the token today still drifts the day the token changes, and it is invisible when it does. What matters is that the value is _read_ from the package, not that it happens to agree with it - - How to consume it, by context: - - Tailwind class — `bg-brand-yellow`, `fill-primary-comfy-ink`, `font-inter` - - CSS, including `style` attributes and inline SVG — `var(--color-brand-yellow)` - - Deriving a variant — `rgb(from var(--color-primary-comfy-ink) r g b / 0.8)`, never a pre-mixed literal - - Canvas / WebGL / any API needing a concrete string — read it at runtime, e.g. `readDesignToken('--color-primary-comfy-yellow')` in `apps/website` - - A token-valued fallback beats a literal one — `getCssVar('--color-muted-foreground') || getCssVar('--color-smoke-800')` - - NEVER use `fill="var(--token)"` as an SVG presentation attribute. Substitution functions there were only resolved into SVG2 in Nov 2025 and Chromium support is uneven — use a `fill-*` utility class or a `style="fill: var(...)"` declaration - - Two things this rule does NOT mean: - - A value that coincidentally equals a token is not a token usage. `#d9d9d9` as a minimap node fill is not `smoke-400`; rewriting it would couple unrelated UI to the brand and change it on the next brand tweak - - Where a literal is unavoidable — a ``, a copyable hex on the brand page, a standalone `.svg` fetched as an image — pin it with a test instead, as `apps/website/src/data/brandColors.test.ts` does - - If the token you need is missing from the entry point you import, add it to the design system rather than copying the value. `base.css` is the marketing-site entry point and deliberately excludes the PrimeVue and node-editor theme - - Brand yellow was stale by a full revision (`#f0ff41` vs `#f2ff59`) purely because copies existed + - `packages/design-system` is the single source of truth for every token it ships: colors, fonts, icons, spacing, radii, shadows, text sizes + - Read the value from the package — a Tailwind class, `var(--token)`, or `readDesignToken()` where an API needs a concrete string. A literal that merely equals the token today still drifts the day the token changes, and it is invisible when it does + - See [Consuming tokens](packages/design-system/README.md#consuming-tokens) for the per-context table, the SVG `fill` caveat, and the two cases where a literal is unavoidable - NEVER use `:class="[]"` to merge class names - Always use `import { cn } from '@comfyorg/tailwind-utils'` - e.g. `
` diff --git a/apps/website/src/composables/useHeroLogo.ts b/apps/website/src/composables/useHeroLogo.ts index 3fa35e6fa92..9721b785056 100644 --- a/apps/website/src/composables/useHeroLogo.ts +++ b/apps/website/src/composables/useHeroLogo.ts @@ -4,7 +4,8 @@ import { onMounted, onUnmounted, ref } from 'vue' import * as THREE from 'three' import { SVGLoader } from 'three/addons/loaders/SVGLoader.js' -import { readDesignToken } from '../utils/designTokens' +import { readDesignToken } from '@comfyorg/shared-frontend-utils/designTokens' + import { prefersReducedMotion } from './useReducedMotion' const IMAGE_COUNT = 16 diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index 015ba6ac058..42bef5f4f8f 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -29,21 +29,21 @@ interface Rgb { b: number } -const COLOUR_LITERAL = +const COLOR_LITERAL = /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|(?:ok)?l(?:ab|ch)|color|color-mix)\([^)]*\)/gi -function parseColour(literal: string): Rgb | undefined { +function parseColor(literal: string): Rgb | undefined { const hex = /^#([0-9a-f]{3,8})$/i.exec(literal) if (hex) { const digits = hex[1] - const channels = + const rrggbb = digits.length === 3 || digits.length === 4 - ? [...digits.slice(0, 3)].map((c) => c + c) + ? digits.slice(0, 3).replace(/./g, '$&$&') : digits.length === 6 || digits.length === 8 - ? [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 6)] + ? digits.slice(0, 6) : undefined - if (!channels) return undefined - const [r, g, b] = channels.map((pair) => parseInt(pair, 16)) + if (!rrggbb) return undefined + const [r, g, b] = [0, 2, 4].map((i) => parseInt(rrggbb.slice(i, i + 2), 16)) return { r, g, b } } const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(literal) @@ -57,32 +57,32 @@ const toHex = ({ r, g, b }: Rgb) => const isYellow = ({ r, g, b }: Rgb) => r > 200 && g > 200 && b < 200 -const coloursIn = (svg: string) => - svg.replace(/url\([^)]*\)/gi, '').match(COLOUR_LITERAL) ?? [] +const colorsIn = (svg: string) => + svg.replace(/url\([^)]*\)/gi, '').match(COLOR_LITERAL) ?? [] function yellowsIn(svg: string): string[] { - const yellows = coloursIn(svg) - .map(parseColour) - .filter((colour): colour is Rgb => colour !== undefined && isYellow(colour)) + const yellows = colorsIn(svg) + .map(parseColor) + .filter((color): color is Rgb => color !== undefined && isYellow(color)) .map(toHex) return [...new Set(yellows)].sort() } -function unreadableColoursIn(svg: string): string[] { - const unreadable = coloursIn(svg).filter( - (literal) => parseColour(literal) === undefined +function unreadableColorsIn(svg: string): string[] { + const unreadable = colorsIn(svg).filter( + (literal) => parseColor(literal) === undefined ) return [...new Set(unreadable.map((c) => c.toLowerCase()))].sort() } /* - * Everything asserted here is a place a design-system colour has to be written + * Everything asserted here is a place a design-system color has to be written * out as a literal, because the consumer cannot read a CSS custom property: * a data table rendered as copyable text, a value the browser parses * itself, and standalone SVGs fetched as images. Since they cannot reference * the token, these tests are what stops them drifting from it. */ -describe('brand colours that cannot reference a token', () => { +describe('brand colors that cannot reference a token', () => { it('the /brand palette table matches the design system', () => { const expected: Record = { 'Comfy Yellow': token('color-electric-400'), @@ -99,11 +99,11 @@ describe('brand colours that cannot reference a token', () => { }) it('the /brand palette table rgb values agree with its own hex values', () => { - for (const colour of brandColors) { - const hex = colour.hex.replace('#', '') + for (const color of brandColors) { + const hex = color.hex.replace('#', '') const fromHex = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16)) - const declared = colour.rgb.split(',').map((n) => Number(n.trim())) - expect(declared, `${colour.name} rgb`).toEqual(fromHex) + const declared = color.rgb.split(',').map((n) => Number(n.trim())) + expect(declared, `${color.name} rgb`).toEqual(fromHex) } }) @@ -131,7 +131,7 @@ describe('brand colours that cannot reference a token', () => { } }) - it('every colour in a brand SVG is one the yellow check can read', () => { + it('every color in a brand SVG is one the yellow check can read', () => { const files = [ 'public/favicon.svg', 'public/icons/logo.svg', @@ -145,9 +145,7 @@ describe('brand colours that cannot reference a token', () => { ] for (const file of files) { - expect(unreadableColoursIn(read(file)), `${file} colour syntax`).toEqual( - [] - ) + expect(unreadableColorsIn(read(file)), `${file} color syntax`).toEqual([]) } }) @@ -191,40 +189,40 @@ describe('yellowsIn', () => { ).toEqual([yellow, retiredYellow].sort()) }) - it('ignores colours outside the yellow family', () => { + it('ignores colors outside the yellow family', () => { expect( yellowsIn(``) ).toEqual([yellow]) }) - it('reports a colour syntax it cannot read rather than ignoring it', () => { - expect(unreadableColoursIn('')).toEqual([ + it('reports a color syntax it cannot read rather than ignoring it', () => { + expect(unreadableColorsIn('')).toEqual([ 'hsl(65 100% 67%)' ]) - expect(unreadableColoursIn(``)).toEqual([]) + expect(unreadableColorsIn(``)).toEqual([]) }) it('reports a malformed hex literal as unreadable', () => { - expect(unreadableColoursIn('')).toEqual(['#12345']) + expect(unreadableColorsIn('')).toEqual(['#12345']) expect(yellowsIn('')).toEqual([]) }) - it('finds nothing in markup that carries no colour', () => { + it('finds nothing in markup that carries no color', () => { expect(yellowsIn('')).toEqual([]) - expect(unreadableColoursIn('')).toEqual([]) + expect(unreadableColorsIn('')).toEqual([]) expect(yellowsIn('')).toEqual( [] ) - expect(unreadableColoursIn('')).toEqual( + expect(unreadableColorsIn('')).toEqual( [] ) }) - it('does not mistake a url() reference for a colour', () => { + it('does not mistake a url() reference for a color', () => { const gradientRef = '' + `` expect(yellowsIn(gradientRef)).toEqual([yellow]) - expect(unreadableColoursIn(gradientRef)).toEqual([]) + expect(unreadableColorsIn(gradientRef)).toEqual([]) }) }) diff --git a/apps/website/src/scripts/snakeGame.ts b/apps/website/src/scripts/snakeGame.ts index 75f24c500e7..b1ac2bd1cbd 100644 --- a/apps/website/src/scripts/snakeGame.ts +++ b/apps/website/src/scripts/snakeGame.ts @@ -1,3 +1,5 @@ +import { readDesignToken } from '@comfyorg/shared-frontend-utils/designTokens' + interface Cell { i: number j: number @@ -34,15 +36,12 @@ const LIFT = HEX_H * 0.35 const TICK_MS = 200 function readColors() { - const style = getComputedStyle(document.documentElement) - const get = (name: string): string => style.getPropertyValue(name).trim() - return { - bg: get('--color-primary-comfy-ink'), - fieldStroke: get('--color-secondary-mauve'), - snakeA: get('--color-primary-comfy-plum'), - snakeB: get('--color-secondary-mauve'), - accent: get('--color-primary-comfy-yellow') + bg: readDesignToken('--color-primary-comfy-ink'), + fieldStroke: readDesignToken('--color-secondary-mauve'), + snakeA: readDesignToken('--color-primary-comfy-plum'), + snakeB: readDesignToken('--color-secondary-mauve'), + accent: readDesignToken('--color-primary-comfy-yellow') } } diff --git a/apps/website/src/templates/brand/BrandBackground.vue b/apps/website/src/templates/brand/BrandBackground.vue index 30196dfbf21..52ac0bf9f37 100644 --- a/apps/website/src/templates/brand/BrandBackground.vue +++ b/apps/website/src/templates/brand/BrandBackground.vue @@ -6,8 +6,9 @@ import { } from '@vueuse/core' import { onMounted, ref } from 'vue' +import { readDesignTokenRgba } from '@comfyorg/shared-frontend-utils/designTokens' + import { prefersReducedMotion } from '../../composables/useReducedMotion' -import { readDesignTokenRgba } from '../../utils/designTokens' interface Node { x: number diff --git a/apps/website/src/utils/designTokens.ts b/apps/website/src/utils/designTokens.ts deleted file mode 100644 index 1ab67982b32..00000000000 --- a/apps/website/src/utils/designTokens.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Reads a design-system token off the document so canvas and WebGL code can use - * the same value CSS does. Both need a concrete colour string, so they cannot - * reference `var(--token)` directly the way a stylesheet can. - */ -export function readDesignToken(name: `--${string}`): string { - if (typeof document === 'undefined') return '' - return getComputedStyle(document.documentElement) - .getPropertyValue(name) - .trim() -} - -/** Same value as `rgb(from var(name) r g b / alpha)`, for canvas fill/stroke. */ -export function readDesignTokenRgba( - name: `--${string}`, - alpha: number -): string { - const rgb = parseRgb(readDesignToken(name)) - if (!rgb) return '' - return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})` -} - -function parseRgb( - color: string -): { r: number; g: number; b: number } | undefined { - const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim()) - if (hex) { - const digits = - hex[1].length === 3 ? [...hex[1]].map((c) => c + c).join('') : hex[1] - return { - r: parseInt(digits.slice(0, 2), 16), - g: parseInt(digits.slice(2, 4), 16), - b: parseInt(digits.slice(4, 6), 16) - } - } - const fn = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec( - color.trim() - ) - if (fn) { - return { r: Number(fn[1]), g: Number(fn[2]), b: Number(fn[3]) } - } - return undefined -} diff --git a/packages/design-system/README.md b/packages/design-system/README.md index 743668e0029..2298c33dd7b 100644 --- a/packages/design-system/README.md +++ b/packages/design-system/README.md @@ -43,6 +43,46 @@ For the palette and fonts without the Tailwind layers or icon plugins: Icons are exposed to Tailwind as `icon-[comfy--*]` and `icon-mask-[comfy--*]` utilities. Size them with `size-*`, not font-size classes. +## Consuming tokens + +Never write out a value this package ships — read it from the package. That +holds for every token here: colors, fonts, icons, spacing, radii, shadows, text +sizes. + +Matching the value is not enough. A literal that equals the token today still +drifts the day the token changes, and nothing points at it when it does. Brand +yellow went stale by a full revision (`#f0ff41` vs `#f2ff59`) purely because +copies of it existed. + +| Context | Consume it as | +| --------------------------------------- | ------------------------------------------------------------------------------------ | +| Tailwind class | `bg-brand-yellow`, `fill-primary-comfy-ink`, `font-inter` | +| CSS, `style` attributes, inline SVG | `var(--color-brand-yellow)` | +| A derived variant | `rgb(from var(--color-primary-comfy-ink) r g b / 0.8)`, never a pre-mixed literal | +| Canvas, WebGL, any API needing a string | read it at runtime — in this repo, `readDesignToken('--color-primary-comfy-yellow')` | +| A fallback | another token — `readDesignToken('--color-muted-foreground', '--color-smoke-800')` | + +The runtime reader lives in `@comfyorg/shared-frontend-utils/designTokens`; it +resolves the custom property off `document.documentElement`, so the value stays +whatever the stylesheet says. + +Do not use `fill="var(--token)"` as an SVG presentation attribute. Substitution +functions there were only resolved into SVG2 in Nov 2025 and Chromium support is +uneven — use a `fill-*` utility class or a `style="fill: var(...)"` declaration. + +If the token you need is missing from the entry point you import, add it here +rather than copying the value. `base.css` is the marketing-site entry point and +deliberately excludes the PrimeVue and node-editor theme. + +Two things this does not mean: + +- A value that coincidentally equals a token is not a token usage. `#d9d9d9` as + a minimap node fill is not `smoke-400`; rewriting it would couple unrelated UI + to the brand and change it on the next brand tweak. +- Where a literal is unavoidable — a ``, a copyable hex + on a brand page, a standalone `.svg` fetched as an image — pin it with a test + instead, as `apps/website/src/data/brandColors.test.ts` does. + ## Releasing Run the **Version Bump Design System** workflow to open a version PR, then merge diff --git a/packages/shared-frontend-utils/package.json b/packages/shared-frontend-utils/package.json index c742aa88fe6..430ddc767ab 100644 --- a/packages/shared-frontend-utils/package.json +++ b/packages/shared-frontend-utils/package.json @@ -7,6 +7,7 @@ "type": "module", "exports": { "./creditsUtil": "./src/creditsUtil.ts", + "./designTokens": "./src/designTokens.ts", "./formatUtil": "./src/formatUtil.ts", "./networkUtil": "./src/networkUtil.ts", "./piiUtil": "./src/piiUtil.ts" diff --git a/packages/shared-frontend-utils/src/designTokens.test.ts b/packages/shared-frontend-utils/src/designTokens.test.ts new file mode 100644 index 00000000000..0f4b8e2e8de --- /dev/null +++ b/packages/shared-frontend-utils/src/designTokens.test.ts @@ -0,0 +1,57 @@ +import { afterEach, describe, expect, it } from 'vitest' + +import { readDesignToken, readDesignTokenRgba } from './designTokens' + +afterEach(() => { + document.documentElement.removeAttribute('style') +}) + +const define = (name: string, value: string) => + document.documentElement.style.setProperty(name, value) + +describe('readDesignToken', () => { + it('falls through to the next token when the one before it is unset', () => { + define('--color-smoke-800', '#454545') + + expect( + readDesignToken('--color-muted-foreground', '--color-smoke-800') + ).toBe('#454545') + }) + + it('prefers the first token that has a value', () => { + define('--color-muted-foreground', '#8a8a8a') + define('--color-smoke-800', '#454545') + + expect( + readDesignToken('--color-muted-foreground', '--color-smoke-800') + ).toBe('#8a8a8a') + }) + + it('returns an empty string when no name resolves', () => { + expect(readDesignToken('--color-muted-foreground')).toBe('') + }) +}) + +describe('readDesignTokenRgba', () => { + it('applies the alpha to a token written as hex', () => { + define('--color-primary-comfy-yellow', '#f2ff59') + + expect(readDesignTokenRgba('--color-primary-comfy-yellow', 0.18)).toBe( + 'rgba(242, 255, 89, 0.18)' + ) + }) + + it('applies the alpha to a token written as rgb()', () => { + define('--color-primary-comfy-yellow', 'rgb(242, 255, 89)') + + expect(readDesignTokenRgba('--color-primary-comfy-yellow', 0.9)).toBe( + 'rgba(242, 255, 89, 0.9)' + ) + }) + + it('returns an empty string for a token it cannot parse', () => { + define('--color-primary-comfy-yellow', 'hsl(65 100% 67%)') + + expect(readDesignTokenRgba('--color-primary-comfy-yellow', 0.5)).toBe('') + }) +}) diff --git a/packages/shared-frontend-utils/src/designTokens.ts b/packages/shared-frontend-utils/src/designTokens.ts new file mode 100644 index 00000000000..05e46a20dc8 --- /dev/null +++ b/packages/shared-frontend-utils/src/designTokens.ts @@ -0,0 +1,55 @@ +export type DesignTokenName = `--${string}` + +/** + * Reads a design-system token off the document so canvas and WebGL code can use + * the same value CSS does. Both need a concrete color string, so they cannot + * reference `var(--token)` directly the way a stylesheet can. + * + * Names after the first are fallbacks, tried in order, so a fallback stays a + * token rather than becoming a literal. + */ +export function readDesignToken(...names: DesignTokenName[]): string { + if (typeof document === 'undefined') return '' + const styles = getComputedStyle(document.documentElement) + for (const name of names) { + const value = styles.getPropertyValue(name).trim() + if (value) return value + } + return '' +} + +/** Same value as `rgb(from var(name) r g b / alpha)`, for canvas fill/stroke. */ +export function readDesignTokenRgba( + name: DesignTokenName, + alpha: number +): string { + const rgb = parseRgb(readDesignToken(name)) + if (!rgb) return '' + return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})` +} + +function parseRgb( + color: string +): { r: number; g: number; b: number } | undefined { + const hexMatch = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim()) + if (hexMatch) { + const digits = + hexMatch[1].length === 3 ? hexMatch[1].replace(/./g, '$&$&') : hexMatch[1] + return { + r: parseInt(digits.slice(0, 2), 16), + g: parseInt(digits.slice(2, 4), 16), + b: parseInt(digits.slice(4, 6), 16) + } + } + const rgbMatch = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec( + color.trim() + ) + if (rgbMatch) { + return { + r: Number(rgbMatch[1]), + g: Number(rgbMatch[2]), + b: Number(rgbMatch[3]) + } + } + return undefined +} diff --git a/src/components/ui/chart/useChart.ts b/src/components/ui/chart/useChart.ts index 15af498af18..c9b5f165a22 100644 --- a/src/components/ui/chart/useChart.ts +++ b/src/components/ui/chart/useChart.ts @@ -1,3 +1,4 @@ +import { readDesignToken } from '@comfyorg/shared-frontend-utils/designTokens' import type { ChartData, ChartOptions, ChartType } from 'chart.js' import { BarController, @@ -29,18 +30,10 @@ Chart.register( Tooltip ) -function getCssVar(name: string): string { - return getComputedStyle(document.documentElement) - .getPropertyValue(name) - .trim() -} - function getDefaultOptions(type: ChartType): ChartOptions { - const foreground = - getCssVar('--color-base-foreground') || getCssVar('--color-white') - const muted = - getCssVar('--color-muted-foreground') || getCssVar('--color-smoke-800') - const fontFamily = getCssVar('--font-inter') + const foreground = readDesignToken('--color-base-foreground', '--color-white') + const muted = readDesignToken('--color-muted-foreground', '--color-smoke-800') + const fontFamily = readDesignToken('--font-inter') return { responsive: true, From 5f0463799468956479310b501408085d09166382 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Sun, 2 Aug 2026 19:36:39 +0000 Subject: [PATCH 09/14] test: pin the desktop-ui and cloud brand SVGs to the yellow token --- apps/website/src/data/brandColors.test.ts | 70 +++++++++++------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index 42bef5f4f8f..e3ae1d7e517 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -20,8 +20,32 @@ function token(name: string): string { } const websiteRoot = join(import.meta.dirname, '..', '..') +const repoRoot = join(websiteRoot, '..', '..') const read = (relative: string) => readFileSync(join(websiteRoot, relative), 'utf-8') +const readRepo = (relative: string) => + readFileSync(join(repoRoot, relative), 'utf-8') + +const yellowSvgs = [ + 'apps/website/public/favicon.svg', + 'apps/website/public/icons/logo.svg', + 'apps/website/public/icons/logomark.svg', + 'apps/website/public/icons/comfyicon.svg', + 'apps/website/public/affiliates/brand/comfy-full-logo-yellow.svg', + 'apps/website/public/affiliates/brand/comfy-color-combo-yellow.svg', + 'apps/website/public/affiliates/brand/comfy-amplified-logo-mark.svg', + 'apps/desktop-ui/public/assets/images/comfy-brand-mark.svg', + 'public/assets/images/comfy-cloud-logo.svg' +] + +const inkSvgs = [ + 'apps/website/public/favicon.svg', + 'apps/website/public/icons/comfyicon.svg', + 'apps/website/public/affiliates/brand/comfy-color-combo-ink.svg', + 'apps/website/public/affiliates/brand/comfy-full-logo-ink.svg' +] + +const brandSvgs = [...new Set([...yellowSvgs, ...inkSvgs])] interface Rgb { r: number @@ -116,50 +140,26 @@ describe('brand colors that cannot reference a token', () => { it('standalone brand SVGs use the brand yellow', () => { const yellow = token('color-electric-400') - const files = [ - 'public/favicon.svg', - 'public/icons/logo.svg', - 'public/icons/logomark.svg', - 'public/icons/comfyicon.svg', - 'public/affiliates/brand/comfy-full-logo-yellow.svg', - 'public/affiliates/brand/comfy-color-combo-yellow.svg', - 'public/affiliates/brand/comfy-amplified-logo-mark.svg' - ] - - for (const file of files) { - expect(yellowsIn(read(file)), `${file} yellows`).toEqual([yellow]) + + for (const file of yellowSvgs) { + expect(yellowsIn(readRepo(file)), `${file} yellows`).toEqual([yellow]) } }) it('every color in a brand SVG is one the yellow check can read', () => { - const files = [ - 'public/favicon.svg', - 'public/icons/logo.svg', - 'public/icons/logomark.svg', - 'public/icons/comfyicon.svg', - 'public/affiliates/brand/comfy-full-logo-yellow.svg', - 'public/affiliates/brand/comfy-color-combo-yellow.svg', - 'public/affiliates/brand/comfy-amplified-logo-mark.svg', - 'public/affiliates/brand/comfy-color-combo-ink.svg', - 'public/affiliates/brand/comfy-full-logo-ink.svg' - ] - - for (const file of files) { - expect(unreadableColorsIn(read(file)), `${file} color syntax`).toEqual([]) + for (const file of brandSvgs) { + expect( + unreadableColorsIn(readRepo(file)), + `${file} color syntax` + ).toEqual([]) } }) it('standalone brand SVGs use comfy-ink where they are two-tone', () => { const ink = token('color-primary-comfy-ink') - const files = [ - 'public/favicon.svg', - 'public/icons/comfyicon.svg', - 'public/affiliates/brand/comfy-color-combo-ink.svg', - 'public/affiliates/brand/comfy-full-logo-ink.svg' - ] - - for (const file of files) { - const svg = read(file).toLowerCase() + + for (const file of inkSvgs) { + const svg = readRepo(file).toLowerCase() expect(svg, `${file} should use ${ink}`).toContain(ink) } }) From 749063f11a7ebcd9c36f3a6f98a6e951997a18bf Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 8 Aug 2026 18:25:57 -0700 Subject: [PATCH 10/14] refactor(website): consume the white token for the subtle border --site-bg and --site-bg-soft already read tokens; --site-border-subtle restated white beside them. --- apps/website/src/styles/global.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index d710fa5157a..327ba41eb66 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -497,7 +497,7 @@ video::-webkit-media-controls-panel { :root { --site-bg: var(--color-primary-comfy-ink); --site-bg-soft: var(--color-site-bg-soft); - --site-border-subtle: rgb(255 255 255 / 0.1); + --site-border-subtle: rgb(from var(--color-white) r g b / 0.1); } @keyframes backdrop-sway { From b41776e2d105ec654e94c0390039e544276551d8 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 8 Aug 2026 18:40:02 -0700 Subject: [PATCH 11/14] refactor(website): drop transparency tokens the package already ships _palette.css declares white-t8 and white-t20 with the same values, so the site @theme was shadowing them. Tailwind still emits both utilities from the package. --- apps/website/src/styles/global.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index 327ba41eb66..b40a6982470 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -89,8 +89,6 @@ --color-secondary-cool-gray: #3c3c3c; --color-illustration-forest: #20464c; --color-transparency-white-t4: rgb(from var(--color-white) r g b / 0.04); - --color-transparency-white-t8: rgb(255 255 255 / 0.08); - --color-transparency-white-t20: rgb(255 255 255 / 0.2); --color-transparency-ink-t80: rgb( from var(--color-primary-comfy-ink) r g b / 0.8 ); From 005043fda59ff489c7f8ab9f997c91d26de46184 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Sun, 9 Aug 2026 02:41:59 +0000 Subject: [PATCH 12/14] test: assert brand SVGs against the semantic yellow token, and run website tests in CI The brand-colour assertions read --color-electric-400, the primitive, while everything downstream consumes --color-brand-yellow. Repointing the semantic alias would have left the suite green while every standalone SVG drifted, so token() now follows var() chains and the assertions name the semantic token. The suite that guards this never ran in CI: root vitest only includes src, packages and scripts, and the website workflow built without testing. --- .github/workflows/ci-website-build.yaml | 3 ++ apps/website/src/data/brandColors.test.ts | 34 +++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-website-build.yaml b/.github/workflows/ci-website-build.yaml index 72eff5c126d..af4dd11d4d0 100644 --- a/.github/workflows/ci-website-build.yaml +++ b/.github/workflows/ci-website-build.yaml @@ -38,6 +38,9 @@ jobs: - name: Typecheck website run: pnpm --filter @comfyorg/website typecheck + - name: Run website unit tests + run: pnpm --filter @comfyorg/website test:unit + - name: Build website env: WEBSITE_ASHBY_API_KEY: ${{ secrets.WEBSITE_ASHBY_API_KEY }} diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index e3ae1d7e517..5913beac577 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -12,11 +12,29 @@ const paletteCss = readFileSync( ) function token(name: string): string { - const match = new RegExp(`--${name}:\\s*(#[0-9a-fA-F]{6})\\s*;`).exec( - paletteCss - ) - if (!match) throw new Error(`token --${name} not found in the design system`) - return match[1].toLowerCase() + const seen = new Set() + let current = name + + while (!seen.has(current)) { + seen.add(current) + const declaration = new RegExp(`--${current}:\\s*([^;]+);`).exec(paletteCss) + if (!declaration) { + throw new Error(`token --${current} not found in the design system`) + } + + const value = declaration[1].trim() + const alias = /^var\(\s*--([\w-]+)\s*\)$/.exec(value) + if (alias) { + current = alias[1] + continue + } + if (!/^#[0-9a-fA-F]{6}$/.test(value)) { + throw new Error(`token --${current} is not a six-digit hex: ${value}`) + } + return value.toLowerCase() + } + + throw new Error(`token --${name} resolves through a cycle`) } const websiteRoot = join(import.meta.dirname, '..', '..') @@ -109,7 +127,7 @@ function unreadableColorsIn(svg: string): string[] { describe('brand colors that cannot reference a token', () => { it('the /brand palette table matches the design system', () => { const expected: Record = { - 'Comfy Yellow': token('color-electric-400'), + 'Comfy Yellow': token('color-brand-yellow'), 'Comfy Ink': token('color-primary-comfy-ink'), 'Comfy Canvas': token('color-primary-comfy-canvas'), 'Comfy Plum': token('color-plum-600') @@ -139,7 +157,7 @@ describe('brand colors that cannot reference a token', () => { }) it('standalone brand SVGs use the brand yellow', () => { - const yellow = token('color-electric-400') + const yellow = token('color-brand-yellow') for (const file of yellowSvgs) { expect(yellowsIn(readRepo(file)), `${file} yellows`).toEqual([yellow]) @@ -166,7 +184,7 @@ describe('brand colors that cannot reference a token', () => { }) describe('yellowsIn', () => { - const yellow = token('color-electric-400') + const yellow = token('color-brand-yellow') const ink = token('color-primary-comfy-ink') const retiredYellow = '#f0ff41' const someOtherYellow = '#ffff00' From 09e7a2dad34e0d3a75c922425125ecf73dc68d87 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 28 Aug 2026 20:00:49 -0700 Subject: [PATCH 13/14] refactor(design-system): move the brand layer into the package (#14790) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stacked on #14484. That PR stops surfaces from restating token values; this one moves the brand layer itself into the package, so there is a single file that owns every brand colour and the brand typeface. - **What**: `_brand.css` (all brand colours + both brand font tokens) and `brand-fonts.css` (the PP Formula faces). `base.css` becomes the brand surface — brand, brand fonts, shared ramps; `style.css` is that plus everything product. `apps/website/src/styles/global.css` drops the 10 brand colours, the 6 PP Formula `@font-face` blocks, both font tokens and the dead Google Fonts Inter import, keeping only site-specific values. 82 mauve stroke literals across three HeroSections, 12 PP Formula literals in `HubspotFormEmbed` and `404.astro`, and the `--brand-yellow` indirection in `style.css` are gone. - **Breaking**: `_palette.css` no longer carries brand tokens and `base.css` no longer loads Inter. Nothing consumes either today — checked. `platform` imports `_palette.css` for the neutral ramps only, and the website never used Inter (its body is `font-formula`), which is what made the Google Fonts import dead. Version bumped to `1.1.0`; platform should move its import to `base.css` when it takes the upgrade. **Why the brand yellow could drift at all.** It was declared in three places under different names, so no single change could keep them equal. The same was true of `--font-formula`, and worse: `_palette.css` said `'PP Formula', 'Inter', sans-serif` while the website said `'PP Formula', sans-serif`, and the website silently won. I kept the Inter fallback in the unified token, because the app bundles only three of the six PP Formula weights (`src/platform/cloud/onboarding/assets`) and leans on Inter for the rest. On comfy.org the fallback is inert — no Inter is served there — so rendering is unchanged on both surfaces. **The test is the part that lasts.** `brandColors.test.ts` now fails if any `--color-*` or `--font-*` token is declared in more than one of `_brand.css`, `_palette.css`, and the website's `@theme`. Documentation alone would not have prevented this; the second declaration always looks reasonable in isolation. **SVG strokes went to utility classes, not `var()`.** `stroke="#4D3762"` became `class="stroke-secondary-mauve"` rather than `stroke="var(--color-secondary-mauve)"` — substitution in SVG presentation attributes was only resolved into SVG2 in Nov 2025 and Chromium is uneven. The two occurrences inside `@keyframes` are real declarations, so those use `var()`. **Verification.** Diffed every emitted `--color-*` / `--font-*` in the built website CSS against the pre-change build: same 34 tokens, same values, only ordering differs plus the intended Inter fallback. Converted stroke counts match one-for-one in the built HTML (cloud 36, cloud/enterprise 39, download 5, zero leftover attributes). Both builds still resolve the full yellow chain to `#f2ff59`, all six PP Formula faces are present in the output, and no `fonts.googleapis` reference survives anywhere in `dist`. Gates: `lint` (0 errors), `format:check`, `typecheck`, `typecheck:website` (0 errors), `knip`, website build (581 pages), 345 website tests, 672 tests across `src/platform/cloud`, `packages/shared-frontend-utils` and `src/components/ui`. **Answers Alexis's question in-repo.** The README now says outright that the package holds two design systems, that the file is what distinguishes them, and that no naming convention reliably does — several token names predate the split. `primary-` is still overloaded across app-semantic roles and brand colours, and `plum-600` / `primary-comfy-plum` remain the same hex under two names. Renaming them is deliberately not in this PR; it is a breaking change for consumers and wants its own decision. **Deliberately left alone.** `--text-2xs` still disagrees between `style.css` (`0.625rem`) and the website (`0.6875rem`). The website's value wins on comfy.org, so aligning it is a visible type change across the site — a designer's call, not a refactor's. The duplicate-declaration test is scoped to the files `base.css` actually pulls in, so it does not paper over this. --- .../components/common/HubspotFormEmbed.vue | 22 ++-- .../components/product/cloud/HeroSection.vue | 104 ++++++----------- .../components/product/local/HeroSection.vue | 14 +-- apps/website/src/data/brandColors.test.ts | 109 ++++++++++++++++-- apps/website/src/pages/404.astro | 3 +- apps/website/src/styles/global.css | 81 +------------ packages/design-system/README.md | 43 +++++-- packages/design-system/package.json | 2 +- packages/design-system/src/css/_brand.css | 44 +++++++ packages/design-system/src/css/_palette.css | 9 -- packages/design-system/src/css/base.css | 13 ++- .../design-system/src/css/brand-fonts.css | 61 ++++++++++ packages/design-system/src/css/style.css | 7 +- 13 files changed, 312 insertions(+), 200 deletions(-) create mode 100644 packages/design-system/src/css/_brand.css create mode 100644 packages/design-system/src/css/brand-fonts.css diff --git a/apps/website/src/components/common/HubspotFormEmbed.vue b/apps/website/src/components/common/HubspotFormEmbed.vue index 61c06d8d4d0..79915a85198 100644 --- a/apps/website/src/components/common/HubspotFormEmbed.vue +++ b/apps/website/src/components/common/HubspotFormEmbed.vue @@ -18,29 +18,29 @@ const HUBSPOT_SCRIPT_SRC = `https://js-${HUBSPOT_REGION}.hsforms.net/forms/embed const hasEmbedLoadError = ref(false) const hubspotFormStyles: Record<`--${string}`, string> = { - '--hsf-global__font-family': "'PP Formula', sans-serif", + '--hsf-global__font-family': 'var(--font-formula)', '--hsf-global__color': 'var(--color-primary-comfy-canvas)', '--hsf-background__background-color': 'var(--color-primary-comfy-ink)', '--hsf-background__border-width': '0', '--hsf-background__padding': '0', - '--hsf-button__font-family': "'PP Formula', sans-serif", + '--hsf-button__font-family': 'var(--font-formula)', '--hsf-button__font-size': '14px', '--hsf-button__color': 'var(--color-primary-comfy-ink)', '--hsf-button__background-color': 'var(--color-primary-comfy-yellow)', '--hsf-button__border-radius': '16px', '--hsf-button__padding': '10px 24px', - '--hsf-richtext__font-family': "'PP Formula', sans-serif", + '--hsf-richtext__font-family': 'var(--font-formula)', '--hsf-richtext__color': 'var(--color-primary-comfy-canvas)', - '--hsf-heading__font-family': "'PP Formula', sans-serif", + '--hsf-heading__font-family': 'var(--font-formula)', '--hsf-heading__color': 'var(--color-primary-comfy-canvas)', - '--hsf-field-label__font-family': "'PP Formula', sans-serif", + '--hsf-field-label__font-family': 'var(--font-formula)', '--hsf-field-label__font-size': '12px', '--hsf-field-label__color': 'var(--color-primary-comfy-canvas)', - '--hsf-field-description__font-family': "'PP Formula', sans-serif", + '--hsf-field-description__font-family': 'var(--font-formula)', '--hsf-field-description__color': 'var(--color-primary-comfy-canvas)', - '--hsf-field-footer__font-family': "'PP Formula', sans-serif", + '--hsf-field-footer__font-family': 'var(--font-formula)', '--hsf-field-footer__color': 'var(--color-primary-comfy-canvas)', - '--hsf-field-input__font-family': "'PP Formula', sans-serif", + '--hsf-field-input__font-family': 'var(--font-formula)', '--hsf-field-input__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-input__background-color': '#2a2230', '--hsf-field-input__placeholder-color': '#585159', @@ -49,7 +49,7 @@ const hubspotFormStyles: Record<`--${string}`, string> = { '--hsf-field-input__border-style': 'solid', '--hsf-field-input__border-radius': '16px', '--hsf-field-input__padding': '16px', - '--hsf-field-textarea__font-family': "'PP Formula', sans-serif", + '--hsf-field-textarea__font-family': 'var(--font-formula)', '--hsf-field-textarea__color': 'var(--color-primary-comfy-canvas)', '--hsf-field-textarea__background-color': '#2a2230', '--hsf-field-textarea__placeholder-color': '#585159', @@ -68,8 +68,8 @@ const hubspotFormStyles: Record<`--${string}`, string> = { '--hsf-field-radio__border-color': '#464147', '--hsf-field-radio__border-width': '1px', '--hsf-field-radio__border-style': 'solid', - '--hsf-erroralert__font-family': "'PP Formula', sans-serif", - '--hsf-infoalert__font-family': "'PP Formula', sans-serif" + '--hsf-erroralert__font-family': 'var(--font-formula)', + '--hsf-infoalert__font-family': 'var(--font-formula)' } onMounted(() => { diff --git a/apps/website/src/components/product/cloud/HeroSection.vue b/apps/website/src/components/product/cloud/HeroSection.vue index 151d68e182d..c4d97b38c40 100644 --- a/apps/website/src/components/product/cloud/HeroSection.vue +++ b/apps/website/src/components/product/cloud/HeroSection.vue @@ -29,52 +29,47 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="510.823" rx="81.9867" transform="matrix(-0.866025 0.5 -0.866025 -0.5 924.132 890.858)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -86,52 +81,47 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="432.47" rx="48.7555" transform="matrix(-0.866025 0.5 0 1 387.119 24.7041)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -143,52 +133,47 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="432.47" rx="48.7555" transform="matrix(0.866025 0.5 0 1 578.635 23.4051)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -197,28 +182,24 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -226,45 +207,42 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -278,8 +256,7 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() height="326.373" rx="52.0171" transform="matrix(-0.866025 0.5 -0.866025 -0.5 764.39 519.23)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -288,74 +265,69 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -368,13 +340,13 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>()

{{ t('cloud.hero.heading', locale) }}

{{ t('cloud.hero.subtitle', locale) }}

diff --git a/apps/website/src/components/product/local/HeroSection.vue b/apps/website/src/components/product/local/HeroSection.vue index a40f6fd4d74..edc2c1562d3 100644 --- a/apps/website/src/components/product/local/HeroSection.vue +++ b/apps/website/src/components/product/local/HeroSection.vue @@ -187,8 +187,7 @@ onUnmounted(() => { height="491.852" rx="65.5036" transform="matrix(-0.866025 -0.5 0 -1 620.969 1058.01)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" visibility="hidden" /> @@ -200,8 +199,7 @@ onUnmounted(() => { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> { height="371.888" rx="59.4123" transform="matrix(-0.866025 -0.5 0 -1 675.746 878.068)" - class="fill-primary-comfy-ink" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> - + + readFileSync(require.resolve(`@comfyorg/design-system/css/${name}`), 'utf-8') +const brandCss = packageCss('_brand.css') +const paletteCss = packageCss('_palette.css') function token(name: string): string { + const declarations = brandCss + paletteCss const seen = new Set() let current = name while (!seen.has(current)) { seen.add(current) - const declaration = new RegExp(`--${current}:\\s*([^;]+);`).exec(paletteCss) + const declaration = new RegExp(`--${current}:\\s*([^;]+);`).exec( + declarations + ) if (!declaration) { throw new Error(`token --${current} not found in the design system`) } @@ -99,8 +102,34 @@ const toHex = ({ r, g, b }: Rgb) => const isYellow = ({ r, g, b }: Rgb) => r > 200 && g > 200 && b < 200 -const colorsIn = (svg: string) => - svg.replace(/url\([^)]*\)/gi, '').match(COLOR_LITERAL) ?? [] +/* + * A bare colour keyword — `yellow`, `gold` — matches no literal pattern, so a + * scan for literals alone cannot see one and reports the file as clean. Rather + * than enumerate the ~140 CSS names, read the paint attributes directly: what + * they carry is a colour unless it is one of the few non-colour keywords, so + * anything left that does not parse gets reported as unreadable. + */ +const PAINT_ATTR = + /\b(?:fill|stroke|stop-color|flood-color|lighting-color)="([^"]*)"/gi +const NON_COLOR_PAINT = + /^(?:none|transparent|currentcolor|inherit|context-(?:fill|stroke)|url\(.*)$/i + +const IS_COLOR_LITERAL = new RegExp(`^(?:${COLOR_LITERAL.source})$`, 'i') + +const paintKeywordsIn = (svg: string) => + [...svg.matchAll(PAINT_ATTR)] + .map((m) => m[1].trim()) + .filter( + (value) => + value !== '' && + !NON_COLOR_PAINT.test(value) && + !IS_COLOR_LITERAL.test(value) + ) + +const colorsIn = (svg: string) => [ + ...(svg.replace(/url\([^)]*\)/gi, '').match(COLOR_LITERAL) ?? []), + ...paintKeywordsIn(svg) +] function yellowsIn(svg: string): string[] { const yellows = colorsIn(svg) @@ -236,6 +265,31 @@ describe('yellowsIn', () => { ) }) + it('catches a yellow written as a bare colour keyword', () => { + expect( + unreadableColorsIn(``) + ).toEqual(['gold']) + expect(unreadableColorsIn('')).toEqual([ + 'yellow' + ]) + }) + + it('does not report paint keywords that name no colour', () => { + expect( + unreadableColorsIn( + '' + + '' + + `` + ) + ).toEqual([]) + }) + + it('reads paint attributes independently of scan order', () => { + const svg = `` + expect(unreadableColorsIn(svg)).toEqual(unreadableColorsIn(svg)) + expect(yellowsIn(svg)).toEqual([yellow]) + }) + it('does not mistake a url() reference for a color', () => { const gradientRef = '' + @@ -244,3 +298,44 @@ describe('yellowsIn', () => { expect(unreadableColorsIn(gradientRef)).toEqual([]) }) }) + +/* + * The brand layer is only a single source of truth while it is the *only* + * place these tokens are declared. A second declaration anywhere in the + * website's own theme silently wins over the package and is invisible until + * the two values disagree — which is exactly how the yellow drifted. + */ +describe('the brand layer is declared in exactly one place', () => { + const declarationsIn = (css: string) => + new Set( + [...css.matchAll(/^\s*(--(?:color|font)-[\w-]+)\s*:/gm)].map((m) => m[1]) + ) + + const brand = declarationsIn(brandCss) + const palette = declarationsIn(paletteCss) + const website = declarationsIn(read('src/styles/global.css')) + + const overlap = (a: Set, b: Set) => + [...a].filter((name) => b.has(name)).sort() + + it('declares no brand token twice inside the package', () => { + expect(overlap(brand, palette)).toEqual([]) + }) + + it('lets the website add site tokens without shadowing the package', () => { + expect(overlap(website, brand)).toEqual([]) + expect(overlap(website, palette)).toEqual([]) + }) + + it('keeps the brand typeface in the brand layer', () => { + expect(brand.has('--font-formula')).toBe(true) + expect(brand.has('--font-formula-narrow')).toBe(true) + }) + + it('catches a redeclaration', () => { + const shadowed = declarationsIn( + '@theme {\n --color-brand-yellow: #fff;\n}' + ) + expect(overlap(shadowed, brand)).toEqual(['--color-brand-yellow']) + }) +}) diff --git a/apps/website/src/pages/404.astro b/apps/website/src/pages/404.astro index 5ef67ebb82a..f93e4ac85da 100644 --- a/apps/website/src/pages/404.astro +++ b/apps/website/src/pages/404.astro @@ -49,13 +49,12 @@ import BaseLayout from '../layouts/BaseLayout.astro' id="startCta" x="300" y="200" - font-family="'PP Formula', sans-serif" font-size="32" letter-spacing="0.15em" text-anchor="end" dominant-baseline="middle" transform="rotate(-31 400 200)" - class="cursor-pointer uppercase" + class="font-formula cursor-pointer uppercase" >CLICK TO START diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css index b40a6982470..9920ba75e81 100644 --- a/apps/website/src/styles/global.css +++ b/apps/website/src/styles/global.css @@ -1,72 +1,10 @@ -@import 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap'; - @import 'tailwindcss'; @import '@comfyorg/design-system/css/base.css'; @import 'tw-animate-css'; -/* PP Formula's native vertical metrics place the baseline too high, so caps - sit in the upper half of the line box. Overriding ascent/descent re-anchors - the baseline so caps render optically centered when line-height is tight. - BUT, IT IS NOT WELL SUPPORTED: - ascent-override: 92%; - descent-override: 8%; - line-gap-override: 0%; */ -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Light.woff2') format('woff2'); - font-weight: 300; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Regular.woff2') format('woff2'); - font-weight: 400; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Medium.woff2') format('woff2'); - font-weight: 500; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Semibold.woff2') format('woff2'); - font-weight: 600; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Bold.woff2') format('woff2'); - font-weight: 700; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula'; - src: url('/fonts/PPFormula-Bold.woff2') format('woff2'); - font-weight: 800; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'PP Formula Narrow'; - src: url('/fonts/PPFormula-NarrowSemibold.woff2') format('woff2'); - font-weight: 600; - font-style: normal; - font-display: swap; -} - +/* Every brand colour and both brand typefaces come from base.css. Declaring + one here shadows the package and reintroduces the drift this replaced — + add site-specific values only. */ @theme { --color-site-dropdown: #332b38; --color-site-bg-soft: color-mix( @@ -74,26 +12,13 @@ var(--color-primary-comfy-ink) 88%, black 12% ); - /* comfy-ink and comfy-canvas are provided by base.css — never redeclare them */ - --color-primary-comfy-yellow: var(--color-brand-yellow); - --color-primary-comfy-orange: #fabc25; - --color-primary-comfy-ink-light: #2a2330; - --color-primary-warm-white: #f0efed; - --color-primary-warm-gray: #7e7c78; - --color-secondary-mauve: #4d3762; --color-destructive: #f44336; /* Legible on the dark ink surfaces; --color-destructive is too dark there. */ --color-destructive-light: #ffb4a8; - --color-primary-comfy-plum: var(--color-plum-600); - --color-secondary-deep-plum: #2b2040; - --color-secondary-cool-gray: #3c3c3c; - --color-illustration-forest: #20464c; --color-transparency-white-t4: rgb(from var(--color-white) r g b / 0.04); --color-transparency-ink-t80: rgb( from var(--color-primary-comfy-ink) r g b / 0.8 ); - --font-formula: 'PP Formula', sans-serif; - --font-formula-narrow: 'PP Formula Narrow', sans-serif; --text-2xs: 0.6875rem; --text-3\.5xl: 2rem; --text-6\.5xl: 4.125rem; diff --git a/packages/design-system/README.md b/packages/design-system/README.md index 2298c33dd7b..be80e6dab19 100644 --- a/packages/design-system/README.md +++ b/packages/design-system/README.md @@ -32,17 +32,46 @@ For the palette and fonts without the Tailwind layers or icon plugins: ## Exports -| Path | Contents | -| -------------------- | ---------------------------------------------------------- | -| `./css/style.css` | Full theme — palette, fonts, Tailwind layers, icon plugins | -| `./css/base.css` | Palette and fonts only | -| `./css/_palette.css` | Color variables | -| `./css/fonts.css` | Font faces | -| `./icons/*.svg` | Comfy icon set source SVGs | +| Path | Contents | +| ----------------------- | --------------------------------------------------------------- | +| `./css/style.css` | Full theme — brand, palette, app tokens, Tailwind layers, icons | +| `./css/base.css` | Brand surface — brand colors, PP Formula, shared neutral ramps | +| `./css/_brand.css` | Brand colors and brand typeface tokens | +| `./css/_palette.css` | Shared neutral ramps (charcoal, ash, smoke, plum, ink) | +| `./css/brand-fonts.css` | PP Formula `@font-face` declarations | +| `./css/fonts.css` | Inter `@font-face` declarations | +| `./icons/*.svg` | Comfy icon set source SVGs | Icons are exposed to Tailwind as `icon-[comfy--*]` and `icon-mask-[comfy--*]` utilities. Size them with `size-*`, not font-size classes. +## Two design systems, one package + +This package ships both the **company brand system** and the **ComfyUI app +system**. The file a token lives in is what tells them apart — there is no +naming convention that reliably does, and several token names predate the +split. + +| File | System | What belongs here | +| -------------- | ----------- | ----------------------------------------------------------------- | +| `_brand.css` | Brand | Anything the Brand Guidelines define: brand colors, PP Formula | +| `_palette.css` | Shared | Raw neutral ramps both systems build on — no brand values | +| `style.css` | ComfyUI app | Semantic roles, node-editor and PrimeVue tokens, the icon plugins | + +Which entry point you import follows from that. A marketing site or any surface +that carries the brand but not the app imports `base.css`. The app and the +desktop shell import `style.css`, which is `base.css` plus everything product. + +The rule that keeps this true: **a token is declared in exactly one file.** If +you need a brand value on an app surface, import it — do not redeclare it in +`style.css`, and do not redeclare it in a consuming app's own `@theme`. A +second declaration silently wins over the package and is invisible until the +two values disagree, which is how the brand yellow spent months drifting. +`apps/website/src/data/brandColors.test.ts` enforces this. + +Fonts are the one thing the package does not ship: `@font-face` declarations +point at `/fonts/*.woff2`, and each consuming app serves the binaries itself. + ## Consuming tokens Never write out a value this package ships — read it from the package. That diff --git a/packages/design-system/package.json b/packages/design-system/package.json index 184e834c903..15af7e3d993 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -1,6 +1,6 @@ { "name": "@comfyorg/design-system", - "version": "1.0.1", + "version": "1.1.0", "description": "Shared design system for ComfyUI Frontend", "homepage": "https://comfy.org", "license": "MIT", diff --git a/packages/design-system/src/css/_brand.css b/packages/design-system/src/css/_brand.css new file mode 100644 index 00000000000..7247e0ac459 --- /dev/null +++ b/packages/design-system/src/css/_brand.css @@ -0,0 +1,44 @@ +/* + * Brand — the Comfy company brand system. + * + * Every brand colour and typeface is declared here, once, for every surface + * that carries the brand: comfy.org, platform.comfy.org, the app and the + * desktop shell. Nothing here is app-specific; nothing app-specific belongs + * here. Product tokens (node editor, PrimeVue, semantic roles) live in + * style.css, and the shared neutral ramps live in _palette.css. + * + * Source of truth: Brand Guidelines 2026. + */ + +@theme { + /* Core brand colours */ + --color-electric-400: #f2ff59; + --color-sapphire-700: #172dd7; + + /* Primary */ + --color-primary-comfy-ink: #211927; + --color-primary-comfy-ink-light: #2a2330; + --color-primary-comfy-canvas: #c2bfb9; + --color-primary-comfy-orange: #fabc25; + --color-primary-warm-white: #f0efed; + --color-primary-warm-gray: #7e7c78; + + /* Secondary */ + --color-secondary-mauve: #4d3762; + --color-secondary-deep-plum: #2b2040; + --color-secondary-cool-gray: #3c3c3c; + + /* Illustration */ + --color-illustration-forest: #20464c; + + /* Named aliases */ + --color-brand-yellow: var(--color-electric-400); + --color-brand-blue: var(--color-sapphire-700); + --color-primary-comfy-yellow: var(--color-brand-yellow); + --color-primary-comfy-plum: var(--color-plum-600); + + /* Brand typefaces. The app bundles only three PP Formula weights + (src/platform/cloud/onboarding/assets), so Inter backs the rest. */ + --font-formula: 'PP Formula', 'Inter', sans-serif; + --font-formula-narrow: 'PP Formula Narrow', sans-serif; +} diff --git a/packages/design-system/src/css/_palette.css b/packages/design-system/src/css/_palette.css index 299ccbe99b2..576aad1ae4e 100644 --- a/packages/design-system/src/css/_palette.css +++ b/packages/design-system/src/css/_palette.css @@ -1,7 +1,6 @@ @theme { /* Font Families */ --font-inter: 'Inter', sans-serif; - --font-formula: 'PP Formula', 'Inter', sans-serif; /* Palette Colors */ --color-transparency-white-t8: rgb(255 255 255 / 0.08); @@ -53,12 +52,4 @@ --color-white: #ffffff; --color-black: #000000; - - /* Brand Colors */ - --color-electric-400: #f2ff59; - --color-sapphire-700: #172dd7; - --color-primary-comfy-ink: #211927; - --color-primary-comfy-canvas: #c2bfb9; - --color-brand-yellow: var(--color-electric-400); - --color-brand-blue: var(--color-sapphire-700); } diff --git a/packages/design-system/src/css/base.css b/packages/design-system/src/css/base.css index 04548f2b3c3..b8d78ca65ea 100644 --- a/packages/design-system/src/css/base.css +++ b/packages/design-system/src/css/base.css @@ -1,8 +1,13 @@ /* - * Design System Base — Brand tokens + fonts only. - * For marketing sites that don't use PrimeVue or the node editor. - * Import the full style.css instead for the desktop app. + * Design System Base — the brand surface. + * Brand colours, the brand typeface, and the shared neutral ramps. No PrimeVue, + * no node editor, no icon plugins. This is what marketing sites import. + * Import the full style.css instead for the app and the desktop shell. + * + * Inter is not here: it is the app's UI typeface, and the brand surfaces do not + * serve its woff2 files. style.css loads it from fonts.css. */ -@import './fonts.css'; +@import './_brand.css'; +@import './brand-fonts.css'; @import './_palette.css'; diff --git a/packages/design-system/src/css/brand-fonts.css b/packages/design-system/src/css/brand-fonts.css new file mode 100644 index 00000000000..1eb51f6fede --- /dev/null +++ b/packages/design-system/src/css/brand-fonts.css @@ -0,0 +1,61 @@ +/* + * PP Formula — the brand typeface. Declarations only: the package never ships + * font binaries, so each consuming app serves the woff2 files from its own + * public/fonts. Imported by base.css (brand surfaces); the app loads Inter + * from fonts.css instead. + * + * PP Formula's native vertical metrics place the baseline too high, so caps + * sit in the upper half of the line box. Overriding ascent/descent would + * re-anchor it, but support is too thin to rely on: + * ascent-override: 92%; + * descent-override: 8%; + * line-gap-override: 0%; + */ + +@font-face { + font-family: 'PP Formula'; + src: url('/fonts/PPFormula-Light.woff2') format('woff2'); + font-weight: 300; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'PP Formula'; + src: url('/fonts/PPFormula-Regular.woff2') format('woff2'); + font-weight: 400; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'PP Formula'; + src: url('/fonts/PPFormula-Medium.woff2') format('woff2'); + font-weight: 500; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'PP Formula'; + src: url('/fonts/PPFormula-Semibold.woff2') format('woff2'); + font-weight: 600; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'PP Formula'; + src: url('/fonts/PPFormula-Bold.woff2') format('woff2'); + font-weight: 700; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'PP Formula Narrow'; + src: url('/fonts/PPFormula-NarrowSemibold.woff2') format('woff2'); + font-weight: 600; + font-style: normal; + font-display: swap; +} diff --git a/packages/design-system/src/css/style.css b/packages/design-system/src/css/style.css index 1858267fc87..8546389a092 100644 --- a/packages/design-system/src/css/style.css +++ b/packages/design-system/src/css/style.css @@ -1,6 +1,7 @@ @layer theme, base, primevue, components, utilities; @import './fonts.css'; +@import './_brand.css'; @import './_palette.css'; @import 'tailwindcss/theme' layer(theme); @import 'tailwindcss/utilities' layer(utilities); @@ -219,8 +220,6 @@ /* Semantic tokens - light mode */ --muted-foreground: var(--color-charcoal-200); --base-foreground: var(--color-charcoal-800); - --brand-yellow: var(--color-electric-400); - --brand-blue: var(--color-sapphire-700); --secondary-background: var(--color-smoke-200); --secondary-background-hover: var(--color-smoke-400); --secondary-background-selected: var(--color-smoke-600); @@ -374,8 +373,6 @@ /* Semantic tokens - dark mode */ --muted-foreground: var(--color-smoke-800); --base-foreground: var(--color-white); - --brand-yellow: var(--color-electric-400); - --brand-blue: var(--color-sapphire-700); --secondary-background: var(--color-charcoal-600); --secondary-background-hover: var(--color-charcoal-400); --secondary-background-selected: var(--color-charcoal-200); @@ -573,8 +570,6 @@ --color-border-subtle: var(--border-subtle); --color-muted-background: var(--muted-background); --color-accent-background: var(--accent-background); - --color-brand-yellow: var(--brand-yellow); - --color-brand-blue: var(--brand-blue); } @custom-variant dark-theme { From 5e1c8eaf42f61c5103065d514d51013f5e0f2300 Mon Sep 17 00:00:00 2001 From: Amp Date: Wed, 2 Sep 2026 05:08:18 +0000 Subject: [PATCH 14/14] test(website): drop removed desktop brand asset --- apps/website/src/data/brandColors.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/website/src/data/brandColors.test.ts b/apps/website/src/data/brandColors.test.ts index bdb21fc1957..85f98a476a9 100644 --- a/apps/website/src/data/brandColors.test.ts +++ b/apps/website/src/data/brandColors.test.ts @@ -55,7 +55,6 @@ const yellowSvgs = [ 'apps/website/public/affiliates/brand/comfy-full-logo-yellow.svg', 'apps/website/public/affiliates/brand/comfy-color-combo-yellow.svg', 'apps/website/public/affiliates/brand/comfy-amplified-logo-mark.svg', - 'apps/desktop-ui/public/assets/images/comfy-brand-mark.svg', 'public/assets/images/comfy-cloud-logo.svg' ]