diff --git a/index.html b/index.html index eb2d9d8..b96c0e2 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@ - + @@ -20,7 +20,7 @@ -
+ diff --git a/public/manifest.json b/public/manifest.json index e2f9c0d..64368ac 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -6,8 +6,8 @@ "scope": "/", "display": "standalone", "orientation": "any", - "background_color": "#f8fafc", - "theme_color": "#0f172a", + "background_color": "#faf7f0", + "theme_color": "#f1ece0", "icons": [ { "src": "/icon-192.png", diff --git a/src/App.jsx b/src/App.jsx index 0f39a66..6cb7586 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,6 @@ import { lazy, Suspense, useEffect, useRef, useState } from 'react'; import { getPlanSchedule, nearestReadingDay } from './utils/readingPlans.js'; +import { applySystemChrome } from './utils/systemChrome.js'; import { AppContext, useApp } from './context/AppContext.js'; import { useAudio } from './hooks/useAudio.js'; import { useAuth } from './hooks/useAuth.js'; @@ -59,6 +60,8 @@ const App = () => { const reader = useBibleReader(currentPage, readerPlanProgress?.translation ?? null); const audio = useAudio(reader.readerBookAbbrev, reader.readerChapter, reader.readerTranslation); useEffect(() => { if (currentPage !== 'reader') setReaderPlan(null); }, [currentPage]); + // Keep the browser/OS chrome (status bar area, overscroll, scrollbars) in the chosen theme + useEffect(() => { applySystemChrome(reader.readerTheme); }, [reader.readerTheme]); const { authUser, setAuthUser, authServerDown, signIn, logout } = useAuth({ onSignIn: (user) => { setProjectIndex(switchStorageUser(user.id)); diff --git a/src/App.test.jsx b/src/App.test.jsx index 53bf574..c4548ac 100644 --- a/src/App.test.jsx +++ b/src/App.test.jsx @@ -1405,3 +1405,18 @@ describe('Import template', () => { expect(await screen.findByRole('button', { name: /download template/i })).toBeEnabled(); }); }); + +describe('System chrome follows the theme', () => { + test('the app tells the browser/OS the theme colour and scheme, and updates it when the theme changes', async () => { + localStorage.setItem('reader-theme', 'dark'); + const user = userEvent.setup(); + await renderApp(); + const themeColor = () => document.head.querySelector('meta[name="theme-color"]')?.getAttribute('content'); + expect(themeColor()).toBe('#262421'); + expect(document.documentElement.style.colorScheme).toBe('dark'); + await user.click(screen.getByRole('button', { name: /account menu/i })); + await user.click(screen.getByRole('button', { name: /^paper$/i })); + expect(themeColor()).toBe('#f1ece0'); + expect(document.documentElement.style.colorScheme).toBe('light'); + }); +}); diff --git a/src/components/reader/ReaderBars.jsx b/src/components/reader/ReaderBars.jsx index bc0e1c4..575365d 100644 --- a/src/components/reader/ReaderBars.jsx +++ b/src/components/reader/ReaderBars.jsx @@ -7,7 +7,7 @@ const iconBtn = 'flex h-9 w-9 items-center justify-center rounded-lg text-[var(- export function TopBar({ title, onBack, onOpenNavigator, onSearch, onBookmarks, bookmarkCount, onSettings, onDoneDrawing }) { return ( -