Skip to content

PR 2/N: lock in .slidewise-editor CSS scope#6

Merged
karthikmudunuri merged 1 commit intokarthikmudunuri/deck-schema-versioningfrom
karthikmudunuri/style-isolation
May 4, 2026
Merged

PR 2/N: lock in .slidewise-editor CSS scope#6
karthikmudunuri merged 1 commit intokarthikmudunuri/deck-schema-versioningfrom
karthikmudunuri/style-isolation

Conversation

@karthikmudunuri
Copy link
Copy Markdown
Member

Second PR in the integration plan. Stacked on top of #5 — review/merge that first (which itself is stacked on #4).

Summary

The library is mounted inside host applications that ship their own global stylesheets (Tailwind preflight, normalize.css, app resets). Any CSS rule we ship that escapes the .slidewise-editor scope would collide with host styles either way (we override their resets, or theirs override ours, depending on load order).

Today's CSS already obeys the rule and the lib build (vite build --mode lib) already excludes Tailwind preflight — but nothing prevented a future change from breaking it. This PR adds a regression test.

What was audited

  • ✅ Every rule in src/SlidewiseEditor.css is nested under .slidewise-editor.
  • ✅ No editor component (anything in tsconfig.lib.json's include list) uses Tailwind utility classes — all styling is via the scoped CSS + inline styles.
  • vite.config.ts:11 excludes the Tailwind plugin from the lib build.
  • dist/slidewise.css (after pnpm build:lib) contains only @font-face rules and .slidewise-editor-scoped rules.

What changed

  • src/lib/__tests__/css-scope.test.ts — vitest that scans src/SlidewiseEditor.css and rejects any top-level selector that doesn't start with .slidewise-editor. At-rules (@font-face, @import, @media, @supports, @keyframes) remain allowed at top level since they don't paint, only register names. Verified the test fails on injected violations like body { … } and a bare h1 inside a comma-list.
  • src/SlidewiseEditor.css — short header comment pointing at the test so future contributors see the constraint inline.

Test plan

  • npx tsc -b clean
  • npx vitest run — 14/14 (6 roundtrip + 7 migrate + 1 css-scope)
  • pnpm build:lib emits dist/slidewise.css of 159 kB (font payload) with only .slidewise-editor selectors and @font-face blocks

The library is mounted inside host applications that ship their own
global stylesheets (Tailwind preflight, normalize.css, app resets). Any
rule in our CSS that escapes the .slidewise-editor scope would collide
with host styles. Today's CSS already obeys the rule, but nothing
prevented a future change from breaking it.

Adds a vitest that scans src/SlidewiseEditor.css and rejects any
top-level selector that does not start with .slidewise-editor (at-rules
like @font-face / @import / @media remain allowed). Verified the test
fails on injected violations like `body { … }` and bare `h1` inside a
comma-list.

Also adds a short header comment to SlidewiseEditor.css pointing at
the test so future contributors see the constraint without reading
this commit.

No production code changes — the lib build (vite build --mode lib) was
already excluding the Tailwind plugin and emitting only @font-face plus
.slidewise-editor-scoped rules.
@karthikmudunuri karthikmudunuri merged commit 463aed7 into karthikmudunuri/deck-schema-versioning May 4, 2026
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