Repository navigation
feat(ui): white-label brand palette for the embedded widget - #23
Merged
Merged
Conversation
Tiny color lib (HSL conversion + a11y contrast plugin) used by the brand-palette generator to derive NextUI CSS-var scales at runtime. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
buildScale derives a NextUI color scale from a single seed hex — seed as DEFAULT, 10..900 following the hand-tuned TEAL lightness ladder at the seed's hue/saturation, WCAG-picked foreground. applyPalette writes the HSL-channel CSS vars onto a root element, mode-aware (light uses the seed; dark lightens + desaturates so a dark brand color stays visible), with the background override scoped to light mode. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
useTheme now reads/writes/observes a configurable root (default <html>) instead of always mutating document.documentElement. setThemeRoot points it at the widget wrapper so the embedded widget never touches the host page's <html>; live subscriptions re-observe the new root. Adds getInitialTheme for a flash-free first paint and hardens the stored-value read against garbage. Standalone behavior is unchanged. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Drop the teal<->orange swap so dark mode keeps the brand hue (primary stays teal, secondary stays orange) and a tenant's color reads the same in both modes. Stop overriding `danger` with the orange secondary; let NextUI's built-in red stand as a fixed status hue, independent of the brand palette (the runtime override never touches danger). Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
BrandTheme renders above the Suspense boundary and paints the resolved palette (per-embed prop ?? client record ?? default, per role) onto the theme root as NextUI CSS vars before first paint. The client record's color1/2/3 map to primary/secondary/background and merge in once the ['client'] query resolves (sharing AppRouter's fetch); the mode-aware DEFAULT/foreground re-applies on a light/dark flip. Wired into App inside Providers so it also themes the loading fallback. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add primaryColor/secondaryColor/backgroundColor to WidgetProps and the r2wc props map (settable as primary-color/etc. attributes). Wrap <App> in a display:contents element that owns the theme class + brand CSS vars, and hand its ref + palette to App/BrandTheme. The wrapper carries the initial theme class synchronously (getInitialTheme) instead of mutating the host page's <html>, so the embed never touches the host document. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Move the PaletteRoles type import to the top group to satisfy import/order. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A fixed switcher in the global decorator applies tenant presets (maroon / shrimataji, green / sahajayoga, default teal) to the story wrapper via the production applyPalette, re-applying on light/dark flips so every atom and molecule can be previewed in any brand palette. Closes #16 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- palette.ts: setRole reuses buildScale's DEFAULT/foreground (drops the recompute + the unknown-cast loop); background seed parsed once; fix the darkTone comment to match the unconditional clamp. - use-theme.ts: export getThemeRoot as the single source for "what is the theme root"; BrandTheme paints onto it instead of re-deriving the document.documentElement fallback. - config/api: add a clientQuery factory so AppRouter's suspense read and BrandTheme's non-suspense read share one key + fetcher (no drift). - App: clarify that theming is app-wide; only the wrapper scoping is widget-only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
applyPalette now clears the NextUI vars it manages before layering on the supplied roles, so a role dropped between applies — or an invalid value — falls back to the static theme instead of leaving a stale override, and an invalid background fails closed. Drops the Ladle switcher's removeAttribute workaround (now redundant) and covers the drop-a-role case with a test. Addresses /code-review (low) + /security-review (SEC-2). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
BrandTheme now derives light/dark from the resolved theme root's own class rather than the useTheme snapshot, which on the widget's first paint can still reflect <html> (before the wrapper is adopted) and would paint a dark wrapper in light tones. Also releases the module-level theme root on unmount so a torn-down embed stops owning it and its detached wrapper can be GC'd. Addresses /code-review (medium x2) + /security-review (SEC-1). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
NextUI overlays portal to document.body, outside the brand-themed wrapper, so embedded-widget overlays don't inherit the wrapper-scoped vars/class. Record the fix path (per-overlay portalContainer) at the provider site. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying atlas-legacy with
|
| Latest commit: |
97b39cd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3a5ed7cc.syatlas.pages.dev |
| Branch Preview URL: | https://feat-brand-palette.syatlas.pages.dev |
A very saturated seed (e.g. the sahajayoga green at ~96% sat) generated neon shades — unreadable as tinted text and clashing with the otherwise muted UI (teal ~23%, orange ~63%). Cap generated saturation at 60% so vivid seeds are toned down while teal/orange/maroon pass through ~unchanged; hue and lightness are preserved. Verified in Ladle across all three presets. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
9 tasks
Replace the saturation cap (a bandaid) with the root fix: the generator now takes ONLY the input hue and applies a fixed saturation (60%) over the lightness ladder, so every brand hue yields the same consistent, readable range — in the spirit of Radix's color scales — regardless of how saturated or light the seed was. A neon seed and a muted one at the same hue produce the identical scale; the DEFAULT solid sits at the 400 step (a lighter step in dark mode). Matches how the built-in ramps are built (constant saturation over a lightness ladder). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Update the palette switcher presets to the actual tenant brand colors and label them by domain: wemeditate.com (default), shrimataji.org (#64032E / #AF94A3 on cream), sahajayoga.org (#62834B / #5D6F44). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Set shrimataji.org secondary to #A11F0C and prefix every switcher option with "palette: " for clarity. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Set sahajayoga.org to primary #5D6F44 (green) / secondary #D47B2C (orange). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
initTheme now delegates to getInitialTheme so the persisted-or-default precedence rule lives in one place. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A near-achromatic seed (e.g. charcoal #333) has no meaningful hue — colord reports h=0 — so pinning it to the fixed 60% saturation rendered it as a vivid red. Below a small saturation threshold the seed's own low saturation now passes through, so neutrals stay neutral while chromatic seeds keep the consistent hue-only treatment. Addresses /code-review (medium). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Hue-only generation flattened dark brands — sahajayoga.org's dark green rendered as a medium green, and muted seeds were pushed to full saturation. Generate from the seed's hue AND lightness instead, capping saturation at 60% as the only normalization: a vivid/neon seed is tamed to the muted register, while dark or muted (or neutral) seeds pass through. The cap subsumes the explicit neutral-seed guard. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The active pagination bullet was stuck on the default theme color because --swiper-theme-color was declared on :root, where the widget's brand override (set on the wrapper) isn't present. Move it onto .swiper so it resolves the brand primary, and set inactive bullets to the theme foreground (was a fixed black, invisible on the dark canvas). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Dark mode already lifts a too-dark seed so it stays visible on the dark canvas; add the mirror — cap the solid's lightness in light mode so a near-white brand seed isn't an invisible bg-primary on the light page. The cap (70) is above every real brand color, so it only affects pathological pale seeds. Addresses /code-review (medium). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
34 tasks
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
Lets each host site render
<syatlas-map>in its own brand colors from a singleembed snippet, without changing the default build.
primary-color/secondary-color/background-color, or the client record'scolor1/2/3). A generator derives a NextUI color scale and writes the--nextui-*HSL-channel CSS vars inline on the widget's own wrapper,repainting chips, buttons, links, active nav, panels, and the carousel pills.
prop ?? client-record ?? built-in default. With nopalette supplied, nothing runs and today's teal/orange build is unchanged.
its wrapper and never mutates the host page's
<html>.Generation model
The scale respects the seed's hue and lightness, and caps saturation at 60%.
Capping is the one normalization — a vivid/neon seed is pulled into the muted
brand register so its tints don't read as glaring — while dark, muted, and
neutral seeds pass through faithfully (so e.g. sahajayoga's dark olive green
stays dark and muted, not a flat medium green). The DEFAULT solid is the brand
color itself, lifted to a visible tone in dark mode (and capped against
near-white on the light canvas — a symmetric guard). The 10…900 tints walk a
fixed lightness ladder; the background override is the tenant's literal surface
color (light mode only). Brand seeds are expected as hex.
Changes
src/config/theme/palette.ts(+test) —buildScale/applyPalette; hue +lightness respected, saturation capped; clears managed vars before each apply.
src/config/theme/BrandTheme.tsx— resolves + paints the palette above theSuspense boundary, merges the client record, re-applies on light/dark flip,
releases the theme root on unmount.
src/hooks/use-theme.ts— configurable theme root (setThemeRoot/getThemeRoot) so the widget scopes theming to its wrapper;getInitialTheme.src/Widget.tsx— color props + r2wc map; adisplay:contentswrapper.src/config/api/index.ts—clientQueryfactory shared by AppRouter + BrandTheme.tailwind.config.js— dark mode keeps the brand hue;danger→ NextUI red.src/styles/globals.css— scope--swiper-theme-colorto.swiperso thecarousel's active pill follows the brand primary (was stuck on the default),
and key inactive pills to the theme foreground so they're visible in both modes.
.ladle/components.tsx— palette switcher (wemeditate.com / shrimataji.org /sahajayoga.org).
colordadded for the color math.Verification
pnpm test:run) · Build ✓ · Ladle ✓repaint with readable foregrounds (sahajayoga stays a dark muted green, shrimataji
a deep maroon), dark mode keeps a visible tone, the cream background applies in
light only,
dangerstays NextUI red, carousel pills follow the brand and stayvisible in dark mode, and the host
<html>is never mutated./simplify+/code-review(high) +/security-reviewacross three rounds;all findings triaged.
Notes for reviewer
color1/2/3(already on the client record, previouslyunused) rather than adding new inert fields — client-record theming works today.
primaryis teal-ish instead of orange, anddangershifts from orange toNextUI's red. Light-mode brand surfaces unchanged.
to
document.body, outside the wrapper, so embedded-widget overlays don'tinherit the wrapper-scoped vars/class. No global
portalContaineronNextUIProvider; per-overlayportalContainer→ the wrapper is the fix. Out ofscope here (and not live-verifiable — dev client key 403s), deferred to refactor(ui): migrate components from NextUI to Radix UI #22 and
noted in
providers.tsx.colord(numericchannel strings,
isValid()-gated) — verified against hostile inputs. Brandseeds are hex-only (named CSS colors fail closed to the default).
Closes #16
🤖 Generated with Claude Code