Repository navigation
feat(platform): derive the branded palette from a single accent color - #2538
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)adjustColorForTheme(≥3:1 against the theme background, WCAG 1.4.11).#030712/#ffffff, the design system's own accent-fg values) chosen by real contrast ratio, replacing theisLightColorluminance 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.--primary-mutedlightness per theme.--primary,--primary-foreground,--primary-muted,--ring(legacy HSL) and--color-accent-base,--color-accent-fg(canonical@tale/ui, what the primaryButtonconsumes). Nav/tab/mobile highlights keep reading the theme-adjusted accent from the branding context.adjustColorForThemenever entered its walk when lightness started at 0/100 — pure black stayed invisible (1.06:1) on the dark theme.Migration story (graceful, reversible)
brandingFormSchemaand the save/read actions dropbrandColor;brandingJsonSchemakeeps it as a documented read-only legacy field, and readers (readBranding, the pptx branding context) coalesceaccentColor || brandColor— so an unmigrated file's saved color keeps its effect immediately.0.3.4/01_branding_single_accent_color(fs-tree snapshot, reversible, registered inALL_META+NODE_MIGRATIONS): per org, an explicitly-setaccentColorwins (it was the field with a visible effect pre-fix(platform): apply brand color to primary-action button token #2483), otherwise the savedbrandColorbecomes theaccentColor; the key is dropped either way.downrestores the branding directory byte-for-byte from the snapshot. Idempotent; corrupt files are logged and left untouched.Ripple
brandColorremoved from en/de/fr locales; e2esettings-depth.spec.tsand 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 legacybrandColorpayload 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 formatclean.bun run migrations:checkgreen (25 folders registered; schema/config snapshots match baseline).Acceptance criteria (#1960)
Caveats
setPropertycalls) and the token consumption is source-verified inglobals.css. The existing e2e spec covers the accent field round-trip.--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