Skip to content

feat(widget): de-brand the widget and keep host CSS out of it #156

Closed

Description

@Ardnived

Summary

Make the widget read as the host's own events feature rather than as a product called Sahaj
Atlas embedded in their page, and stop the host's CSS reaching into it.

Stage B of the white-label/SEO programme (.claude/reports/whitelabel-seo-program.md §8), and the
one that states the goal literally. Everything before it was infrastructure: the loader made the
embed cheap (#150), query routing made it indexable (#155). This is the part a visitor sees.

Taken now rather than in plan order because Stage C is blocked — SahajCloud #633 and #634 are
still open and C4/C5 consume what they produce. What remains of C on this side is one deletion,
which is also a B item, so it comes along here (see B1).

Proposed changes

B1 · Copy sweep — the visitor-facing strings

Where Now Change
public/locales/*/common.json widget.label ×10 "Sahaj Atlas — free meditation classes" Split into widget.label ("Free meditation classes") and widget.label_named ("%{name} — free meditation classes")
public/locales/*/events.json on_sahaj_atlas ×10 "on Sahaj Atlas" Key renamed to display.view_full_details
Fallbacks.tsx app-level alert title="Sahaj Atlas" Drop the prop entirely
App.tsx RootFallback "Sahaj Atlas could not be loaded…" Neutral sentence
src/lib/ics.ts PRODID -//Sahaj Atlas//Events//EN Neutral, and not tenant-configurable
src/styles/fonts.ts FONT_FAMILY 'Sahaj Raleway' 'Atlas Raleway'
index.html <title> "Sahaj Atlas" Neutral

Four of those need their reasoning stated, because each has a trap:

  • widget.label splits into two keys rather than taking an interpolation. An absent name would leave a dangling em-dash, and this string is the role="region" accessible name — WebKit drops the landmark entirely when it resolves empty (i18n-options.test.ts records this).
  • on_sahaj_atlas is renamed, not just retranslated. A key named after the brand is itself a brand reference in a file translators read.
  • RootFallback stays a hardcoded English literal with no i18n and no theme dependency. That constraint is correct and must survive: it renders when the providers themselves have failed. Only the string becomes neutral.
  • ⚠ UID:event-<id>@atlas.sydevelopers.com (ics.ts:324) stays exactly as it is. It is the calendar dedupe key — changing it makes every previously-exported event re-appear as a new entry in somebody's calendar. PRODID identifies the producing software and is a different field with different rules.

Plus the deletion carried over from Stage C: EventSummary renders both the on_sahaj_atlas
label and an outbound link to event.webUrl. That backlink was never correct behaviour, and once
canonicals point at the owning client it becomes a self-link on the very page the widget is
embedded in. With it gone the component is a two-call-site alias over an EventFacts that already
takes variant, title, children and className — so it goes too, along with its
standalone/hasMap read and its barrel exports.

A ratchet spec walks the locale JSON and a named list of source files and fails if anything
matches /sahaj\s*atlas|we ?meditate/i. Same spirit as href.test.ts's anchor inventory: the
enumeration is the enforcement, so the next brand string turns the lane red instead of shipping.

B2 · Tenant identity

  • Display name from client.name, which already exists and is already used as a display string in buildReportContext — no SahajCloud change needed. Plus the name script parameter the loader already parses.
  • JSON-LD organizer currently hardcodes We Meditate (EventMetadata.tsx:50-55). Derive it from the client, and omit the whole block when unknown — an absent optional property is better structured data than a false one.
  • Typography via a --sy-font-sans custom property that tailwind.config.js reads, so a host can name a font their page already loads. No new request, no CSP change.
  • Storage keys move under atlas.. ⚠ The un-namespaced theme key is a bug fix, not branding — docs/embedding.md already admits it reads and overwrites a host's own theme key — so it needs a one-time migration read of the old key and should be described in the changelog as a fix.

B3 · Defensive CSS reset

Host CSS reaching into the widget is the one direction the #91 scoping work does not cover, and
it has broken embeds in the field.

:where(.sy-atlas),
:where(.sy-atlas) :where(*) {
  all: revert;
}

Unlayered, and placed before our sheet. The mechanics matter, because the obvious spelling is
backwards:

  • ⚠ @layer alone makes it worse. Unlayered author styles outrank every author layer, so putting our sheet in a layer hands the host's unlayered rules an automatic win.
  • :where() is (0,0,0) specificity, so every rule of ours still outranks it — it only wins where nothing of ours speaks, which is exactly the set a host can leak into.
  • all excludes custom properties, so the brand palette survives untouched.
  • It is hand-written against .sy-atlas, which postcss-scope-widget.mjs passes through unmodified — so assert:css keeps working with no changes.
  • The second half is mandatory: all: revert does not stop inherited properties crossing the root boundary, so the root needs an explicit baseline for font-family, color, line-height, letter-spacing, text-transform, word-spacing and text-align. globals.css already does this for line-height; this generalises it.
  • ⚠ Never add contain: layout or a transform to the root. The measured table in .claude/rules/components.md shows both re-parent position: fixed descendants — which would break map mode, every drawer, the peek strips and the cog.
  • ⚠ Measure the cost. all: revert on * defeats style-sharing and forces full property recomputation per element; check a long results list before shipping.

B4 · Shadow DOM evaluation ticket

Filed as a real ticket rather than left as a maybe. Must cover: @font-face inside a shadow root
in current engines; retargeting every Radix portal and the document.activeElement /
dismissible-layer machinery; vite-plugin-css-injected-by-js appending to document.head;
Mapbox's document.elementFromPoint; and that it does not fix vaul's window-height arithmetic,
which is the thing map mode actually needs.

Explicitly not doing

  • Removing sahajatlas.com as a runtime dependency. Assets are served from there whichever way the widget loads, so bundling the locale JSON would only move which requests hit that origin, not remove it. Document it honestly instead. (Does not block refactor(i18n): source translations from SahajCloud CMS #28.)
  • Renaming the DOM identifiers — sahaj-atlas, sahaj-atlas-style, sahaj-atlas-fonts, sy-atlas. docs/embedding.md invites hosts to key off the style ids and promises they are stable; no visitor ever sees any of them; and renaming the scope class means four synchronised sites plus a build gate for zero visitor-facing gain.

Acceptance criteria

  • No visitor-facing string, in any of the ten locales, names Sahaj Atlas or We Meditate.
  • The role="region" landmark has a non-empty accessible name with and without a client name.
  • EventSummary is gone; both call sites use EventFacts directly and render no outbound backlink.
  • JSON-LD omits organizer entirely when the client is unknown, rather than naming We Meditate.
  • The theme key is namespaced, with a one-time read of the old key so nobody loses their setting.
  • ⚠ The ICS UID is byte-identical to before; PRODID is neutral.
  • Host CSS (button { … }, a { color: … !important }, an aggressive * { box-sizing }) does not visibly alter the widget, verified in a browser against a hostile stylesheet.
  • The brand-string ratchet spec fails when a brand string is reintroduced.
  • pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm size && pnpm ladle:build pass, and pnpm size is reported for a credentialed build.
  • docs/embedding.md and CHANGELOG.md record what a host can observe; write an implementation report to .claude/reports/.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions