Skip to content

feat: add theme switching component and expose admin theme to iframe apps - #1284

Open
Arnold Stoba (arnoldstoba) wants to merge 2 commits into
mainfrom
feat/theme-switch-and-sdk-theme
Open

feat: add theme switching component and expose admin theme to iframe apps#1284
Arnold Stoba (arnoldstoba) wants to merge 2 commits into
mainfrom
feat/theme-switch-and-sdk-theme

Conversation

@arnoldstoba

@arnoldstoba Arnold Stoba (arnoldstoba) commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Adds theme switching for Meteor apps and exposes the Administration's resolved theme to iframe apps through the Admin SDK.

🎥 Example usage in the Administration: https://www.loom.com/share/25b434e8ca85432eb303e6d30e0e9992

Closes #1174
Closes #1129

Component library (#1174)

  • mt-theme-select — select for choosing light, dark, or system (localized labels, en/de).
  • useTheme composable — resolves the system preference, applies the resolved theme via data-theme, persists to localStorage (key mt-theme). Built on @vueuse/core.

Admin SDK (#1129)

  • context.getTheme(), context.subscribeTheme(), context.syncTheme() — following the contextLocale pattern (message key contextTheme).
  • Zero-config for apps: on SDK startup inside an iframe, the resolved admin theme is mirrored onto <html data-theme="…"> and kept in sync. Updating the SDK dependency is the only change an app needs. Apps that set data-theme themselves are left untouched; older admins without theme support are a silent no-op.
  • The admin side implements handle('contextTheme', …) + publish('contextTheme', …), same wiring as contextLocale.

Known limitation

Iframes can briefly flash unthemed (white) on load: the theme arrives via an async postMessage round trip, so the first paint can happen before it. This could potentially be solved by one of my previous proposed fixes of adjusting the default bg color to transparent if inside of a embedded iframe context (passed through via admin-sdk).

Tests

Unit tests for the composable, the component, and the SDK theme API (incl. stale-response race, invalid values, rejected initial fetch, and the zero-config auto-sync). Changesets: minor for both packages.

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
meteor-docs Ready Ready Preview, Comment Jul 23, 2026 2:30pm
meteor-storybook Ready Ready Preview, Comment Jul 23, 2026 2:30pm

Request Review

…apps

Component library (#1174):
- mt-theme-select: select for light, dark, or system with localized labels
- useTheme composable (VueUse-based): resolves the system preference,
  applies the resolved theme via data-theme, persists to localStorage
- docs-app pages for both, plus Storybook stories and interaction tests

Admin SDK (#1129):
- context.getTheme(), context.subscribeTheme(), context.syncTheme()
  following the contextLocale pattern (message key: contextTheme)
- zero-config: on SDK startup inside app iframes the resolved admin theme
  is mirrored onto the document root's data-theme attribute and kept in
  sync, so apps only need to update their SDK dependency. Apps that set
  data-theme themselves are left untouched.
- documented in the Context API reference

Closes #1174
Closes #1129
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.

Theme switch component Admin SDK: expose admin theme to iframe apps

1 participant