Mobile UI redesign and size fixes
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
This commit is contained in:
parent
ddea7fc512
commit
b19de6f9ea
17 changed files with 1292 additions and 131 deletions
BIN
.vs/Calorie Tracker.slnx/v18/.wsuo
Normal file
BIN
.vs/Calorie Tracker.slnx/v18/.wsuo
Normal file
Binary file not shown.
12
.vs/Calorie Tracker.slnx/v18/DocumentLayout.json
Normal file
12
.vs/Calorie Tracker.slnx/v18/DocumentLayout.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Elijah\\Desktop\\Calorie Tracker\\",
|
||||
"Documents": [],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": []
|
||||
}
|
||||
]
|
||||
}
|
||||
6
.vs/VSWorkspaceState.json
Normal file
6
.vs/VSWorkspaceState.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
],
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
BIN
.vs/slnx.sqlite
Normal file
BIN
.vs/slnx.sqlite
Normal file
Binary file not shown.
10
README.md
10
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.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@
|
|||
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="icon" href="/icon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png" />
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="180x180"
|
||||
href="/icons/apple-touch-icon-v2.png"
|
||||
/>
|
||||
<title>Calio · Everyday, in balance</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
BIN
public/icons/apple-touch-icon-v2.png
Normal file
BIN
public/icons/apple-touch-icon-v2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.1 KiB |
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
305
src/App.tsx
305
src/App.tsx
|
|
@ -207,6 +207,106 @@ function SignIn({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
function MealJournal({
|
||||
dayEntries,
|
||||
settings,
|
||||
add,
|
||||
edit,
|
||||
remove,
|
||||
}: {
|
||||
dayEntries: JournalRecord<Entry>[];
|
||||
settings: SettingsData;
|
||||
add: (meal: Meal) => void;
|
||||
edit: (record: JournalRecord<Entry>) => void;
|
||||
remove: (record: JournalRecord) => void;
|
||||
}) {
|
||||
const mealIcons = {
|
||||
Breakfast: Coffee,
|
||||
Lunch: Sun,
|
||||
Dinner: Moon,
|
||||
Snacks: Sparkles,
|
||||
};
|
||||
return (
|
||||
<section className="card meals-card">
|
||||
<div className="card-title">
|
||||
<div>
|
||||
<span className="eyebrow">SAVOR THE EVERYDAY</span>
|
||||
<h2>On the menu</h2>
|
||||
</div>
|
||||
<span className="subtle-number">
|
||||
{dayEntries.length} {dayEntries.length === 1 ? "entry" : "entries"}
|
||||
</span>
|
||||
</div>
|
||||
{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 (
|
||||
<div className="meal-section" key={meal}>
|
||||
<div className="meal-heading">
|
||||
<span className={"meal-icon meal-" + meal.toLowerCase()}>
|
||||
<Icon size={19} />
|
||||
</span>
|
||||
<h3>{meal}</h3>
|
||||
{rows.length > 0 && (
|
||||
<span className="meal-total">
|
||||
{number(calories)} <small>kcal</small>
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
className="icon-button add-meal"
|
||||
aria-label={`Add to ${meal.toLowerCase()}`}
|
||||
onClick={() => add(meal)}
|
||||
>
|
||||
<Plus size={18} />
|
||||
</button>
|
||||
</div>
|
||||
{rows.length ? (
|
||||
rows.map((r) => (
|
||||
<div className="food-log-row" key={r.id}>
|
||||
<button className="food-log-copy" onClick={() => edit(r)}>
|
||||
<strong>{r.data.name}</strong>
|
||||
<small>
|
||||
{r.data.time
|
||||
? displayTime(r.data.time)
|
||||
: "Time not recorded"}{" "}
|
||||
· {number(r.data.quantity, 2)} × {r.data.serving}
|
||||
{settings.goals.protein.enabled
|
||||
? ` · ${number(r.data.nutrients.protein * r.data.quantity, 1)}g protein`
|
||||
: ""}
|
||||
</small>
|
||||
</button>
|
||||
<span className="entry-calories">
|
||||
{number(r.data.nutrients.calories * r.data.quantity)}
|
||||
<small>kcal</small>
|
||||
</span>
|
||||
<button
|
||||
className="icon-button delete-entry"
|
||||
aria-label={`Delete ${r.data.name}`}
|
||||
onClick={() => remove(r)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<button className="empty-meal" onClick={() => add(meal)}>
|
||||
Something good belongs here.
|
||||
<Plus size={13} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
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<Entry>) => void;
|
||||
remove: (r: JournalRecord) => void;
|
||||
openLibrary: () => void;
|
||||
syncControl: ReactNode;
|
||||
}) {
|
||||
const [journalOpen, setJournalOpen] = useState(false);
|
||||
const closeJournal = useCallback(() => setJournalOpen(false), []);
|
||||
const entries = recordsOf<Entry>(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 (
|
||||
<>
|
||||
<div className="page-heading">
|
||||
<div className="page-heading today-heading">
|
||||
<div>
|
||||
<span className="eyebrow">EVERYDAY, IN BALANCE</span>
|
||||
<h1>
|
||||
<h1 className="mobile-today-title">
|
||||
{date === today()
|
||||
? "Today"
|
||||
: displayDate(date, { weekday: "long" })}
|
||||
</h1>
|
||||
<h1 className="desktop-today-title">
|
||||
{date === today()
|
||||
? "A little better, today"
|
||||
: displayDate(date, { weekday: "long" })}
|
||||
|
|
@ -270,6 +374,7 @@ function Dashboard({
|
|||
</p>
|
||||
</div>
|
||||
<div className="heading-actions">
|
||||
<div className="mobile-home-sync">{syncControl}</div>
|
||||
<button className="date-picker-button secondary">
|
||||
<span>
|
||||
{date === today()
|
||||
|
|
@ -359,7 +464,12 @@ function Dashboard({
|
|||
</div>
|
||||
</div>
|
||||
{tracked.length > 0 ? (
|
||||
<div className="macro-grid">
|
||||
<div
|
||||
className="macro-grid"
|
||||
role="region"
|
||||
aria-label="Tracked macros. Swipe horizontally for more."
|
||||
tabIndex={tracked.length > 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.
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
className="mobile-journal-button secondary"
|
||||
onClick={() => setJournalOpen(true)}
|
||||
>
|
||||
<Utensils size={21} />
|
||||
<span>Food journal</span>
|
||||
<span className="journal-count">{dayEntries.length}</span>
|
||||
<ChevronRight size={20} />
|
||||
</button>
|
||||
<div className="balance-footer">
|
||||
<Leaf size={15} />
|
||||
<span>
|
||||
|
|
@ -401,89 +520,14 @@ function Dashboard({
|
|||
</span>
|
||||
</div>
|
||||
</section>
|
||||
<div className="day-right">
|
||||
<section className="card meals-card">
|
||||
<div className="card-title">
|
||||
<div>
|
||||
<span className="eyebrow">SAVOR THE EVERYDAY</span>
|
||||
<h2>On the menu</h2>
|
||||
</div>
|
||||
<span className="subtle-number">
|
||||
{dayEntries.length}{" "}
|
||||
{dayEntries.length === 1 ? "entry" : "entries"}
|
||||
</span>
|
||||
</div>
|
||||
{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 (
|
||||
<div className="meal-section" key={meal}>
|
||||
<div className="meal-heading">
|
||||
<span className={"meal-icon meal-" + meal.toLowerCase()}>
|
||||
<Icon size={19} />
|
||||
</span>
|
||||
<h3>{meal}</h3>
|
||||
{rows.length > 0 && (
|
||||
<span className="meal-total">
|
||||
{number(calories)} <small>kcal</small>
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
className="icon-button add-meal"
|
||||
aria-label={`Add to ${meal.toLowerCase()}`}
|
||||
onClick={() => add(meal)}
|
||||
>
|
||||
<Plus size={18} />
|
||||
</button>
|
||||
</div>
|
||||
{rows.length ? (
|
||||
rows.map((r) => (
|
||||
<div className="food-log-row" key={r.id}>
|
||||
<button
|
||||
className="food-log-copy"
|
||||
onClick={() => edit(r)}
|
||||
>
|
||||
<strong>{r.data.name}</strong>
|
||||
<small>
|
||||
{r.data.time
|
||||
? displayTime(r.data.time)
|
||||
: "Time not recorded"}{" "}
|
||||
· {number(r.data.quantity, 2)} × {r.data.serving}
|
||||
{settings.goals.protein.enabled
|
||||
? ` · ${number(r.data.nutrients.protein * r.data.quantity, 1)}g protein`
|
||||
: ""}
|
||||
</small>
|
||||
</button>
|
||||
<span className="entry-calories">
|
||||
{number(r.data.nutrients.calories * r.data.quantity)}
|
||||
<small>kcal</small>
|
||||
</span>
|
||||
<button
|
||||
className="icon-button delete-entry"
|
||||
aria-label={`Delete ${r.data.name}`}
|
||||
onClick={() => remove(r)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<button className="empty-meal" onClick={() => add(meal)}>
|
||||
Something good belongs here.
|
||||
<Plus size={13} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
<div className="day-right desktop-journal">
|
||||
<MealJournal
|
||||
dayEntries={dayEntries}
|
||||
settings={settings}
|
||||
add={add}
|
||||
edit={edit}
|
||||
remove={remove}
|
||||
/>
|
||||
<button className="library-prompt" onClick={openLibrary}>
|
||||
<span className="prompt-icon">
|
||||
<BookOpen size={24} />
|
||||
|
|
@ -496,6 +540,30 @@ function Dashboard({
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{journalOpen && (
|
||||
<Modal
|
||||
title="Food journal"
|
||||
subtitle={displayDate(date)}
|
||||
close={closeJournal}
|
||||
>
|
||||
<MealJournal
|
||||
dayEntries={dayEntries}
|
||||
settings={settings}
|
||||
add={(meal) => {
|
||||
closeJournal();
|
||||
add(meal);
|
||||
}}
|
||||
edit={(record) => {
|
||||
closeJournal();
|
||||
edit(record);
|
||||
}}
|
||||
remove={(record) => {
|
||||
closeJournal();
|
||||
remove(record);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
<div className="page-footnote">
|
||||
<span className="little-star">✳</span>A little consistency. A lot of
|
||||
possibility.
|
||||
|
|
@ -532,9 +600,9 @@ function Library({
|
|||
<div>
|
||||
<span className="eyebrow">FAMILIAR FAVORITES</span>
|
||||
<h1>
|
||||
Your everyday staples<span>.</span>
|
||||
Library<span>.</span>
|
||||
</h1>
|
||||
<p>A little less effort, every time you log.</p>
|
||||
<p>Foods, plates and nutrition history.</p>
|
||||
</div>
|
||||
{tab !== "trends" && (
|
||||
<button
|
||||
|
|
@ -862,8 +930,32 @@ export function App() {
|
|||
: journal.outbox.length
|
||||
? `${journal.outbox.length} pending · saved on device`
|
||||
: "All changes synced";
|
||||
const syncControl = (
|
||||
<button
|
||||
className={
|
||||
"sync-indicator " +
|
||||
(!status.online || status.needsLogin || status.error
|
||||
? "sync-warning"
|
||||
: "")
|
||||
}
|
||||
onClick={() => (status.needsLogin ? setReauth(true) : void sync())}
|
||||
aria-label={syncLabel}
|
||||
title={status.error || syncLabel}
|
||||
>
|
||||
{!status.online ? (
|
||||
<WifiOff size={14} />
|
||||
) : status.busy ? (
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
) : status.needsLogin ? (
|
||||
<LockKeyhole size={14} />
|
||||
) : (
|
||||
<span className="status-dot" />
|
||||
)}
|
||||
<span>{syncLabel}</span>
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<div className={"app-shell page-" + page}>
|
||||
<aside className="sidebar">
|
||||
<a
|
||||
className="brand"
|
||||
|
|
@ -900,27 +992,7 @@ export function App() {
|
|||
<img src="/icon.svg" alt="" />
|
||||
calio
|
||||
</div>
|
||||
<button
|
||||
className={
|
||||
"sync-indicator " +
|
||||
(!status.online || status.needsLogin || status.error
|
||||
? "sync-warning"
|
||||
: "")
|
||||
}
|
||||
onClick={() => (status.needsLogin ? setReauth(true) : void sync())}
|
||||
title={status.error || syncLabel}
|
||||
>
|
||||
{!status.online ? (
|
||||
<WifiOff size={14} />
|
||||
) : status.busy ? (
|
||||
<LoaderCircle size={14} className="spin" />
|
||||
) : status.needsLogin ? (
|
||||
<LockKeyhole size={14} />
|
||||
) : (
|
||||
<span className="status-dot" />
|
||||
)}
|
||||
<span>{syncLabel}</span>
|
||||
</button>
|
||||
{syncControl}
|
||||
<span className="profile-avatar">
|
||||
E<span />
|
||||
</span>
|
||||
|
|
@ -961,6 +1033,7 @@ export function App() {
|
|||
}
|
||||
remove={setDeleting}
|
||||
openLibrary={() => setPage("library")}
|
||||
syncControl={syncControl}
|
||||
/>
|
||||
)}
|
||||
{page === "library" && (
|
||||
|
|
|
|||
|
|
@ -100,9 +100,9 @@ export function Settings({
|
|||
<div>
|
||||
<span className="eyebrow">MAKE ROOM FOR YOU</span>
|
||||
<h1>
|
||||
Your way<span>.</span>
|
||||
Settings<span>.</span>
|
||||
</h1>
|
||||
<p>A journal that fits your everyday.</p>
|
||||
<p>Goals, appearance and exports.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings-grid">
|
||||
|
|
|
|||
|
|
@ -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<Metric>("calories");
|
||||
const chartRef = useRef<HTMLDivElement>(null);
|
||||
const [chartWidth, setChartWidth] = useState(600);
|
||||
const start = offsetDay(end, 1 - period);
|
||||
const entries = recordsOf<Entry>(records, "entry");
|
||||
const allWeights = recordsOf<Weight>(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({
|
|||
<div className="stat-large">
|
||||
{number(values.at(-1)!, 1)} <span>{settings.unit}</span>
|
||||
</div>
|
||||
<div className="weight-chart">
|
||||
<div className="weight-chart" ref={chartRef}>
|
||||
<svg
|
||||
viewBox="0 0 600 210"
|
||||
viewBox={`0 0 ${chartWidth} 210`}
|
||||
role="img"
|
||||
aria-label={`${dailyWeights.length} weigh-ins, latest ${number(values.at(-1)!, 1)} ${settings.unit}`}
|
||||
>
|
||||
<line
|
||||
x1="28"
|
||||
x2="572"
|
||||
x2={chartWidth - 28}
|
||||
y1="30"
|
||||
y2="30"
|
||||
className="grid-line"
|
||||
/>
|
||||
<line
|
||||
x1="28"
|
||||
x2="572"
|
||||
x2={chartWidth - 28}
|
||||
y1="100"
|
||||
y2="100"
|
||||
className="grid-line"
|
||||
/>
|
||||
<line
|
||||
x1="28"
|
||||
x2="572"
|
||||
x2={chartWidth - 28}
|
||||
y1="170"
|
||||
y2="170"
|
||||
className="grid-line"
|
||||
|
|
@ -289,7 +300,7 @@ export function Trends({
|
|||
<text x="28" y="202">
|
||||
{displayDate(start, { month: "short", day: "numeric" })}
|
||||
</text>
|
||||
<text x="572" y="202" textAnchor="end">
|
||||
<text x={chartWidth - 28} y="202" textAnchor="end">
|
||||
{displayDate(end, { month: "short", day: "numeric" })}
|
||||
</text>
|
||||
</svg>
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
|
|
|
|||
1001
src/mobile.css
Normal file
1001
src/mobile.css
Normal file
File diff suppressed because it is too large
Load diff
37
tests/browser/mobile-layout.check.js
Normal file
37
tests/browser/mobile-layout.check.js
Normal file
|
|
@ -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};
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue