fix(web): match the iOS status bar to the theme picked in the app
The theme-color metas used prefers-color-scheme media queries, so they followed the OS theme and ignored the in-app choice. Use a single meta that the pre-paint script and ThemeProvider update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,9 @@ type ThemeContextValue = {
|
||||
const STORAGE_KEY = 'superlist-theme'
|
||||
const DARK_QUERY = '(prefers-color-scheme: dark)'
|
||||
|
||||
/** Browser chrome color (the iOS status bar) per theme. Keep in sync with `index.html`. */
|
||||
const THEME_COLORS: Record<ResolvedTheme, string> = { light: '#f9f8f5', dark: '#0f1411' }
|
||||
|
||||
/**
|
||||
* This theme handling is hand-rolled on purpose. Libraries such as `next-themes`
|
||||
* avoid the pre-paint flash by rendering a `<script>` from React, but React 19
|
||||
@@ -60,6 +63,9 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
const root = document.documentElement
|
||||
root.classList.toggle('dark', resolvedTheme === 'dark')
|
||||
root.style.colorScheme = resolvedTheme
|
||||
document
|
||||
.querySelector('meta[name="theme-color"]')
|
||||
?.setAttribute('content', THEME_COLORS[resolvedTheme])
|
||||
}, [resolvedTheme])
|
||||
|
||||
const setTheme = useCallback((next: Theme) => {
|
||||
|
||||
Reference in New Issue
Block a user