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/AGENTS.md b/AGENTS.md index 333ada868eb..99eaff8b355 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 write out a design-system value — consume the token + - `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/components/common/HubspotFormEmbed.vue b/apps/website/src/components/common/HubspotFormEmbed.vue index f1c7891d3f6..79915a85198 100644 --- a/apps/website/src/components/common/HubspotFormEmbed.vue +++ b/apps/website/src/components/common/HubspotFormEmbed.vue @@ -18,30 +18,30 @@ 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__color': '#c2bfb9', - '--hsf-background__background-color': '#211927', + '--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': '#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-heading__font-family': "'PP Formula', sans-serif", - '--hsf-heading__color': '#c2bfb9', - '--hsf-field-label__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': 'var(--font-formula)', + '--hsf-heading__color': 'var(--color-primary-comfy-canvas)', + '--hsf-field-label__font-family': 'var(--font-formula)', '--hsf-field-label__font-size': '12px', - '--hsf-field-label__color': '#c2bfb9', - '--hsf-field-description__font-family': "'PP Formula', sans-serif", - '--hsf-field-description__color': '#c2bfb9', - '--hsf-field-footer__font-family': "'PP Formula', sans-serif", - '--hsf-field-footer__color': '#c2bfb9', - '--hsf-field-input__font-family': "'PP Formula', sans-serif", - '--hsf-field-input__color': '#c2bfb9', + '--hsf-field-label__color': 'var(--color-primary-comfy-canvas)', + '--hsf-field-description__font-family': 'var(--font-formula)', + '--hsf-field-description__color': 'var(--color-primary-comfy-canvas)', + '--hsf-field-footer__font-family': 'var(--font-formula)', + '--hsf-field-footer__color': 'var(--color-primary-comfy-canvas)', + '--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', '--hsf-field-input__border-color': '#3b3539', @@ -49,8 +49,8 @@ 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__color': '#c2bfb9', + '--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', '--hsf-field-textarea__border-color': '#3b3539', @@ -58,18 +58,18 @@ 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', '--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 1426cfa3789..c4d97b38c40 100644 --- a/apps/website/src/components/product/cloud/HeroSection.vue +++ b/apps/website/src/components/product/cloud/HeroSection.vue @@ -29,56 +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)" - fill="#211927" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -90,56 +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)" - fill="#211927" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -151,56 +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)" - fill="#211927" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -209,28 +182,24 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -238,45 +207,42 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -290,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)" - fill="#211927" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> @@ -300,74 +265,69 @@ const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -380,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 ea552f71c88..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)" - fill="#211927" - 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)" - fill="#211927" - 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)" - fill="#211927" - 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)" - fill="#211927" - stroke="#4D3762" + class="fill-primary-comfy-ink stroke-secondary-mauve" stroke-width="3" /> - + { { { diff --git a/apps/website/src/composables/useHeroLogo.ts b/apps/website/src/composables/useHeroLogo.ts index 6ed12fb04c2..9721b785056 100644 --- a/apps/website/src/composables/useHeroLogo.ts +++ b/apps/website/src/composables/useHeroLogo.ts @@ -4,6 +4,8 @@ import { onMounted, onUnmounted, ref } from 'vue' import * as THREE from 'three' import { SVGLoader } from 'three/addons/loaders/SVGLoader.js' +import { readDesignToken } from '@comfyorg/shared-frontend-utils/designTokens' + import { prefersReducedMotion } from './useReducedMotion' const IMAGE_COUNT = 16 @@ -17,7 +19,7 @@ interface HeroLogoConfig { tiltZ: number zoom: number fov: number - logoColor: string + logoColor?: string extrudeDepth: number cursorTiltStrength: number bgScale: number @@ -36,7 +38,6 @@ const DEFAULTS: HeroLogoConfig = { tiltZ: -0.1, zoom: 7, fov: 50, - logoColor: '#F2FF59', extrudeDepth: 200, cursorTiltStrength: 0.5, bgScale: 0.8, @@ -207,7 +208,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..85f98a476a9 --- /dev/null +++ b/apps/website/src/data/brandColors.test.ts @@ -0,0 +1,340 @@ +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 packageCss = (name: string) => + 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( + declarations + ) + 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, '..', '..') +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', + '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 + g: number + b: number +} + +const COLOR_LITERAL = + /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|(?:ok)?l(?:ab|ch)|color|color-mix)\([^)]*\)/gi + +function parseColor(literal: string): Rgb | undefined { + const hex = /^#([0-9a-f]{3,8})$/i.exec(literal) + if (hex) { + const digits = hex[1] + const rrggbb = + digits.length === 3 || digits.length === 4 + ? digits.slice(0, 3).replace(/./g, '$&$&') + : digits.length === 6 || digits.length === 8 + ? digits.slice(0, 6) + : undefined + 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) + 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 + +/* + * 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) + .map(parseColor) + .filter((color): color is Rgb => color !== undefined && isYellow(color)) + .map(toHex) + return [...new Set(yellows)].sort() +} + +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 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 colors that cannot reference a token', () => { + it('the /brand palette table matches the design system', () => { + const expected: Record = { + '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') + } + + 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 color of brandColors) { + const hex = color.hex.replace('#', '') + const fromHex = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16)) + const declared = color.rgb.split(',').map((n) => Number(n.trim())) + expect(declared, `${color.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-brand-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', () => { + 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') + + for (const file of inkSvgs) { + const svg = readRepo(file).toLowerCase() + expect(svg, `${file} should use ${ink}`).toContain(ink) + } + }) +}) + +describe('yellowsIn', () => { + const yellow = token('color-brand-yellow') + 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 retired yellow written as rgb()', () => { + expect( + yellowsIn(``) + ).toEqual([yellow, retiredYellow].sort()) + }) + + it('catches a retired yellow written as 8-digit hex', () => { + expect( + yellowsIn(``) + ).toEqual([yellow, retiredYellow].sort()) + }) + + it('ignores colors outside the yellow family', () => { + expect( + yellowsIn(``) + ).toEqual([yellow]) + }) + + it('reports a color syntax it cannot read rather than ignoring it', () => { + expect(unreadableColorsIn('')).toEqual([ + 'hsl(65 100% 67%)' + ]) + expect(unreadableColorsIn(``)).toEqual([]) + }) + + it('reports a malformed hex literal as unreadable', () => { + expect(unreadableColorsIn('')).toEqual(['#12345']) + expect(yellowsIn('')).toEqual([]) + }) + + it('finds nothing in markup that carries no color', () => { + expect(yellowsIn('')).toEqual([]) + expect(unreadableColorsIn('')).toEqual([]) + expect(yellowsIn('')).toEqual( + [] + ) + expect(unreadableColorsIn('')).toEqual( + [] + ) + }) + + 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 = + '' + + `` + expect(yellowsIn(gradientRef)).toEqual([yellow]) + 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 9fff35c63c6..f93e4ac85da 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"> - - - - - - - + + + + + + +

@@ -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/scripts/snakeGame.ts b/apps/website/src/scripts/snakeGame.ts index 224d0fe046d..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,16 +36,12 @@ const LIFT = HEX_H * 0.35 const TICK_MS = 200 function readColors() { - const style = getComputedStyle(document.documentElement) - const get = (name: string, fallback: string): string => - style.getPropertyValue(name).trim() || fallback - 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: 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/styles/global.css b/apps/website/src/styles/global.css index c0b51ac5c2c..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,27 +12,13 @@ var(--color-primary-comfy-ink) 88%, black 12% ); - --color-primary-comfy-yellow: #f2ff59; - --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-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); - --font-formula: 'PP Formula', sans-serif; - --font-formula-narrow: 'PP Formula Narrow', sans-serif; + --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 + ); --text-2xs: 0.6875rem; --text-3\.5xl: 2rem; --text-6\.5xl: 4.125rem; @@ -496,7 +420,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 { diff --git a/apps/website/src/templates/brand/BrandBackground.vue b/apps/website/src/templates/brand/BrandBackground.vue index 94b63a162b0..52ac0bf9f37 100644 --- a/apps/website/src/templates/brand/BrandBackground.vue +++ b/apps/website/src/templates/brand/BrandBackground.vue @@ -6,6 +6,8 @@ import { } from '@vueuse/core' import { onMounted, ref } from 'vue' +import { readDesignTokenRgba } from '@comfyorg/shared-frontend-utils/designTokens' + import { prefersReducedMotion } from '../../composables/useReducedMotion' interface Node { @@ -28,6 +30,8 @@ const nodes: Node[] = Array.from({ length: 14 }, () => ({ })) let ctx: CanvasRenderingContext2D | null = null +let linkColor = '' +let nodeColor = '' function draw() { const el = canvasEl.value @@ -43,7 +47,7 @@ function draw() { if (n.y < 0 || n.y > 1) n.vy *= -1 } - ctx.strokeStyle = 'rgba(242, 255, 89, 0.18)' + ctx.strokeStyle = linkColor ctx.lineWidth = dpr const max = Math.min(w, h) * 0.22 for (let i = 0; i < nodes.length; i++) { @@ -65,7 +69,7 @@ function draw() { } ctx.globalAlpha = 1 - ctx.fillStyle = 'rgba(242, 255, 89, 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) @@ -99,6 +103,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() }) 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/packages/design-system/README.md b/packages/design-system/README.md index 743668e0029..be80e6dab19 100644 --- a/packages/design-system/README.md +++ b/packages/design-system/README.md @@ -32,17 +32,86 @@ 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 +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/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 0974d7baa72..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,10 +52,4 @@ --color-white: #ffffff; --color-black: #000000; - - /* Brand Colors */ - --color-electric-400: #f0ff41; - --color-sapphire-700: #172dd7; - --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 60300b08537..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); @@ -67,8 +68,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; @@ -221,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); @@ -376,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); @@ -575,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 { 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/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)
diff --git a/src/components/ui/chart/useChart.ts b/src/components/ui/chart/useChart.ts index ec641cef94c..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,15 +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') || '#ffffff' - const muted = getCssVar('--color-muted-foreground') || '#8a8a8a' + 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, @@ -52,7 +48,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 +83,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 +96,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;