Skip to content

feat(ui): shadow stylesheet loader — content.css transform + adopt (stage 2a)#189

Merged
heznpc merged 1 commit into
mainfrom
feat/shadow-css-loader
Jun 9, 2026
Merged

feat(ui): shadow stylesheet loader — content.css transform + adopt (stage 2a)#189
heznpc merged 1 commit into
mainfrom
feat/shadow-css-loader

Conversation

@heznpc

@heznpc heznpc commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Stage 2a of the Shadow DOM migration. Builds the bulk-CSS mechanism the sidebar (stage 2b) needs, on the already-shadowed FAB — no UI moved, no 83-site churn yet.

What

  • src/content/shadow-css.js (standalone): pure transformForShadow rewrites content.css's ancestor theme selectors into :host(...) form, plus a cached fetch → transform → CSSStyleSheet loader and idempotent adopt.
  • Env-agnostic path: the CSS URL is read from the manifest (content_scripts[].css[0]), so it resolves to src/content/content.css in dev and content.bundle.css in the bundle. manifest.json + build-bundle.js make that file web-accessible (the build remaps the dev path → content.bundle.css).
  • getUiRoot adopts the sheet into #skillbridge-root; the FAB keeps its inline critical style (adopt is async).

Verification

  • tests/shadow-css.test.js (8 unit tests): includes a completeness pass over the real content.css — asserts no html./body. theme prefix survives (all 391 rewritten) and the :host(...) forms appear.
  • shadow-isolation.spec.js: new assertion that content.css is fetched, transformed (:host(.si18n-dark) present), and adopted into the shadow root — verified against the minified bundle (catches any minify/transform interaction).
  • 520 unit tests · full E2E (19) · lint · prettier · validate · check:* — green.

Next (stage 2b)

Move the sidebar + its dependent modules (~83 document-level query sites → sb.uiRoot()), styled by this adopted sheet.

🤖 Generated with Claude Code

…tage 2a)

Builds the bulk-CSS mechanism the sidebar migration (stage 2b) needs: load
content.css once, rewrite its ancestor theme selectors to :host(...) form, and
adopt the result into the shadow UI root.

- New src/content/shadow-css.js (standalone module): pure transformForShadow
  (html.si18n-dark → :host(.si18n-dark); body:is(.si18n-lang-ar,.si18n-lang-he)
  → :host(:is(...)); body.si18n-lang-XX → :host(.si18n-lang-XX)) + a cached
  fetch→transform→CSSStyleSheet loader + idempotent adopt.
- The CSS path is resolved from the manifest (content_scripts[].css[0]) so it
  works in both the dev build (src/content/content.css) and the bundle
  (content.bundle.css). manifest + build-bundle.js make that file
  web-accessible (build remaps the dev path to content.bundle.css).
- getUiRoot adopts the sheet into #skillbridge-root. The FAB keeps its inline
  critical style (the adopted sheet loads async).

Verified:
- tests/shadow-css.test.js (8): transform cases incl. a completeness pass over
  the REAL content.css — asserts NO html./body. theme prefix survives (all 391
  rewritten) and the :host forms appear.
- shadow-isolation.spec.js: new assertion that content.css is fetched,
  transformed (contains :host(.si18n-dark)), and adopted into the shadow root —
  proven against the minified bundle.
- 520 unit tests, full E2E (19), lint, prettier, validate, check:* — green.

Next (stage 2b): move the sidebar + its dependent modules' ~83 query sites
into the shadow root, styled by this adopted sheet.
@heznpc heznpc enabled auto-merge (squash) June 9, 2026 19:52
@heznpc heznpc merged commit e895bb4 into main Jun 9, 2026
9 checks passed
@heznpc heznpc deleted the feat/shadow-css-loader branch June 9, 2026 19:53
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.

1 participant