Skip to content

feat(platform): derive the branded palette from a single accent color - #2538

Merged
yannickmonney merged 2 commits into
mainfrom
improvement/accent-color-palette-1960
Jul 7, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
improvement/accent-color-palette-1960

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Summary

Drops the two-field brand/accent contract: one accent color is now the single source of truth, and the whole branded palette is derived from it per theme. Builds on #2483 (which wired the brand color into the primary-button token) and supersedes it per the issue.

Palette derivation (lib/utils/color.ts → deriveAccentPalette)

  • base — the accent adjusted per theme via the existing adjustColorForTheme (≥3:1 against the theme background, WCAG 1.4.11).
  • fg — the ink (#030712/#ffffff, the design system's own accent-fg values) chosen by real contrast ratio, replacing the isLightColor luminance guess; when the better ink still misses the 4.5:1 AA text target, base's lightness is nudged away from the ink until it clears — never trading away the 3:1 background floor.
  • mutedHsl — the accent hue at half saturation with the default --primary-muted lightness per theme.
  • The provider injects the palette into both token vocabularies: --primary, --primary-foreground, --primary-muted, --ring (legacy HSL) and --color-accent-base, --color-accent-fg (canonical @tale/ui, what the primary Button consumes). Nav/tab/mobile highlights keep reading the theme-adjusted accent from the branding context.
  • Bonus root-cause fix the new tests exposed: adjustColorForTheme never entered its walk when lightness started at 0/100 — pure black stayed invisible (1.06:1) on the dark theme.

Migration story (graceful, reversible)

  • brandingFormSchema and the save/read actions drop brandColor; brandingJsonSchema keeps it as a documented read-only legacy field, and readers (readBranding, the pptx branding context) coalesce accentColor || brandColor — so an unmigrated file's saved color keeps its effect immediately.
  • New versioned node migration 0.3.4/01_branding_single_accent_color (fs-tree snapshot, reversible, registered in ALL_META + NODE_MIGRATIONS): per org, an explicitly-set accentColor wins (it was the field with a visible effect pre-fix(platform): apply brand color to primary-action button token #2483), otherwise the saved brandColor becomes the accentColor; the key is dropped either way. down restores the branding directory byte-for-byte from the snapshot. Idempotent; corrupt files are logged and left untouched.
  • The config-fingerprint guard classifies the form-schema field removal as data-safe, so the committed snapshot baseline is unchanged.

Ripple

  • Branding form shows a single Accent color picker; preview drives wordmark + nav + tabs from it; brandColor removed from en/de/fr locales; e2e settings-depth.spec.ts and the manual settings checklist updated.

Test plan

  • lib/utils/color.test.ts — palette legibility across 8 hostile picks × both themes (base ≥3:1 vs background, ink ≥4.5:1 on base), ink-by-contrast cases, muted-hue cases; observed red on the boundary bug, green after the fix.
  • branding-provider.test.tsx — all six tokens injected from one accent; nothing injected without one; stale legacy brandColor payload ignored.
  • migration.test.ts — merge rules (lone brandColor, both set, empty-string accent), no-file no-op, idempotency, corrupt-file skip, up/down round-trip on a real temp fs.
  • bun run test (server+pii: 702 files / 74886 tests) and the full client project (436 files / 3145 tests) green.
  • bun run --filter @tale/platform typecheck, bun run lint, bun run lint:sast, bun run format clean.
  • bun run migrations:check green (25 folders registered; schema/config snapshots match baseline).

Acceptance criteria (#1960)

  • Only an accent color is configurable.
  • Picking a poor color still yields a legible palette in both themes (incl. the pure-black/white edge the old walk missed).
  • Existing orgs migrate cleanly — coalescing read + on-disk migration; no saved color silently disappears.

Caveats

  • Live browser verification wasn't run in this environment; behaviour is observed via the jsdom provider test (real CSSOM setProperty calls) and the token consumption is source-verified in globals.css. The existing e2e spec covers the accent field round-trip.
  • Focus rings (--ring) now tint to the accent — intentional (globals.css keys the ring to the accent-base intent color); the injected base is guaranteed ≥3:1 against the theme background.

Closes #1960

Drop the two-field brand/accent contract (#1960): one accent color now
drives the whole derived palette in both themes. deriveAccentPalette
normalizes any pick — base clears the 3:1 non-text floor, the ink is
chosen by real contrast ratio and nudged to the 4.5:1 AA text target,
and a muted shade keeps the accent hue. The provider injects --primary,
--primary-foreground, --primary-muted, --ring, --color-accent-base and
--color-accent-fg from that palette. brandColor stays a read-only
legacy field in the JSON schema so unmigrated files coalesce it into
accentColor; saves never write it. Also fixes adjustColorForTheme never
walking when lightness starts at a 0/100 boundary (pure black stayed
invisible on the dark theme).
Versioned node migration 0.3.4/01 (fs-tree snapshot, reversible): for
each org's branding.json, keep an explicitly-set accentColor, otherwise
promote the legacy brandColor value, and drop the brandColor key. down
restores the pre-migration branding directory byte-for-byte. Idempotent
per org; corrupt files are logged and left untouched.
@yannickmonney
yannickmonney merged commit 35c9f17 into main Jul 7, 2026
30 of 31 checks passed
@yannickmonney
yannickmonney deleted the improvement/accent-color-palette-1960 branch July 7, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: Drop "brand color" — derive the whole palette from a single accent color

1 participant