Skip to content

Inline shared UI tokens into the synced theme stylesheet - #70

Merged
callumalpass merged 2 commits into
mainfrom
fix/theme-css-imports
Oct 1, 2026
Merged

callumalpass merged 2 commits into
mainfrom
fix/theme-css-imports

Conversation

@callumalpass

Copy link
Copy Markdown
Contributor

Problem

Since the Connect ref was bumped to beta120 in #68, the deployed mdbase-theme.css starts with:

@import "@mdbase-dev/ui/tokens.css";
@import "@mdbase-dev/ui/brand.css";
@import "@mdbase-dev/ui/controls.css";

mdbase-connect#508 moved the tokens into the @mdbase-dev/ui package, and sync-sources.mjs copies the head of packages/ui/styles.css verbatim. Browsers can't resolve bare specifiers, so every --color-* token is undefined on mdbase.dev. As a result the header rules are gone, the page background is unset, and the theme toggle does nothing visible.

Fix

resolveConnectThemeImports in scripts/sync-sources.mjs:

  • inlines packages/app-ui/css/tokens.css
  • drops brand.css and controls.css, which are app component styles; the pre-#508 extract never included them, and brand.css would override the site's .wordmark
  • throws on any unexpected or leftover @import, so a future upstream change fails the deploy instead of shipping broken CSS

The committed public/mdbase-theme.css and public/theme-bootstrap.js are refreshed from the pinned beta120 ref.

Verification

  • Ran sync:sources against worktrees at the refs in site-sources.json: no @import in the output, and every custom property the old theme defined is still defined.
  • pnpm build, then Playwright on the preview: header borders are 1px in both colour schemes, the body background and ink resolve, and the theme toggle switches, persists across a reload and switches back.

The palette now follows Connect's new oklch tokens, so colours differ slightly from before #508.

mdbase-connect #508 moved the theme tokens out of packages/ui/styles.css
into the @mdbase-dev/ui package, leaving bare @import specifiers at the
top of the file. sync-sources copied those imports verbatim into
public/mdbase-theme.css, where browsers cannot resolve them, so every
colour, border and control token on the deployed site went undefined.

Resolve the imports while syncing: inline tokens.css, drop brand.css and
controls.css (app component styles the site does not use, and brand.css
would restyle the site's .wordmark), and fail the sync on any other or
leftover @import. Refresh the committed theme files from Connect beta120.
@callumalpass
callumalpass merged commit 1f3cec6 into main Oct 1, 2026
1 check passed
@callumalpass
callumalpass deleted the fix/theme-css-imports branch October 2, 2026 03: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