From 60d006e8b7fa43feabad5f714449fc05eca357e0 Mon Sep 17 00:00:00 2001 From: tisachi Date: Sat, 17 Oct 2026 02:01:37 +0200 Subject: [PATCH] =?UTF-8?q?App:=20tryb=20standalone/PWA=20=E2=80=94=20view?= =?UTF-8?q?port-fit=3Dcover=20z=20wypelnieniem=20safe-area=20(tytul,=20dol?= =?UTF-8?q?ny=20pasek,=20drawer),=20theme-color=20per=20tryb,=20toasty=20n?= =?UTF-8?q?ad=20pasek=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index.html | 32 +++++++++++++++++++++----------- app/src/components/toast.tsx | 2 +- app/src/store/theme.ts | 27 ++++++++++++++++++++------- app/src/styles.css | 19 +++++++++++++++++++ app/src/topbar/Topbar.tsx | 4 ++-- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/app/index.html b/app/index.html index 0431655..c1d2f32 100644 --- a/app/index.html +++ b/app/index.html @@ -2,22 +2,32 @@ - - + + diff --git a/app/src/components/toast.tsx b/app/src/components/toast.tsx index 8e1b485..442847d 100644 --- a/app/src/components/toast.tsx +++ b/app/src/components/toast.tsx @@ -50,7 +50,7 @@ export function ToastProvider({ children }: { children: ReactNode }) { {children}
{toasts.map((t) => { const { icon: Icon, cls } = TOAST_STYLES[t.kind]; diff --git a/app/src/store/theme.ts b/app/src/store/theme.ts index 022059d..b508bfc 100644 --- a/app/src/store/theme.ts +++ b/app/src/store/theme.ts @@ -14,19 +14,32 @@ function currentTheme(): Theme { return 'dark'; } -/* theme-color = kolor tła WIDOCZNY u góry strony (bg + poświata body::before), - nie płaski --bg — inaczej pole statusu tworzy ciemniejszy pas nad treścią. - Wartości zmieszane jak gradient „--ambient”. Ekportowane — index.html ma +/* theme-color = kolor tła WIDOCZNY u góry strony: w przeglądarce pas pod paskiem + statusu to wiersz tła (bg + poświata „--ambient”), w standalone (PWA) całe pole + safe-area to tło strony — stąd płaski --bg. Ekportowane — index.html ma inline-skrypt z tymi samymi wartościami (kolor pola od pierwszego paintu). */ -export const THEME_COLORS: Record = { - dark: '#1d1612', - light: '#f6efea', +export const THEME_COLORS: Record = { + dark: { browser: '#1d1612', standalone: '#141210' }, + light: { browser: '#f6efea', standalone: '#f7f4f0' }, }; +function isStandalone(): boolean { + return ( + (typeof window !== 'undefined' && + typeof window.matchMedia === 'function' && + window.matchMedia('(display-mode: standalone)').matches) || + // iOS < 15.4 nie zna display-mode — legacy flaga standalone + (window.navigator as unknown as { standalone?: boolean }).standalone === true + ); +} + export function applyTheme(theme: Theme) { document.documentElement.classList.toggle('light', theme === 'light'); const meta = document.querySelector('meta[name="theme-color"]'); - if (meta) meta.setAttribute('content', THEME_COLORS[theme]); + if (meta) { + const colors = THEME_COLORS[theme]; + meta.setAttribute('content', isStandalone() ? colors.standalone : colors.browser); + } } interface ThemeState { diff --git a/app/src/styles.css b/app/src/styles.css index 53e6203..b8fb96b 100644 --- a/app/src/styles.css +++ b/app/src/styles.css @@ -302,6 +302,25 @@ } } +/* PWA (standalone) na iOS/Android: pływający tytuł i dolny pasek menu muszą + „dopełniać” pola safe-area (notch, home-indicator) — w przeglądarkowej + wersji robi to UI paska (theme-color), więc w media nie ma = zero kosztu */ +@media (display-mode: standalone) { + .safe-pad-top { + padding-top: env(safe-area-inset-top); + background-color: var(--bg); + } +} + +/* dolny pasek menu istnieje tylko na telefonie ( void }) {
{/* telefon: header rozbity (contents) — tytuł jako pływająca pigułka z shadow; akcje kontekstowe i tak żyją w dolnym pasku */} -
+
{/* telefon: otoczka tytułu na szerokość napisu, przylega do prawej (przy hamburgerze) */}

@@ -149,7 +149,7 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) { (renderowany tylko gdy strona ma w nim jakąś opcję) */}