Repository navigation
Description
Context
On Android, an installed PWA's status bar takes its colour from the page's <meta name="theme-color">, or from the manifest's theme_color when the page has none. brain-kit gives the host one dark value for both: WEB_APP_COLORS sets theme_color and background_color to the icon tile's ground #0c1417 (packages/ui-kit/src/brand.ts:83-84), and nothing is exported for a light scheme.
The app can be switched to Paper (light) in Settings, or follow the system. useApplyTheme only writes <html data-theme> (useApplyTheme, packages/ui-react/src/components/layout/theme.tsx:20-26), so a user on Paper gets a dark status bar above a #ece7dc canvas (--bk-color-canvas: light-dark(#ece7dc, #0c0e12), packages/ui-kit/src/tokens.css:45). The app already knows the effective scheme: useColorScheme (packages/ui-react/src/hooks/use-color-scheme.ts:17-31) resolves the preference, defaulting to "dark" (packages/ui-react/src/stores/ui-state.ts:226), and under system the OS setting.
The host owns index.html, so the initial meta tag is a host change, tracked in schlessera/brain-hosting-template#34. This issue ships the values and the runtime update.
Guide: (no guide). Support (MDN BCD 8.1.6): <meta name="theme-color"> is in Chrome for Android 39 and Samsung Internet 6.2, and not in Firefox for Android, which ignores it. Chrome for Android uses it in dark mode only for installed PWAs, which is the target here.
Binding: the brand exports are documented in package-api.md "Logo assets", so a new export is an additive contract change.
Scope
ui-kitbrand entry: exportTHEME_COLORS = { light, dark }, taken fromLIGHT_TOKENS["color-canvas"]andTOKENS["color-canvas"]rather than repeated literals. Also exportHTML_THEME_COLOR_META = { name: "theme-color", content: THEME_COLORS.dark }, the tag a host writes into its head besideHTML_ICON_LINKS(brand.ts:99-103), matching the app's default dark preference.ui-react: while the app shell is mounted, keep thecontentof the document's first<meta name="theme-color">equal toTHEME_COLORS[scheme]for the effective scheme fromuseColorScheme, following preference and OS changes. If no such tag exists, create one. Leave anymediaattribute the host set untouched, except on the tag being updated.- Document both exports in package-api.md's "Logo assets", and note the runtime update in the
useApplyThemedoc comment.
Out of scope
WEB_APP_COLORSand the manifest'stheme_color/background_color; the splash screen and icon ground stay#0c1417.- The host's
index.htmland the inline pre-paint theme script (shell: declare theme colour per scheme and OS text scale in the app HTML brain-hosting-template#34). - Per-view status-bar colours (sheets, overlays).
color-schemeor token changes.
Acceptance criteria
-
THEME_COLORS.light === "#ece7dc"andTHEME_COLORS.dark === "#0c0e12", asserted in a ui-kit test that derives them from the token tables, so a token change cannot drift silently. - In a real-browser test (
ui-react-layoutproject), with a host meta ofcontent="#0c0e12", selecting Paper changes it to#ece7dc, selecting Dark changes it back, and under System it follows an emulatedprefers-color-schemechange. The test fails on the tree before the change. - With no meta in the document, mounting the shell creates exactly one, and unmounting does not leave a second one behind after remounting.
- Firefox for Android needs no detection, since an ignored meta is harmless; the PR states this.
- package-api.md, the api-report and a changeset for
ui-kitandui-reactland in the same commit, prefixedCONTRACT:.
Verification
bun run test packages/ui-kit/tests
bun run test:layout
bun run api-report
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
Activity