mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
An iPhone home-screen install drew the app under the status bar and put white clock/battery glyphs over it. On the light theme (--bg: #f7f9ff) that is white on near-white; iOS 26 glasses the strip as well, which is the blur in the report. Underneath it, the sidebar's logo and first nav item sat behind the status bar, and the menu button was parked flush against it. Cause: `apple-mobile-web-app-status-bar-style: black-translucent` with `viewport-fit=cover`. It runs the web view full-bleed AND forces white glyphs regardless of theme, while `theme-color` was hardcoded to the dark theme's background and never updated on a switch. Apple lists the value as deprecated. - status bar style -> `default`; every `calc(56px + env(safe-area-inset-top))` rule degrades to its pre-notch value because the inset is then 0 - theme-color follows the active theme: stamped pre-paint in theme-init.js, re-read from the live --bg on switch. setTheme now delegates to applyTheme rather than restating it, so one path touches the document - body::before paints an opaque strip of exactly env(safe-area-inset-top) — zero-height under `default`, insurance for landscape Safari and any future iOS that goes full-bleed again; pointer-events:none so it cannot eat taps - .mobile-toggle used max(12px, inset), which resolves to the inset itself and removes the gap entirely; .sidebar gained the top inset New test pins theme-init.js's duplicated colour literals to the theme files and guards the black-translucent regression; verified to fail on injected drift. typecheck clean, lint clean, 1680/1680 unit tests pass, build verified to emit content="default".
40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
// Stamp the theme before first paint so the boot loader (and the app behind
|
|
// it) never flashes the wrong theme. Resolution order:
|
|
// 1. Explicit user choice in localStorage
|
|
// 2. System prefers-color-scheme media query
|
|
// 3. Default: dark
|
|
// Kept as an external file — not inline — because the self-hosted Express
|
|
// deployment enforces `script-src 'self'` (helmet CSP), which blocks inline
|
|
// scripts.
|
|
//
|
|
// It also stamps <meta name="theme-color">, which is what iOS paints the
|
|
// standalone status bar with. That has to happen HERE rather than in the app:
|
|
// by the time core/theme.ts runs, the status bar has already been painted, and
|
|
// a hardcoded colour means the light theme gets a dark strip above it.
|
|
//
|
|
// The two literals below duplicate the `--bg` token of each theme, because at
|
|
// this point in the document no stylesheet has loaded and there is nothing to
|
|
// read it from. Source of truth: src/styles/themes/orbit-dark.css (dark) and
|
|
// dawn-light.css (light). src/__tests__/statusBarColor.test.ts fails the build
|
|
// if they ever drift apart.
|
|
var BG = { dark: '#0a0e1c', light: '#f7f9ff' }
|
|
|
|
function stampTheme(theme) {
|
|
document.documentElement.setAttribute('data-theme', theme)
|
|
var meta = document.querySelector('meta[name="theme-color"]')
|
|
if (meta && BG[theme]) meta.setAttribute('content', BG[theme])
|
|
}
|
|
|
|
try {
|
|
var saved = localStorage.getItem('finance-theme')
|
|
if (saved === 'light' || saved === 'dark') {
|
|
stampTheme(saved)
|
|
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
stampTheme('light')
|
|
} else {
|
|
stampTheme('dark')
|
|
}
|
|
} catch (e) {
|
|
stampTheme('dark')
|
|
}
|