Repository navigation
Closed
Description
Summary
Let each host site render <syatlas-map> in its own brand colors from a single
embed snippet, so the widget feels native on shrimataji.org, sahajayoga.org, and
future tenants. Today the palette is hardcoded in tailwind.config.js (the
wemeditate teal/orange) and baked into the build. This adds runtime theming by
overriding NextUI's CSS variables on a widget-root wrapper, driven by a palette
resolved as prop ?? client-record field ?? built-in default. When no palette is
supplied the build output and appearance are unchanged.
Sampled tenant palettes (live, June 2026): shrimataji #64032E/#7A404E on cream
#F0ECE2; sahajayoga #468503/#4C6539 on white; wemeditate #82B1AE/#E08E79
(current default).
Proposed changes
- Palette generator — new
src/config/theme/palette.ts(+palette.test.ts):buildScale(seedHex)→{ DEFAULT, '10', '50'…'900', foreground }as HSL-channel
strings (e.g."178 18% 60%"), mirroring the existing teal ramp's per-step
lightness so generated scales match today's visual weight. Foreground picked
black/white by WCAG contrast (colorda11y).applyPalette(rootEl, { primary?, secondary?, background? }, mode)sets
--nextui-<token>-<shade>inline onrootEl; mode-aware DEFAULT + foreground
(light → ~500–600 step, dark → ~200–300 step). No-ops for omitted roles.
- Dependency — add
colord+a11yplugin. - Resolve + apply — new
src/config/theme/BrandTheme.tsx: holds the wrapper ref,
applies prop palette immediately at mount (themes the loading fallback), merges the
client-record palette once['client', apiKey]resolves (prop wins), and reapplies
DEFAULT/foreground on light/dark flip. - Widget props —
src/Widget.tsx: addprimaryColor/secondaryColor/
backgroundColortoWidgetPropsand ther2wcprops map; render a wrapper<div>
that owns thelight/darkclass + brand vars, wrapping<App>. - Scope the theme root —
src/hooks/use-theme.ts: target a configurable root
(defaultdocument.documentElementstandalone; the widget wrapper when embedded)
instead of always mutating the host page's<html>. - Drop the swap + stabilize danger —
tailwind.config.js: darkprimarykeeps the
brand hue (no flip to secondary);dangerbecomes a fixed warning hue independent of
the tenant's secondary. - Server field —
src/types/client.ts: extendClientSchemawith optional/nullable
primaryColor/secondaryColor/backgroundColor. Forward-compatible; inert until
the SahajCloud backend returns them. Consumed where the client is already read
(src/App.tsx:52). - Ladle preview —
.ladle/components.tsx: palette switcher (teal/default,
maroon/shrimataji, green/sahajayoga) calling the sameapplyPaletteon the story
wrapper.
Acceptance criteria
-
<syatlas-map primaryColor="#64032E" secondaryColor="#7A404E">repaints chips,
buttons, links, active nav, and panels in maroon with readable foregrounds; the
green set does likewise. - Per-embed props override the client-record palette; client-record palette applies
when no prop is set; built-in teal/orange default when neither is set. - Dark mode keeps the tenant hue at a lighter/desaturated tone with readable
contrast (no vanishing primary); the tenant background override applies to light
mode only, dark keeps its dark neutral. -
dangeris unaffected by the tenant palette. - The host page's
<html>is not mutated by the embedded widget (vars + theme
class are scoped to the widget wrapper). - Default build (no palette) is visually unchanged from today.
-
palette.tsunit tests: monotonic-lightness scale, foreground flips at the
contrast boundary,buildScale('#82b1ae')≈ the hand-tunedTEAL_COLOR. - Ladle palette switcher previews all three presets across atoms/molecules.
- Lint + typecheck + build +
test:runpass. - Verified in the running widget via Playwright (maroon + green sets, light & dark).
Files affected
- New:
src/config/theme/palette.ts,src/config/theme/palette.test.ts,
src/config/theme/BrandTheme.tsx - Edit:
src/Widget.tsx,src/hooks/use-theme.ts,tailwind.config.js,
src/types/client.ts,.ladle/components.tsx,package.json
References
- NextUI emits colors as HSL-channel CSS vars (
--nextui-primary,
--nextui-primary-{10,50…900},--nextui-primary-foreground) under.light/.dark. - Dark-mode tone shift follows Material 3 tonal-palette guidance (preserve hue, shift
tone, desaturate slightly). - Client fetch:
src/App.tsx:52(useSuspenseQuery(['client', apiKey])). - Blocked downstream: branding the map itself — see the on-hold map-branding ticket.
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Hold Until
None yet
Activity
feat(ui): white-label brand palette for the embedded widget (#23)