From b19de6f9eadfdeae6e86f4753a3174d92d7a4a0c Mon Sep 17 00:00:00 2001 From: Elijah Date: Tue, 20 Oct 2026 20:16:25 -0700 Subject: [PATCH] Mobile UI redesign and size fixes --- .vs/Calorie Tracker.slnx/v18/.wsuo | Bin 0 -> 9728 bytes .../v18/DocumentLayout.json | 12 + .vs/VSWorkspaceState.json | 6 + .vs/slnx.sqlite | Bin 0 -> 90112 bytes README.md | 10 + index.html | 6 +- public/icons/apple-touch-icon-v2.png | Bin 0 -> 3206 bytes public/icons/apple-touch-icon.png | Bin 3279 -> 3206 bytes scripts/build-sw.js | 1 + scripts/container-smoke.js | 1 + scripts/generate-icons.ps1 | 12 +- src/App.tsx | 305 +++-- src/Settings.tsx | 4 +- src/Trends.tsx | 27 +- src/main.tsx | 1 + src/mobile.css | 1001 +++++++++++++++++ tests/browser/mobile-layout.check.js | 37 + 17 files changed, 1292 insertions(+), 131 deletions(-) create mode 100644 .vs/Calorie Tracker.slnx/v18/.wsuo create mode 100644 .vs/Calorie Tracker.slnx/v18/DocumentLayout.json create mode 100644 .vs/VSWorkspaceState.json create mode 100644 .vs/slnx.sqlite create mode 100644 public/icons/apple-touch-icon-v2.png create mode 100644 src/mobile.css create mode 100644 tests/browser/mobile-layout.check.js diff --git a/.vs/Calorie Tracker.slnx/v18/.wsuo b/.vs/Calorie Tracker.slnx/v18/.wsuo new file mode 100644 index 0000000000000000000000000000000000000000..779a89578c1c87d1d9f797ba6ef89621c90ee7ba GIT binary patch literal 9728 zcmeHN&u)ZD?r^QHd%Jb(A1u+M-4XLP{k}0#2Y(PtH1V+$N5-cA%X2 zTe$Vgkz4CwjZ@_xIksnKv`*{P|?^`NK!2 zUr2}+41X9uz6AbfK6V!Tw=ni^ z4)jU)!Qv5rUh<0NV|Y&@asBV${l1@PIj8aDz(MN&-0{Bt|4zXJslFYg{(lJE|C0XO zl4qDYc8qY^`Cj(Z+uh#k0R+9`UaZM-{Z-FVfJScR`IUPO9^KkMPI@G z(4On=qxyv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Wqru9K@@QC95VHO7}y$tT11vaqCZz9&hi4ZqUa0HUSheUZ zg6unvPcv9c{HJPae8+jSi_v<`wF43^$A3uX2iLi-8#0EcpAPr^cwZR(Hy_o4pOipEB!%cOA+e?Kzx}PVr*& z(LtNuif$d8?|#beM#;vLL3FFPBV?s#(S34biwUO|$w_vrzs()G7Gbxp+Kv@7Qcc?S zHpnmtEY@M&ORa_5w$bo9jhn+etoQ=HcPAfUVzHPvEk;avb3iw;lx=C6KO?#!a z;K8;`qYYhE;~J}7u?*vSfa~mQy!EE1W%KCheU9a_PX*Os+|QMAzgsEeI(muTEn!{wsaL9?ZQRuw>Z46&A-l%A2-<#ItP*LG04ZD*w$HnpSD zwp!W9vt5EaG%~_Icg?oQEyGhCR(e*;cFSFtXt?I}()xw_gWtwBT3(Hp{qEP<5A3qE zJ?e)D8vFL>lh1syayKJ*}{2y*My64I2m(qMrM|n2{KTbiBqB7>#S}z2FDD|Nl^(9MBmM00KY&2mk>f00e*l5C8%| z00;nq*M$Jw|GzHSp;I6L1b_e#00KY&2mk>f00e*l5C8%Xl>q$y-$TU>odE$L00e*l z5C8%|00;m9AOHk_01$Xx2tfS*b-@mu0s$ZZ1b_e#00KY&2mk>f00e*l5O}Br{ue~R B2txn> literal 0 HcmV?d00001 diff --git a/README.md b/README.md index a441ae0..d9edad9 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,14 @@ A single-user, self-hosted nutrition journal. PWA first, with a responsive deskt - Markdown, CSV and JSON export with date range, nutrient and weight selections. Markdown is designed for LLM analysis. Data is downloaded locally, never submitted to an LLM. Save preferences to remember the export format, range preset and selections. - Password authentication, IndexedDB offline journal/outbox, a precached app shell, automatic foreground/reconnect sync, and explicit PWA update prompts. +### Phone layout + +On phones, Today fills the available screen, including iPhone safe areas, with the calorie circle, readout, macros and navigation visible together. **Food journal** opens the selected day's meals in a separate scrollable sheet; adding, editing and removing entries from it uses the same offline journal. Desktop retains the side-by-side dashboard and meals. Compact screens use the date picker instead of the full week strip, and landscape arranges the circle beside the totals. If more than three nutrient goals are enabled, swipe the macro row horizontally to see the rest. + +Phone controls use larger type, 44–56 px tap targets, and 51×31 px switches. Food entry uses full-width day/time/meal rows, explicitly constrained native input widths, and a sticky sheet header. Library, Weight and Settings scroll normally. + +The iPhone Home Screen icon uses a dark background and high-contrast mark so automatic tinting has a dark base instead of a bright colored square. The versioned Apple touch-icon URL lets new installations request the revised asset; Android keeps its existing regular and maskable icons. iOS owns the final tinted/clear rendering, so a PWA cannot guarantee the native Icon Composer appearance. If an existing Home Screen shortcut retains its old cached icon, first sync all pending entries, then add Calio to the Home Screen again. The server's database is unchanged. + Barcode lookup and nutrition-label OCR are deferred. This release uses manual nutrition entry and saved foods. It does not include Apple Watch integration, HealthKit, fasting, reminders or water tracking; those screenshot features were not part of the requested core. ## Deploy on Unraid @@ -104,3 +112,5 @@ node scripts/container-smoke.js calio:local --unraid ``` App code is in `src/`, shared schemas/merge rules in `shared/`, and the Express/SQLite server in `server/`. The handwritten service worker is generated from production asset hashes by `scripts/build-sw.js`. Icons are committed PNGs; `scripts/generate-icons.ps1` regenerates them on Windows without external assets. + +The read-only browser regression expression in `tests/browser/mobile-layout.check.js` checks Today height, visible macros/readout, navigation type and tap targets, Settings switches, and food-editor input bounds. Load its text into the browser tool's `playwright.evaluate` at phone sizes, on Today, Settings, and an open food editor; `pass` must be true. Verify small/tall portrait screens, landscape, safe-area insets, all enabled macros, and journal-to-editor actions. It runs against rendered DOM rather than asserting stylesheet strings; it is separate from the Node-only unit suite. diff --git a/index.html b/index.html index af8ee42..356bec6 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,11 @@ - + Calio · Everyday, in balance diff --git a/public/icons/apple-touch-icon-v2.png b/public/icons/apple-touch-icon-v2.png new file mode 100644 index 0000000000000000000000000000000000000000..ff07f066924c0546495692ebc5aa15e0be55d7e4 GIT binary patch literal 3206 zcmb_f`#%%j8=s7}m5)WFVF+`{non}gZ8I|^MI|;Zm$b1^B+R9ZLULJd5t2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lP1+AcaifC?W+q zHy6ZeSIyD0_5(OW=YMDjm`_&F%#zwl@X6nwOJ1rwk7Zi#?1gWKgE%5@pwag814{18 zL>0B#@j7eKE_JQ%_9JS>U^-M2@@Ja3uyj>l=%$k9%S^KYliy~5BkWx@_ z9!L!BXe?l+r`_kvl?+N)cg;&&Y(HZ|EX!iB8#bA(@w{i+nrEEta{Ro}yPa>_>?mUP^%%2z2 z*!)KFT_@VQ=~mb?+J3EC`g||?+VVKl0*N;~(IF1-a|H$NfX@^Evi%e9B0;QTOW`+! z;Rd7TPH!~89mj^MJbOlC8y+Gp$pvKSzXWk6sW}ioY z3a|Q6iO@j|B1W*)S_A#~IrovN*NXv5aE|lHPT5o`{ZnR*IRSyoDSjbf-mwJ5UCcy; z)Iz7K49v6KoZ5M!<}`AE$qnAKO`;dak?cX(7lJ3>^?&UDsG& zGNbY%d>i$?$hsua{GG!hK-!e{FzTZCQEV6rH06^M6<1mq zg!$ko+jApViY#<5*2f8IdkBQ&j%vHS>$#vw_I+i&a`4Jnc$!aCseedzpNP_bvHB#1`lA|cHmMHb^1?2k4HQuQ@QYL!sRYyK*Ot)2)UhD?K; zQ9R%YXAO(YQlfe12?$yO5H?Lcmr4r#9?DXwlCB}yx+2LjC%|X<(v0V8YP0Cfm#fwx zo<1>6eBddNpO`I2Msm+9N9c#nvF>YdHh(~Bpb7}3y_s6~Qaq7gG7RLA7Q<6THjDf2 z>mvK3YOkP2z2i|2%LXs`b*$D*8C;x1CZDRLQZaBiP6qt{0S|>=Jb7D@H!%z3eL?^j LI~Us~Q~>#ZaB2$< diff --git a/scripts/build-sw.js b/scripts/build-sw.js index 5950c10..a9d9d42 100644 --- a/scripts/build-sw.js +++ b/scripts/build-sw.js @@ -7,6 +7,7 @@ const shell = [ "/icon.svg", "/manifest.webmanifest", "/icons/apple-touch-icon.png", + "/icons/apple-touch-icon-v2.png", "/icons/icon-192.png", "/icons/icon-512.png", "/icons/maskable-512.png", diff --git a/scripts/container-smoke.js b/scripts/container-smoke.js index 138da23..2d0028e 100644 --- a/scripts/container-smoke.js +++ b/scripts/container-smoke.js @@ -131,6 +131,7 @@ try { "/sw.js", "/manifest.webmanifest", "/icons/apple-touch-icon.png", + "/icons/apple-touch-icon-v2.png", ]) assert.equal((await request(path)).status, 200, path); const html = await (await request("/")).text(); diff --git a/scripts/generate-icons.ps1 b/scripts/generate-icons.ps1 index a5bd3f0..f567232 100644 --- a/scripts/generate-icons.ps1 +++ b/scripts/generate-icons.ps1 @@ -1,21 +1,25 @@ Add-Type -AssemblyName System.Drawing $iconRoot = Join-Path $PSScriptRoot '../public/icons' New-Item -ItemType Directory -Force -Path $iconRoot | Out-Null -foreach ($iconSpec in @(@('icon-192.png',192), @('icon-512.png',512), @('maskable-512.png',512), @('apple-touch-icon.png',180))) { +foreach ($iconSpec in @(@('icon-192.png',192), @('icon-512.png',512), @('maskable-512.png',512), @('apple-touch-icon.png',180), @('apple-touch-icon-v2.png',180))) { $iconSize = [int]$iconSpec[1] $bitmap = New-Object System.Drawing.Bitmap($iconSize,$iconSize) $graphics = [System.Drawing.Graphics]::FromImage($bitmap) $graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias $graphics.ScaleTransform($iconSize / 192.0, $iconSize / 192.0) - $graphics.Clear([System.Drawing.ColorTranslator]::FromHtml('#8391ed')) - $cream = New-Object System.Drawing.SolidBrush([System.Drawing.ColorTranslator]::FromHtml('#f5f5ef')) + $isAppleIcon = $iconSpec[0].StartsWith('apple-touch-icon') + $backgroundColor = if ($isAppleIcon) { '#121318' } else { '#8391ed' } + $glyphColor = if ($isAppleIcon) { '#f4f4f8' } else { '#f5f5ef' } + $leafColor = if ($isAppleIcon) { '#f4f4f8' } else { '#cad1ff' } + $graphics.Clear([System.Drawing.ColorTranslator]::FromHtml($backgroundColor)) + $cream = New-Object System.Drawing.SolidBrush([System.Drawing.ColorTranslator]::FromHtml($glyphColor)) $ringPen = New-Object System.Drawing.Pen($cream,8) $graphics.DrawEllipse($ringPen,48,54,96,96) foreach ($point in @(@(72,112),@(95,122),@(118,112),@(96,99))) { $graphics.FillEllipse($cream,($point[0]-8),($point[1]-8),16,16) } $leaf = New-Object System.Drawing.Drawing2D.GraphicsPath $leaf.AddBezier(96,50,94,27,119,26,120,27) $leaf.AddBezier(120,27,120,44,105,51,96,50) - $green = New-Object System.Drawing.SolidBrush([System.Drawing.ColorTranslator]::FromHtml('#cad1ff')) + $green = New-Object System.Drawing.SolidBrush([System.Drawing.ColorTranslator]::FromHtml($leafColor)) $graphics.FillPath($green,$leaf) $bitmap.Save((Join-Path $iconRoot $iconSpec[0]),[System.Drawing.Imaging.ImageFormat]::Png) $graphics.Dispose(); $bitmap.Dispose(); $cream.Dispose(); $ringPen.Dispose(); $leaf.Dispose(); $green.Dispose() diff --git a/src/App.tsx b/src/App.tsx index b88181e..6f27dc0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -207,6 +207,106 @@ function SignIn({ ); } +function MealJournal({ + dayEntries, + settings, + add, + edit, + remove, +}: { + dayEntries: JournalRecord[]; + settings: SettingsData; + add: (meal: Meal) => void; + edit: (record: JournalRecord) => void; + remove: (record: JournalRecord) => void; +}) { + const mealIcons = { + Breakfast: Coffee, + Lunch: Sun, + Dinner: Moon, + Snacks: Sparkles, + }; + return ( +
+
+
+ SAVOR THE EVERYDAY +

On the menu

+
+ + {dayEntries.length} {dayEntries.length === 1 ? "entry" : "entries"} + +
+ {meals.map((meal) => { + const rows = dayEntries + .filter((r) => r.data.meal === meal) + .sort( + (a, b) => + (a.data.time || "").localeCompare(b.data.time || "") || + a.id.localeCompare(b.id), + ); + const calories = totalNutrients(rows.map((r) => r.data)).calories; + const Icon = mealIcons[meal]; + return ( +
+
+ + + +

{meal}

+ {rows.length > 0 && ( + + {number(calories)} kcal + + )} + +
+ {rows.length ? ( + rows.map((r) => ( +
+ + + {number(r.data.nutrients.calories * r.data.quantity)} + kcal + + +
+ )) + ) : ( + + )} +
+ ); + })} +
+ ); +} function Dashboard({ records, settings, @@ -216,6 +316,7 @@ function Dashboard({ edit, remove, openLibrary, + syncControl, }: { records: JournalRecord[]; settings: SettingsData; @@ -225,7 +326,10 @@ function Dashboard({ edit: (r: JournalRecord) => void; remove: (r: JournalRecord) => void; openLibrary: () => void; + syncControl: ReactNode; }) { + const [journalOpen, setJournalOpen] = useState(false); + const closeJournal = useCallback(() => setJournalOpen(false), []); const entries = recordsOf(records, "entry"); const dayEntries = entries.filter((r) => r.data.date === date); const totals = totalNutrients(dayEntries.map((r) => r.data)); @@ -243,18 +347,18 @@ function Dashboard({ (m) => m.key !== "calories" && settings.goals[m.key].enabled, ); const goal = settings.goals.calories; - const mealIcons = { - Breakfast: Coffee, - Lunch: Sun, - Dinner: Moon, - Snacks: Sparkles, - }; + return ( <> -
+
EVERYDAY, IN BALANCE -

+

+ {date === today() + ? "Today" + : displayDate(date, { weekday: "long" })} +

+

{date === today() ? "A little better, today" : displayDate(date, { weekday: "long" })} @@ -270,6 +374,7 @@ function Dashboard({

+
{syncControl}
{tracked.length > 0 ? ( -
+
3 ? 0 : -1} + > {tracked.map((m) => { const target = settings.goals[m.key].target; return ( @@ -392,6 +502,15 @@ function Dashboard({ Your day, with only the details you choose to track.

)} +
@@ -401,89 +520,14 @@ function Dashboard({
-
-
-
-
- SAVOR THE EVERYDAY -

On the menu

-
- - {dayEntries.length}{" "} - {dayEntries.length === 1 ? "entry" : "entries"} - -
- {meals.map((meal) => { - const rows = dayEntries - .filter((r) => r.data.meal === meal) - .sort( - (a, b) => - (a.data.time || "").localeCompare(b.data.time || "") || - a.id.localeCompare(b.id), - ); - const calories = totalNutrients(rows.map((r) => r.data)).calories; - const Icon = mealIcons[meal]; - return ( -
-
- - - -

{meal}

- {rows.length > 0 && ( - - {number(calories)} kcal - - )} - -
- {rows.length ? ( - rows.map((r) => ( -
- - - {number(r.data.nutrients.calories * r.data.quantity)} - kcal - - -
- )) - ) : ( - - )} -
- ); - })} -
+
+
+ {journalOpen && ( + + { + closeJournal(); + add(meal); + }} + edit={(record) => { + closeJournal(); + edit(record); + }} + remove={(record) => { + closeJournal(); + remove(record); + }} + /> + + )}
✳A little consistency. A lot of possibility. @@ -532,9 +600,9 @@ function Library({
FAMILIAR FAVORITES

- Your everyday staples. + Library.

-

A little less effort, every time you log.

+

Foods, plates and nutrition history.

{tab !== "trends" && ( + ); return ( -
diff --git a/src/Trends.tsx b/src/Trends.tsx index c770c77..fd62aa0 100644 --- a/src/Trends.tsx +++ b/src/Trends.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { ArrowDownRight, ArrowUpRight, @@ -41,6 +41,8 @@ export function Trends({ const [period, setPeriod] = useState(7); const [end, setEnd] = useState(today()); const [metric, setMetric] = useState("calories"); + const chartRef = useRef(null); + const [chartWidth, setChartWidth] = useState(600); const start = offsetDay(end, 1 - period); const entries = recordsOf(records, "entry"); const allWeights = recordsOf(records, "weight").sort( @@ -55,6 +57,15 @@ export function Trends({ const dailyWeights = [ ...new Map(weights.map((r) => [r.data.date, r])).values(), ]; + const hasWeights = dailyWeights.length > 0; + useEffect(() => { + if (!chartRef.current) return; + const observer = new ResizeObserver(([entry]) => + setChartWidth(Math.max(160, entry.contentRect.width)), + ); + observer.observe(chartRef.current); + return () => observer.disconnect(); + }, [mode, hasWeights]); const days = Array.from({ length: period }, (_, i) => { const date = offsetDay(start, i); const logs = entries.filter((r) => r.data.date === date); @@ -83,7 +94,7 @@ export function Trends({ 28 + ((new Date(r.data.date).getTime() - new Date(start).getTime()) / ((period - 1) * 86400000)) * - 544, + (chartWidth - 56), y: 170 - ((values[i] - minWeight) / (maxWeight - minWeight)) * 140, })); const delta = values.length > 1 ? values.at(-1)! - values[0] : null; @@ -238,29 +249,29 @@ export function Trends({
{number(values.at(-1)!, 1)} {settings.unit}
-
+
{displayDate(start, { month: "short", day: "numeric" })} - + {displayDate(end, { month: "short", day: "numeric" })} diff --git a/src/main.tsx b/src/main.tsx index c113af2..79e31b4 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,6 +2,7 @@ import React from "react"; import { createRoot } from "react-dom/client"; import { App } from "./App"; import "./styles.css"; +import "./mobile.css"; createRoot(document.getElementById("root")!).render( diff --git a/src/mobile.css b/src/mobile.css new file mode 100644 index 0000000..e0536f0 --- /dev/null +++ b/src/mobile.css @@ -0,0 +1,1001 @@ +/* Phone layout: readable type, touch-sized controls, and a viewport-sized Today. */ +.mobile-today-title, +.mobile-journal-button, +.mobile-home-sync { + display: none; +} + +@media (max-width: 760px), (max-width: 1000px) and (max-height: 500px) { + :root { + --safe-top: env(safe-area-inset-top, 0px); + --safe-bottom: env(safe-area-inset-bottom, 0px); + --mobile-nav-height: calc(76px + var(--safe-bottom)); + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + } + body { + font-size: 16px; + } + .sidebar { + display: none; + } + .main-wrap { + margin-left: 0; + padding-bottom: var(--mobile-nav-height); + } + .breadcrumb, + .profile-avatar, + .desktop-add { + display: none; + } + .topbar .mobile-brand { + display: flex; + margin-right: auto; + } + .topbar { + height: auto; + min-height: calc(60px + var(--safe-top)); + padding: calc(8px + var(--safe-top)) 20px 8px; + } + .topbar .brand { + font-size: 25px; + } + .topbar .brand img { + width: 28px; + height: 28px; + } + .sync-indicator { + font-size: 12px; + gap: 6px; + min-height: 44px; + } + main { + padding: 20px 20px 24px; + } + .page-heading { + gap: 14px; + margin-bottom: 24px; + align-items: center; + } + .page-heading h1 { + font-size: 32px; + letter-spacing: -1px; + margin: 0 0 8px; + } + .page-heading p { + font-size: 15px; + line-height: 1.4; + } + .page-heading .eyebrow, + .card-title .eyebrow, + .sheet-head .eyebrow { + display: none; + } + .card-title { + gap: 12px; + margin-bottom: 20px; + } + .card-title h2, + .settings-card .card-title h2, + .weight-journal .card-title h2 { + font-size: 24px; + } + .primary, + .secondary, + .danger-button, + .page-heading > .primary { + min-height: 50px; + font-size: 16px; + padding: 12px 16px; + border-radius: 14px; + } + .icon-button { + min-width: 44px; + min-height: 44px; + width: 44px; + height: 44px; + } + .text-button { + min-height: 44px; + font-size: 15px; + } + .small, + .settings-card .small, + .install-tip { + font-size: 14px; + line-height: 1.5; + } + .pill, + .weight-journal .pill, + .tiny-badge { + font-size: 12px; + padding: 8px 10px; + } + .subtle-number { + font-size: 14px; + } + .bottom-nav { + display: grid; + grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr; + position: fixed; + align-items: center; + bottom: 0; + left: 0; + right: 0; + z-index: 10; + border-top: 1px solid var(--line); + background: var(--nav-bg); + backdrop-filter: blur(18px); + height: var(--mobile-nav-height); + padding: 8px 12px calc(8px + var(--safe-bottom)); + gap: 4px; + } + .bottom-nav > button { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: var(--muted); + height: 56px; + gap: 5px; + min-width: 0; + } + .bottom-nav > button > svg { + width: 25px; + height: 25px; + } + .bottom-nav > button > span { + font-size: 12px; + } + .bottom-nav > button.active { + color: var(--accent-text); + } + .bottom-nav > .nav-add { + background: var(--accent); + color: var(--on-accent); + margin: auto; + width: 56px; + height: 56px; + border-radius: 19px; + } + .bottom-nav > .nav-add svg { + width: 30px; + height: 30px; + } + .toast { + font-size: 15px; + bottom: calc(var(--mobile-nav-height) + 12px); + padding: 14px 18px; + } + .notice { + font-size: 14px; + padding: 12px; + } + .notice > button { + font-size: 14px; + min-height: 44px; + } + + /* The home is a dashboard, not the top of a scrolling journal. */ + html:has(.page-today), + body:has(.page-today) { + height: 100%; + overflow: hidden; + overscroll-behavior-y: none; + } + .page-today { + height: 100vh; + height: 100dvh; + overflow: hidden; + } + .page-today .main-wrap { + height: 100%; + display: flex; + flex-direction: column; + padding-top: var(--safe-top); + padding-bottom: var(--mobile-nav-height); + } + .page-today .topbar { + display: none; + } + .page-today main { + display: flex; + flex-direction: column; + flex: 1; + min-height: 0; + width: 100%; + padding: 12px 20px 10px; + } + .today-heading { + flex: none; + margin: 0 0 8px; + position: relative; + display: block; + } + .today-heading .desktop-today-title { + display: none; + } + .mobile-today-title { + display: block; + } + .today-heading .mobile-today-title { + font-size: 32px; + margin: 0 104px 4px 0; + } + .today-heading p { + font-size: 15px; + } + .today-heading .heading-actions { + position: absolute; + top: 0; + right: 0; + gap: 6px; + } + .mobile-home-sync { + display: block; + } + .mobile-home-sync .sync-indicator { + width: 44px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + } + .mobile-home-sync .sync-indicator > span:last-child { + display: none; + } + .mobile-home-sync .status-dot { + width: 8px; + height: 8px; + } + .today-heading .date-picker-button { + display: flex; + width: 48px; + min-width: 48px; + height: 48px; + border-radius: 16px; + padding: 12px; + } + .today-heading .date-picker-button > span { + display: none; + } + .page-today .dashboard-grid { + flex: 1; + min-height: 0; + display: flex; + gap: 0; + } + .page-today .balance-card { + display: flex; + flex-direction: column; + flex: 1; + min-height: 0; + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + box-shadow: none; + overflow: visible; + } + .page-today .balance-card > .card-title, + .page-today .balance-footer, + .page-today .desktop-journal, + .page-today .page-footnote { + display: none; + } + .page-today .week-strip { + flex: none; + height: 60px; + margin: 0 -10px 4px; + gap: 0; + } + .page-today .week-day { + flex: 1; + min-width: 0; + height: 58px; + min-height: 58px; + padding: 5px 0; + gap: 3px; + border-radius: 20px; + } + .page-today .week-day strong { + font-size: 17px; + } + .page-today .week-day > span { + font-size: 12px; + } + .page-today .week-arrow { + min-width: 26px; + width: 26px; + padding: 0; + } + .page-today .orb-shell { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + container-type: size; + } + .page-today .orb { + flex: none; + width: min(100%, calc(100dvh - 440px)); + height: auto; + margin: 0; + } + @supports (width: 1cqh) { + .page-today .orb { + width: min(100cqw, max(0px, calc(100cqh - 90px))); + } + } + .page-today .orb-number.orb-number-outside { + flex: none; + min-height: 80px; + margin: 6px 0 0; + gap: 2px; + } + .page-today .orb-number.orb-number-outside strong { + font-size: 46px; + line-height: 1.05; + } + .page-today .orb-number.orb-number-outside .eyebrow { + font-size: 11px; + letter-spacing: 1.5px; + } + .page-today .orb-number.orb-number-outside .orb-unit { + font-size: 14px; + } + .page-today .calorie-summary { + flex: none; + height: 38px; + padding: 4px 0 10px; + gap: 18px; + } + .page-today .calorie-summary > div { + font-size: 13px; + gap: 6px; + } + .page-today .calorie-summary strong { + font-size: 18px; + } + .page-today .macro-grid { + flex: none; + flex-wrap: nowrap; + gap: 16px; + padding: 12px 0 14px; + min-height: 84px; + overflow-x: auto; + overflow-y: hidden; + scroll-snap-type: x mandatory; + scrollbar-width: thin; + } + .page-today .macro-grid:has(.macro:nth-child(4)) { + justify-content: flex-start; + } + .page-today .macro-grid > .macro { + flex: 0 0 calc((100% - 32px) / 3); + scroll-snap-align: start; + } + .page-today .macro-label { + font-size: 14px; + gap: 5px; + margin-bottom: 7px; + } + .page-today .macro strong { + font-size: 24px; + } + .page-today .macro > div > span { + font-size: 12px; + } + .page-today .progress-track { + height: 6px; + margin-top: 9px; + } + .page-today .balance-card > .centered { + flex: none; + font-size: 14px; + margin: 10px 0; + } + .mobile-journal-button { + display: flex; + flex: none; + gap: 10px; + width: 100%; + margin-top: 4px; + min-height: 48px; + } + .mobile-journal-button > span:first-of-type { + flex: 1; + text-align: left; + } + .journal-count { + color: var(--muted); + font-size: 15px; + } + .page-today main > .notice { + flex: none; + max-height: 100px; + overflow-y: auto; + margin-bottom: 6px; + } + + /* Native Safari controls must never contribute an intrinsic grid width. */ + label { + font-size: 16px; + } + input:not([type="checkbox"]), + select, + textarea, + .sheet input:not([type="checkbox"]), + .sheet select, + .sheet textarea, + .settings-card input:not([type="checkbox"]), + .settings-card select { + display: block; + box-sizing: border-box; + width: 100%; + inline-size: 100%; + min-width: 0; + min-inline-size: 0; + max-width: 100%; + max-inline-size: 100%; + min-height: 52px; + font-size: 18px; + line-height: 1.4; + padding: 12px 14px; + border-radius: 13px; + } + input[type="date"], + input[type="time"] { + appearance: none; + -webkit-appearance: none; + overflow: hidden; + } + input::-webkit-date-and-time-value { + text-align: left; + min-height: 1.4em; + } + input::-webkit-datetime-edit { + padding: 0; + min-width: 0; + } + .date-picker-button input { + position: absolute; + margin: 0; + min-height: 0; + height: 100%; + padding: 0; + } + .sheet { + width: calc(100% - 2px); + max-height: calc(100dvh - var(--safe-top) - 8px); + padding: 26px 20px calc(24px + var(--safe-bottom)); + overflow-x: hidden; + } + .sheet-head { + position: sticky; + top: 0; + z-index: 3; + background: var(--surface); + padding: 8px 0 12px; + align-items: flex-start; + gap: 10px; + margin-bottom: 20px; + } + .sheet-head h2 { + font-size: 27px; + line-height: 1.2; + margin-top: 0; + } + .sheet-head p { + font-size: 15px; + line-height: 1.4; + } + .sheet-head > .icon-button { + margin: -4px -4px 0 0; + } + .sheet .segmented > button { + font-size: 15px; + min-height: 44px; + padding: 8px 5px; + white-space: normal; + } + .sheet .entry-details { + grid-template-columns: minmax(0, 1fr); + gap: 14px; + } + .sheet .entry-details > label:first-child { + grid-column: auto; + } + .sheet label { + font-size: 16px; + line-height: 1.4; + } + .sheet form > label, + .sheet form > .form-row { + margin-top: 20px; + } + .sheet .section-caption { + font-size: 15px; + flex-wrap: wrap; + gap: 4px; + } + .sheet .section-caption > span:last-child { + display: none; + } + .nutrient-fields { + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 16px; + } + .nutrient-fields label:first-child { + font-size: 16px; + grid-column: 1 / -1; + padding: 10px 14px; + } + .settings-grid { + grid-template-columns: minmax(0, 1fr); + } + .nutrient-fields label:first-child .unit-input { + width: 55%; + min-width: 0; + } + .nutrient-fields label:first-child input { + font-size: 22px; + } + .sheet .unit-input > span, + .unit-input > span { + font-size: 14px; + padding-right: 12px; + } + .check-row, + .export-options .check-row { + min-height: 48px; + font-size: 16px; + gap: 12px; + } + .check-row input { + width: 24px; + height: 24px; + } + .sheet form > .primary { + min-height: 54px; + font-size: 17px; + } + .picker-row strong { + font-size: 17px; + } + .picker-row small { + font-size: 14px; + line-height: 1.5; + } + .error { + font-size: 15px; + } + .sheet .meals-card { + border: 0; + box-shadow: none; + background: transparent; + padding: 0; + } + .sheet .meals-card > .card-title { + display: none; + } + .meal-heading h3 { + font-size: 19px; + } + .meal-icon { + width: 40px; + height: 40px; + } + .meal-total { + font-size: 16px; + } + .food-log-row { + padding-left: 0; + gap: 8px; + padding-top: 10px; + } + .food-log-copy { + min-height: 54px; + padding: 6px 0; + } + .food-log-copy > strong { + font-size: 17px; + line-height: 1.4; + } + .food-log-copy > small { + font-size: 14px; + line-height: 1.5; + margin-top: 4px; + } + .entry-calories { + font-size: 19px; + } + .entry-calories small { + font-size: 12px; + } + .empty-meal { + min-height: 48px; + font-size: 15px; + margin-left: 0; + } + .delete-entry { + opacity: 1; + } + + /* The remaining tabs scroll normally, with the same mobile type and targets. */ + .settings-card, + .chart-card, + .weight-journal { + padding: 20px; + border-radius: 22px; + } + .settings-card > .muted, + .settings-card p, + .chart-note { + font-size: 15px; + } + .goal-head { + font-size: 12px; + margin-top: 24px; + } + .goal-row, + .settings-card .goal-row { + min-height: 78px; + padding: 12px 0; + gap: 10px; + } + .toggle-label { + font-size: 17px; + gap: 12px; + min-height: 48px; + } + .switch { + width: 51px; + height: 31px; + border-radius: 20px; + } + .switch:after { + width: 25px; + height: 25px; + top: 3px; + left: 3px; + } + .switch:checked:after { + transform: translateX(20px); + } + .goal-input { + width: 122px; + flex: none; + } + .settings-card .goal-input input { + font-size: 18px; + padding: 10px 6px; + } + .goal-input > span { + min-width: 28px; + padding-right: 8px; + font-size: 13px; + } + .settings-section h3 { + font-size: 20px; + } + .preference-row { + font-size: 16px; + flex-wrap: wrap; + } + .preference-row select { + width: auto; + max-width: 100%; + font-size: 16px; + } + .field-caption { + font-size: 12px; + } + .accent-swatches { + flex-wrap: wrap; + gap: 6px; + } + .accent-swatches > button { + width: 44px; + height: 44px; + } + .custom-accent { + font-size: 16px; + } + .custom-accent input[type="color"] { + width: 48px; + height: 48px; + min-height: 48px; + padding: 4px; + } + .segmented > button, + .theme-control > button, + .trend-controls > .segmented > button { + font-size: 15px; + min-height: 44px; + padding: 8px 6px; + } + .segmented > button > span { + font-size: 13px; + } + .library-controls > .segmented { + align-self: stretch; + } + .library-controls .search-field input { + font-size: 18px; + min-height: 52px; + padding-left: 44px; + } + .library-grid { + grid-template-columns: minmax(0, 1fr); + gap: 16px; + } + .library-card { + padding: 20px; + } + .library-food-info h3 { + font-size: 20px; + } + .library-food-info p { + font-size: 15px; + } + .food-macros { + font-size: 14px; + } + .library-card-actions .text-button { + font-size: 15px; + } + .empty { + padding: 32px 12px; + } + .empty h3 { + font-size: 21px; + } + .empty p { + font-size: 16px; + line-height: 1.55; + } + .library-empty { + min-height: 300px; + } + .library-bottom { + font-size: 14px; + gap: 12px; + } + .library-bottom > button { + margin-left: 0; + } + .date-controls { + font-size: 15px; + } + .stat-large { + font-size: 36px; + } + .stat-large > span { + font-size: 15px; + } + .chart-card select { + width: auto; + max-width: 52%; + font-size: 16px; + } + .bar-chart { + height: 220px; + } + .bar-slot > span, + .chart-grid-lines { + font-size: 12px; + } + .weight-chart { + height: 220px; + } + .weight-axis, + .weight-chart svg text { + font-size: 14px; + } + .journal-row { + gap: 10px; + } + .journal-row .row-copy strong { + font-size: 18px; + } + .journal-row .row-copy small { + font-size: 14px; + line-height: 1.5; + } + .export-options { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .login-form > label, + .login-form > p { + font-size: 16px; + } + .login-form > .primary { + min-height: 52px; + font-size: 17px; + } + .login-note { + font-size: 14px; + } + .status-detail strong { + font-size: 16px; + } + .status-detail small, + .account-row > div { + font-size: 14px; + } + .account-row small { + font-size: 12px; + } + .account-row .text-button { + font-size: 15px; + } +} + +@media (max-width: 365px) { + .page-today main { + padding-inline: 16px; + } + main { + padding-inline: 16px; + } + .page-heading h1, + .today-heading .mobile-today-title { + font-size: 29px; + } + .page-today .macro-label { + font-size: 14px; + } + .page-today .macro > div > span { + font-size: 11px; + } + .page-today .macro strong { + font-size: 22px; + } + .goal-row .toggle-label { + font-size: 16px; + gap: 8px; + } + .goal-input { + width: 106px; + } + .settings-card { + padding-inline: 16px; + } +} + +@media (max-width: 760px) and (max-height: 680px) { + .page-today main { + padding-top: 6px; + padding-bottom: 6px; + } + .today-heading .mobile-today-title { + font-size: 28px; + } + .today-heading p { + font-size: 14px; + } + .page-today .week-strip { + height: 52px; + margin-bottom: 0; + } + .page-today .week-day { + min-height: 50px; + height: 50px; + } + .page-today .orb-number.orb-number-outside { + min-height: 70px; + margin-top: 2px; + } + .page-today .orb-number.orb-number-outside strong { + font-size: 38px; + } + .page-today .macro-grid { + min-height: 78px; + padding: 8px 0 10px; + } +} + +@media (max-width: 1000px) and (max-height: 500px) { + .page-today main { + padding: 6px 20px; + } + .today-heading { + margin-bottom: 4px; + } + .today-heading .mobile-today-title { + font-size: 25px; + } + .today-heading p { + font-size: 14px; + } + .page-today .balance-card { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); + grid-template-rows: 40px 30px minmax(62px, 1fr) 44px; + column-gap: 20px; + } + .page-today .week-strip { + display: none; + } + .page-today .orb-shell { + display: contents; + container-type: normal; + } + .page-today .orb { + grid-column: 1; + grid-row: 1 / 5; + width: min( + 100%, + calc(100dvh - var(--safe-top) - var(--mobile-nav-height) - 72px) + ); + justify-self: center; + align-self: center; + } + .page-today .orb-number.orb-number-outside { + grid-column: 2; + grid-row: 1; + flex-direction: row; + min-height: 40px; + margin: 0; + gap: 8px; + } + .page-today .orb-number.orb-number-outside .eyebrow { + max-width: 100px; + } + .page-today .orb-number.orb-number-outside strong { + font-size: 32px; + } + .page-today .calorie-summary { + grid-column: 2; + grid-row: 2; + height: 30px; + padding: 0; + gap: 10px; + } + .page-today .calorie-summary strong { + font-size: 16px; + } + .page-today .calorie-summary > div { + font-size: 11px; + gap: 4px; + } + .page-today .macro-grid { + grid-column: 2; + grid-row: 3; + min-height: 62px; + padding: 6px 0; + gap: 10px; + } + .page-today .macro-grid > .macro { + flex-basis: calc((100% - 20px) / 3); + } + .page-today .macro-label { + margin-bottom: 3px; + } + .page-today .macro strong { + font-size: 20px; + } + .page-today .macro > div > span { + font-size: 11px; + } + .page-today .progress-track { + margin-top: 5px; + } + .mobile-journal-button { + grid-column: 2; + grid-row: 4; + height: 44px; + min-height: 44px; + padding: 8px 12px; + margin: 0; + } +} + +@media (max-width: 760px) and (min-height: 501px) and (max-height: 600px) { + .page-today .week-strip { + display: none; + } +} diff --git a/tests/browser/mobile-layout.check.js b/tests/browser/mobile-layout.check.js new file mode 100644 index 0000000..038ef91 --- /dev/null +++ b/tests/browser/mobile-layout.check.js @@ -0,0 +1,37 @@ +// Run this expression with the browser tool's read-only evaluate API at phone sizes. +// Exercise Today, Settings and an open food editor; every returned check must pass. +(() => { + const checks = {}; + const font = (element) => getComputedStyle(element).fontSize.split('px')[0] * 1; + const visible = (selector) => [...document.querySelectorAll(selector)].filter(e => e.getBoundingClientRect().width > 0); + const dialog = document.querySelector('dialog[open]'); + checks.noHorizontalPageOverflow = document.documentElement.scrollWidth <= window.innerWidth + 1; + if (!dialog && visible('.dashboard-grid').length) { + checks.homeFitsViewport = document.documentElement.scrollHeight <= window.innerHeight + 1; + checks.macrosReadable = visible('.macro-label').every(e => font(e) >= 14); + const nav = document.querySelector('.bottom-nav').getBoundingClientRect(); + checks.homeControlsAboveNavigation = visible('.mobile-journal-button').length > 0 && visible('.mobile-journal-button').every(e => e.getBoundingClientRect().bottom <= nav.top + 1); + checks.macrosAboveNavigation = visible('.macro-grid').every(e => e.getBoundingClientRect().bottom <= nav.top + 1); + const orb = document.querySelector('.orb').getBoundingClientRect(); + checks.circleRemainsVisible = orb.width >= 100 && orb.height >= 100; + if (window.innerHeight > 500) { + const number = document.querySelector('.orb-number').getBoundingClientRect(); + checks.circleAndReadoutDoNotOverlap = orb.bottom <= number.top + 1; + } + } + checks.navigationReadable = visible('.bottom-nav button span').every(e => font(e) >= 12); + checks.navigationTapTargets = visible('.bottom-nav button').every(e => e.getBoundingClientRect().height >= 44); + if (!dialog && visible('.settings-card .switch').length) { + checks.switchSize = visible('.switch').every(e => { const r=e.getBoundingClientRect(); return r.width >= 44 && r.height >= 28; }); + checks.settingsLabelsReadable = visible('.toggle-label').every(e => font(e) >= 16); + } + if (dialog) { + checks.dialogFitsWidth = dialog.scrollWidth <= dialog.clientWidth + 1; + checks.nativeFieldsStayInColumns = visible('dialog input[type="date"], dialog input[type="time"]').every(e => e.getBoundingClientRect().right <= e.parentElement.getBoundingClientRect().right + 1); + checks.formLabelsReadable = visible('dialog label').every(e => font(e) >= 14); + checks.formControlsReadable = visible('dialog input:not([type="checkbox"]), dialog select').every(e => font(e) >= 16 && e.getBoundingClientRect().height >= 48); + } + const weightChart = visible('.weight-chart svg')[0]; + if (weightChart) checks.weightChartTextNotShrunk = weightChart.getBoundingClientRect().width / (weightChart.getAttribute('viewBox').split(' ')[2] * 1) >= 0.9; + return {pass: Object.values(checks).every(Boolean), checks}; +})()