Extensive UI changes
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
6fc0a01c56
commit
ddea7fc512
16 changed files with 675 additions and 493 deletions
|
|
@ -5,10 +5,12 @@ A single-user, self-hosted nutrition journal. PWA first, with a responsive deskt
|
||||||
## Included
|
## Included
|
||||||
|
|
||||||
- Daily calorie vessel with colliding physics bubbles, week navigation, meal journal, editable entries, fractional servings. New bubbles drop from the top as calories increase.
|
- Daily calorie vessel with colliding physics bubbles, week navigation, meal journal, editable entries, fractional servings. New bubbles drop from the top as calories increase.
|
||||||
|
- Food names are optional: unnamed daily entries use the meal name and next available number, such as `Dinner 1`. The main Add food action suggests breakfast from 5–11am, lunch from 11am–4pm, dinner from 4–10pm and snacks overnight, using the device's local time. Meal-specific add buttons preserve their category; the selection remains editable.
|
||||||
|
- Food entries include an editable local clock time, shown in the journal and all export formats. Existing entries without a time remain valid and show “Time not recorded” until you add one. Entries sort by time within each meal.
|
||||||
- Saved foods and reusable plates. Logging a plate creates an atomic batch of independent food entries. Logs retain a nutrition snapshot when library foods change.
|
- Saved foods and reusable plates. Logging a plate creates an atomic batch of independent food entries. Logs retain a nutrition snapshot when library foods change.
|
||||||
- Independently enabled calorie, protein, carbohydrate, fat, fiber, sugar and sodium goals.
|
- Independently enabled calorie, protein, carbohydrate, fat, fiber, sugar and sodium goals.
|
||||||
- Weight journal in lb or kg; internally stored in kg. Multiple weigh-ins are retained, with the latest measurement per day used in charts.
|
- Weight journal in lb or kg; internally stored in kg. Multiple weigh-ins are retained, with the latest measurement per day used in charts.
|
||||||
- 7 / 30 / 90 / 365 day nutrition and weight trends. Unlogged days are excluded from intake averages.
|
- Dedicated Weight tab on desktop and mobile, with its own logging, graph and journal. Nutrition trends live under Library → Trends. Both support 7 / 30 / 90 / 365 day periods. Unlogged days are excluded from intake averages.
|
||||||
- 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.
|
- 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.
|
- Password authentication, IndexedDB offline journal/outbox, a precached app shell, automatic foreground/reconnect sync, and explicit PWA update prompts.
|
||||||
|
|
||||||
|
|
@ -66,9 +68,9 @@ To restore a database backup: stop Calio, preserve the current data directory, r
|
||||||
|
|
||||||
### Bubble motion
|
### Bubble motion
|
||||||
|
|
||||||
Tap **Enable tilt** beneath the calorie circle to allow device orientation. On iPhone, Safari asks for motion/orientation permission from that tap; the public site must use HTTPS. The app remembers the choice for the current page session and does not transmit sensor readings. Portrait, landscape and upside-down positions are mapped to the screen's gravity direction. Devices without sensors, or with permission denied, retain downward gravity and the **Give a nudge** control.
|
Enable **Settings → Look & feel → Tilt calorie bubbles** to allow device orientation. On iPhone, Safari asks for motion/orientation permission from that gesture; the public site must use HTTPS. The preference is stored only on this device, and iOS may require enabling it again after reopening the app. Sensor readings are never transmitted. Portrait, landscape and upside-down positions are mapped to the screen's gravity direction. Devices without sensors, or with permission denied, retain downward gravity.
|
||||||
|
|
||||||
The circle uses a bounded Matter.js simulation: bubbles collide with each other and the circular wall, new calorie bubbles drop from the top, and removing calories removes the corresponding particles. Bubbles draw smaller than their collision boundaries, creating a small visible gap between them. A full hexagonal packing defines the 100% capacity; near a full vessel, the numeric readout moves below the circle so it does not hide dots. The particle count caps at the daily goal; over-goal calories still show the exact excess and a red ring. With the calorie goal disabled, the display uses a fixed 2,500 kcal visual scale. The animation sleeps when settled, pauses in hidden tabs, and honors the device's reduced-motion preference with a still arrangement. The graphic is an approximate visual; the numeric calorie total is authoritative.
|
The circle uses a bounded Matter.js simulation: bubbles collide with each other and the circular wall, new calorie bubbles drop from the top at 30 per second (50% faster than the original pace), and removing calories removes the corresponding particles. Bubbles draw smaller than their collision boundaries, creating a small visible gap between them. A full hexagonal packing defines the 100% capacity. The numeric readout always sits below the circle, leaving every dot visible. The particle count caps at the daily goal; over-goal calories still show the exact excess and a red ring. With the calorie goal disabled, the display uses a fixed 2,500 kcal visual scale. Macro bars animate when totals change, and rows with one or two tracked macros are centered. Motion honors the device's reduced-motion preference. The physics animation sleeps when settled and pauses in hidden tabs. The graphic is an approximate visual; the numeric calorie total is authoritative.
|
||||||
|
|
||||||
## Forgejo CI and container registry
|
## Forgejo CI and container registry
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,8 @@ export function createBubbleWorld(initialCount = 0, random = Math.random) {
|
||||||
}
|
}
|
||||||
function step(delta = 1000 / 60) {
|
function step(delta = 1000 / 60) {
|
||||||
spawnTime += delta;
|
spawnTime += delta;
|
||||||
if (balls.length < target && spawnTime >= 45) {
|
// Two 60 Hz frames per bubble, previously three: 50% more arrivals/second.
|
||||||
|
if (balls.length < target && spawnTime >= 1000 / 30) {
|
||||||
spawnTime = 0;
|
spawnTime = 0;
|
||||||
// Each new bubble enters at the upper inside edge, then falls naturally.
|
// Each new bubble enters at the upper inside edge, then falls naturally.
|
||||||
const x = 160 + (random() - 0.5) * 55;
|
const x = 160 + (random() - 0.5) * 55;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ const food = z.object({
|
||||||
const entry = food
|
const entry = food
|
||||||
.extend({
|
.extend({
|
||||||
date,
|
date,
|
||||||
|
time: z
|
||||||
|
.string()
|
||||||
|
.regex(/^([01]\d|2[0-3]):[0-5]\d$/)
|
||||||
|
.optional(),
|
||||||
meal: z.enum(["Breakfast", "Lunch", "Dinner", "Snacks"]),
|
meal: z.enum(["Breakfast", "Lunch", "Dinner", "Snacks"]),
|
||||||
quantity: z.number().finite().positive().max(1000),
|
quantity: z.number().finite().positive().max(1000),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
22
shared/entry.js
Normal file
22
shared/entry.js
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/** @returns {'Breakfast' | 'Lunch' | 'Dinner' | 'Snacks'} */
|
||||||
|
export function suggestedMeal(date = new Date()) {
|
||||||
|
const hour = date.getHours();
|
||||||
|
if (hour >= 5 && hour < 11) return "Breakfast";
|
||||||
|
if (hour >= 11 && hour < 16) return "Lunch";
|
||||||
|
if (hour >= 16 && hour < 22) return "Dinner";
|
||||||
|
return "Snacks";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function localTime(date = new Date()) {
|
||||||
|
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nextFoodName(prefix, names) {
|
||||||
|
let highest = 0;
|
||||||
|
for (const name of names) {
|
||||||
|
if (!name.startsWith(prefix + " ")) continue;
|
||||||
|
const suffix = name.slice(prefix.length + 1);
|
||||||
|
if (/^\d+$/.test(suffix)) highest = Math.max(highest, Number(suffix));
|
||||||
|
}
|
||||||
|
return `${prefix} ${highest + 1}`;
|
||||||
|
}
|
||||||
175
src/App.tsx
175
src/App.tsx
|
|
@ -1,13 +1,17 @@
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
||||||
import {
|
import {
|
||||||
Activity,
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
import {
|
||||||
ArrowRight,
|
ArrowRight,
|
||||||
ArrowUpRight,
|
ArrowUpRight,
|
||||||
BookOpen,
|
BookOpen,
|
||||||
Check,
|
Check,
|
||||||
ChevronLeft,
|
ChevronLeft,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
CircleHelp,
|
|
||||||
CloudOff,
|
CloudOff,
|
||||||
Coffee,
|
Coffee,
|
||||||
Home,
|
Home,
|
||||||
|
|
@ -15,7 +19,6 @@ import {
|
||||||
LoaderCircle,
|
LoaderCircle,
|
||||||
LockKeyhole,
|
LockKeyhole,
|
||||||
Moon,
|
Moon,
|
||||||
MoreHorizontal,
|
|
||||||
Pencil,
|
Pencil,
|
||||||
Plus,
|
Plus,
|
||||||
Scale,
|
Scale,
|
||||||
|
|
@ -31,6 +34,7 @@ import {
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { defaultSettings, totalNutrients } from "../shared/domain.js";
|
import { defaultSettings, totalNutrients } from "../shared/domain.js";
|
||||||
import { accentPalette } from "../shared/theme.js";
|
import { accentPalette } from "../shared/theme.js";
|
||||||
|
import { suggestedMeal } from "../shared/entry.js";
|
||||||
import {
|
import {
|
||||||
deleteRecord,
|
deleteRecord,
|
||||||
initStore,
|
initStore,
|
||||||
|
|
@ -53,11 +57,11 @@ import {
|
||||||
import {
|
import {
|
||||||
dayDate,
|
dayDate,
|
||||||
displayDate,
|
displayDate,
|
||||||
|
displayTime,
|
||||||
number,
|
number,
|
||||||
offsetDay,
|
offsetDay,
|
||||||
recordsOf,
|
recordsOf,
|
||||||
today,
|
today,
|
||||||
weightValue,
|
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import {
|
import {
|
||||||
CalorieOrb,
|
CalorieOrb,
|
||||||
|
|
@ -70,7 +74,7 @@ import {
|
||||||
import { Trends } from "./Trends";
|
import { Trends } from "./Trends";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "./Settings";
|
||||||
|
|
||||||
type Page = "today" | "library" | "trends" | "settings";
|
type Page = "today" | "library" | "weight" | "settings";
|
||||||
type Editor =
|
type Editor =
|
||||||
| { kind: "log"; meal: Meal; record?: JournalRecord<Entry> }
|
| { kind: "log"; meal: Meal; record?: JournalRecord<Entry> }
|
||||||
| { kind: "food"; record?: JournalRecord<Food> }
|
| { kind: "food"; record?: JournalRecord<Food> }
|
||||||
|
|
@ -109,7 +113,7 @@ function SignIn({
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="login-orb">
|
<div className="login-orb">
|
||||||
<CalorieOrb value={1050} goal={2000} enabled interactive={false} />
|
<CalorieOrb value={1050} goal={2000} enabled />
|
||||||
<span className="art-label">
|
<span className="art-label">
|
||||||
<Leaf size={16} />
|
<Leaf size={16} />
|
||||||
Room to grow.
|
Room to grow.
|
||||||
|
|
@ -141,7 +145,6 @@ function SignIn({
|
||||||
<span className="login-lock">
|
<span className="login-lock">
|
||||||
<LockKeyhole size={24} />
|
<LockKeyhole size={24} />
|
||||||
</span>
|
</span>
|
||||||
<span className="eyebrow">YOUR PERSONAL SPACE</span>
|
|
||||||
<h2>{reauth ? "Welcome back." : "A fresh perspective."}</h2>
|
<h2>{reauth ? "Welcome back." : "A fresh perspective."}</h2>
|
||||||
<p>
|
<p>
|
||||||
{reauth
|
{reauth
|
||||||
|
|
@ -213,7 +216,6 @@ function Dashboard({
|
||||||
edit,
|
edit,
|
||||||
remove,
|
remove,
|
||||||
openLibrary,
|
openLibrary,
|
||||||
logWeight,
|
|
||||||
}: {
|
}: {
|
||||||
records: JournalRecord[];
|
records: JournalRecord[];
|
||||||
settings: SettingsData;
|
settings: SettingsData;
|
||||||
|
|
@ -223,7 +225,6 @@ function Dashboard({
|
||||||
edit: (r: JournalRecord<Entry>) => void;
|
edit: (r: JournalRecord<Entry>) => void;
|
||||||
remove: (r: JournalRecord) => void;
|
remove: (r: JournalRecord) => void;
|
||||||
openLibrary: () => void;
|
openLibrary: () => void;
|
||||||
logWeight: () => void;
|
|
||||||
}) {
|
}) {
|
||||||
const entries = recordsOf<Entry>(records, "entry");
|
const entries = recordsOf<Entry>(records, "entry");
|
||||||
const dayEntries = entries.filter((r) => r.data.date === date);
|
const dayEntries = entries.filter((r) => r.data.date === date);
|
||||||
|
|
@ -242,11 +243,6 @@ function Dashboard({
|
||||||
(m) => m.key !== "calories" && settings.goals[m.key].enabled,
|
(m) => m.key !== "calories" && settings.goals[m.key].enabled,
|
||||||
);
|
);
|
||||||
const goal = settings.goals.calories;
|
const goal = settings.goals.calories;
|
||||||
const latestWeight = recordsOf<Weight>(records, "weight").sort(
|
|
||||||
(a, b) =>
|
|
||||||
b.data.date.localeCompare(a.data.date) ||
|
|
||||||
b.updatedAt.localeCompare(a.updatedAt),
|
|
||||||
)[0];
|
|
||||||
const mealIcons = {
|
const mealIcons = {
|
||||||
Breakfast: Coffee,
|
Breakfast: Coffee,
|
||||||
Lunch: Sun,
|
Lunch: Sun,
|
||||||
|
|
@ -290,7 +286,10 @@ function Dashboard({
|
||||||
/>
|
/>
|
||||||
<ChevronRight size={16} />
|
<ChevronRight size={16} />
|
||||||
</button>
|
</button>
|
||||||
<button className="primary desktop-add" onClick={() => add("Snacks")}>
|
<button
|
||||||
|
className="primary desktop-add"
|
||||||
|
onClick={() => add(suggestedMeal())}
|
||||||
|
>
|
||||||
<Plus size={18} />
|
<Plus size={18} />
|
||||||
Add food
|
Add food
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -415,7 +414,13 @@ function Dashboard({
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{meals.map((meal) => {
|
{meals.map((meal) => {
|
||||||
const rows = dayEntries.filter((r) => r.data.meal === 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 calories = totalNutrients(rows.map((r) => r.data)).calories;
|
||||||
const Icon = mealIcons[meal];
|
const Icon = mealIcons[meal];
|
||||||
return (
|
return (
|
||||||
|
|
@ -447,7 +452,10 @@ function Dashboard({
|
||||||
>
|
>
|
||||||
<strong>{r.data.name}</strong>
|
<strong>{r.data.name}</strong>
|
||||||
<small>
|
<small>
|
||||||
{number(r.data.quantity, 2)} × {r.data.serving}
|
{r.data.time
|
||||||
|
? displayTime(r.data.time)
|
||||||
|
: "Time not recorded"}{" "}
|
||||||
|
· {number(r.data.quantity, 2)} × {r.data.serving}
|
||||||
{settings.goals.protein.enabled
|
{settings.goals.protein.enabled
|
||||||
? ` · ${number(r.data.nutrients.protein * r.data.quantity, 1)}g protein`
|
? ` · ${number(r.data.nutrients.protein * r.data.quantity, 1)}g protein`
|
||||||
: ""}
|
: ""}
|
||||||
|
|
@ -486,31 +494,6 @@ function Dashboard({
|
||||||
</span>
|
</span>
|
||||||
<ArrowUpRight size={21} />
|
<ArrowUpRight size={21} />
|
||||||
</button>
|
</button>
|
||||||
<section className="card quick-weight">
|
|
||||||
<div className="weight-icon">
|
|
||||||
<Scale size={22} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span className="eyebrow">A SMALL CHECK-IN</span>
|
|
||||||
<h3>
|
|
||||||
{latestWeight
|
|
||||||
? `${number(weightValue(latestWeight.data.valueKg, settings.unit), 1)} ${settings.unit}`
|
|
||||||
: "How are you feeling?"}
|
|
||||||
</h3>
|
|
||||||
<p>
|
|
||||||
{latestWeight
|
|
||||||
? `Latest weigh-in · ${displayDate(latestWeight.data.date, { month: "short", day: "numeric" })}`
|
|
||||||
: "Log your weight. See the bigger picture."}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
className="icon-button"
|
|
||||||
aria-label="Log weight"
|
|
||||||
onClick={logWeight}
|
|
||||||
>
|
|
||||||
<Plus size={20} />
|
|
||||||
</button>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="page-footnote">
|
<div className="page-footnote">
|
||||||
|
|
@ -529,6 +512,7 @@ function Library({
|
||||||
editPlate,
|
editPlate,
|
||||||
log,
|
log,
|
||||||
remove,
|
remove,
|
||||||
|
trends,
|
||||||
}: {
|
}: {
|
||||||
foods: JournalRecord<Food>[];
|
foods: JournalRecord<Food>[];
|
||||||
plates: JournalRecord<Plate>[];
|
plates: JournalRecord<Plate>[];
|
||||||
|
|
@ -538,6 +522,7 @@ function Library({
|
||||||
editPlate: (r: JournalRecord<Plate>) => void;
|
editPlate: (r: JournalRecord<Plate>) => void;
|
||||||
log: () => void;
|
log: () => void;
|
||||||
remove: (r: JournalRecord) => void;
|
remove: (r: JournalRecord) => void;
|
||||||
|
trends: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const [tab, setTab] = useState("foods");
|
const [tab, setTab] = useState("foods");
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
@ -551,13 +536,15 @@ function Library({
|
||||||
</h1>
|
</h1>
|
||||||
<p>A little less effort, every time you log.</p>
|
<p>A little less effort, every time you log.</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
{tab !== "trends" && (
|
||||||
className="primary"
|
<button
|
||||||
onClick={tab === "foods" ? newFood : newPlate}
|
className="primary"
|
||||||
>
|
onClick={tab === "foods" ? newFood : newPlate}
|
||||||
<Plus size={18} />
|
>
|
||||||
{tab === "foods" ? "New food" : "New plate"}
|
<Plus size={18} />
|
||||||
</button>
|
{tab === "foods" ? "New food" : "New plate"}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="library-controls">
|
<div className="library-controls">
|
||||||
<div className="segmented">
|
<div className="segmented">
|
||||||
|
|
@ -573,19 +560,29 @@ function Library({
|
||||||
>
|
>
|
||||||
My plates <span>{plates.length}</span>
|
My plates <span>{plates.length}</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className={tab === "trends" ? "active" : ""}
|
||||||
|
onClick={() => setTab("trends")}
|
||||||
|
>
|
||||||
|
Trends
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<label className="search-field">
|
{tab !== "trends" && (
|
||||||
<Search size={18} />
|
<label className="search-field">
|
||||||
<input
|
<Search size={18} />
|
||||||
aria-label="Search saved foods and plates"
|
<input
|
||||||
type="search"
|
aria-label="Search saved foods and plates"
|
||||||
placeholder="Find a favorite…"
|
type="search"
|
||||||
value={search}
|
placeholder="Find a favorite…"
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
value={search}
|
||||||
/>
|
onChange={(e) => setSearch(e.target.value)}
|
||||||
</label>
|
/>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{(tab === "foods" ? foods : plates).length === 0 ? (
|
{tab === "trends" ? (
|
||||||
|
trends
|
||||||
|
) : (tab === "foods" ? foods : plates).length === 0 ? (
|
||||||
<section className="card library-empty">
|
<section className="card library-empty">
|
||||||
<Empty
|
<Empty
|
||||||
icon={
|
icon={
|
||||||
|
|
@ -704,17 +701,19 @@ function Library({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="library-bottom">
|
{tab !== "trends" && (
|
||||||
<Leaf size={18} />
|
<div className="library-bottom">
|
||||||
<span>
|
<Leaf size={18} />
|
||||||
Saved foods are a starting point. Your past entries keep their
|
<span>
|
||||||
original nutrition.
|
Saved foods are a starting point. Your past entries keep their
|
||||||
</span>
|
original nutrition.
|
||||||
<button className="text-button" onClick={log}>
|
</span>
|
||||||
Log something
|
<button className="text-button" onClick={log}>
|
||||||
<ArrowUpRight size={15} />
|
Log something
|
||||||
</button>
|
<ArrowUpRight size={15} />
|
||||||
</div>
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -851,7 +850,7 @@ export function App() {
|
||||||
const nav = [
|
const nav = [
|
||||||
{ key: "today", label: "Today", icon: Home },
|
{ key: "today", label: "Today", icon: Home },
|
||||||
{ key: "library", label: "My library", icon: BookOpen },
|
{ key: "library", label: "My library", icon: BookOpen },
|
||||||
{ key: "trends", label: "Trends", icon: Activity },
|
{ key: "weight", label: "Weight", icon: Scale },
|
||||||
{ key: "settings", label: "Settings", icon: Settings2 },
|
{ key: "settings", label: "Settings", icon: Settings2 },
|
||||||
] as const;
|
] as const;
|
||||||
const syncLabel = !status.online
|
const syncLabel = !status.online
|
||||||
|
|
@ -891,21 +890,6 @@ export function App() {
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="sidebar-bottom">
|
|
||||||
<div className="sidebar-note">
|
|
||||||
<span className="little-star">✳</span>
|
|
||||||
<p>
|
|
||||||
Progress looks
|
|
||||||
<br />
|
|
||||||
different every day.
|
|
||||||
</p>
|
|
||||||
<span>Keep showing up for you.</span>
|
|
||||||
</div>
|
|
||||||
<div className="private-label">
|
|
||||||
<ShieldCheck size={16} />
|
|
||||||
Your personal space
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
</aside>
|
||||||
<div className="main-wrap">
|
<div className="main-wrap">
|
||||||
<header className="topbar">
|
<header className="topbar">
|
||||||
|
|
@ -977,7 +961,6 @@ export function App() {
|
||||||
}
|
}
|
||||||
remove={setDeleting}
|
remove={setDeleting}
|
||||||
openLibrary={() => setPage("library")}
|
openLibrary={() => setPage("library")}
|
||||||
logWeight={() => setEditor({ kind: "weight" })}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{page === "library" && (
|
{page === "library" && (
|
||||||
|
|
@ -988,12 +971,20 @@ export function App() {
|
||||||
newPlate={() => setEditor({ kind: "plate" })}
|
newPlate={() => setEditor({ kind: "plate" })}
|
||||||
editFood={(record) => setEditor({ kind: "food", record })}
|
editFood={(record) => setEditor({ kind: "food", record })}
|
||||||
editPlate={(record) => setEditor({ kind: "plate", record })}
|
editPlate={(record) => setEditor({ kind: "plate", record })}
|
||||||
log={() => setEditor({ kind: "log", meal: "Snacks" })}
|
log={() => setEditor({ kind: "log", meal: suggestedMeal() })}
|
||||||
remove={setDeleting}
|
remove={setDeleting}
|
||||||
|
trends={
|
||||||
|
<Trends
|
||||||
|
mode="nutrition"
|
||||||
|
records={journal.records}
|
||||||
|
settings={settings}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{page === "trends" && (
|
{page === "weight" && (
|
||||||
<Trends
|
<Trends
|
||||||
|
mode="weight"
|
||||||
records={journal.records}
|
records={journal.records}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
logWeight={() => setEditor({ kind: "weight" })}
|
logWeight={() => setEditor({ kind: "weight" })}
|
||||||
|
|
@ -1039,7 +1030,7 @@ export function App() {
|
||||||
<button
|
<button
|
||||||
className="nav-add"
|
className="nav-add"
|
||||||
aria-label="Add food"
|
aria-label="Add food"
|
||||||
onClick={() => setEditor({ kind: "log", meal: "Snacks" })}
|
onClick={() => setEditor({ kind: "log", meal: suggestedMeal() })}
|
||||||
>
|
>
|
||||||
<Plus size={28} />
|
<Plus size={28} />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { metrics } from "./types";
|
||||||
import { downloadExport, offsetDay, today } from "./utils";
|
import { downloadExport, offsetDay, today } from "./utils";
|
||||||
import { logout, saveRecord, sync, useSyncStatus } from "./store";
|
import { logout, saveRecord, sync, useSyncStatus } from "./store";
|
||||||
import { accentPresets, DEFAULT_ACCENT } from "../shared/theme.js";
|
import { accentPresets, DEFAULT_ACCENT } from "../shared/theme.js";
|
||||||
|
import { useTilt } from "./useTilt";
|
||||||
|
|
||||||
export function Settings({
|
export function Settings({
|
||||||
settings,
|
settings,
|
||||||
|
|
@ -36,6 +37,7 @@ export function Settings({
|
||||||
update: (() => void) | null;
|
update: (() => void) | null;
|
||||||
}) {
|
}) {
|
||||||
const [draft, setDraft] = useState(settings);
|
const [draft, setDraft] = useState(settings);
|
||||||
|
const tilt = useTilt();
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [format, setFormat] = useState(settings.exportFormat);
|
const [format, setFormat] = useState(settings.exportFormat);
|
||||||
const [range, setRange] = useState(settings.exportDays);
|
const [range, setRange] = useState(settings.exportDays);
|
||||||
|
|
@ -174,6 +176,26 @@ export function Settings({
|
||||||
))}
|
))}
|
||||||
<div className="settings-section">
|
<div className="settings-section">
|
||||||
<h3>Look & feel</h3>
|
<h3>Look & feel</h3>
|
||||||
|
<div className="preference-row">
|
||||||
|
<label className="toggle-label">
|
||||||
|
<input
|
||||||
|
className="switch"
|
||||||
|
type="checkbox"
|
||||||
|
checked={tilt.enabled}
|
||||||
|
onChange={() => void tilt.toggleTilt()}
|
||||||
|
/>
|
||||||
|
Tilt calorie bubbles
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<p className="small muted" role="status">
|
||||||
|
{tilt.status === "denied"
|
||||||
|
? "Motion permission was not granted. Check your browser’s website permissions."
|
||||||
|
: tilt.status === "unavailable"
|
||||||
|
? "Orientation sensors are unavailable on this device. Bubbles still fall normally."
|
||||||
|
: tilt.status === "permission"
|
||||||
|
? "Enable tilt again to grant motion access for this session."
|
||||||
|
: "Uses this device’s orientation. iPhone may request permission again after reopening. Reduced motion pauses the animation."}
|
||||||
|
</p>
|
||||||
<div className="segmented theme-control">
|
<div className="segmented theme-control">
|
||||||
{(
|
{(
|
||||||
[
|
[
|
||||||
|
|
|
||||||
446
src/Trends.tsx
446
src/Trends.tsx
|
|
@ -29,12 +29,14 @@ export function Trends({
|
||||||
logWeight,
|
logWeight,
|
||||||
editWeight,
|
editWeight,
|
||||||
remove,
|
remove,
|
||||||
|
mode = "nutrition",
|
||||||
}: {
|
}: {
|
||||||
records: JournalRecord[];
|
records: JournalRecord[];
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
logWeight: () => void;
|
mode?: "nutrition" | "weight";
|
||||||
editWeight: (r: JournalRecord<Weight>) => void;
|
logWeight?: () => void;
|
||||||
remove: (r: JournalRecord) => void;
|
editWeight?: (r: JournalRecord<Weight>) => void;
|
||||||
|
remove?: (r: JournalRecord) => void;
|
||||||
}) {
|
}) {
|
||||||
const [period, setPeriod] = useState(7);
|
const [period, setPeriod] = useState(7);
|
||||||
const [end, setEnd] = useState(today());
|
const [end, setEnd] = useState(today());
|
||||||
|
|
@ -87,19 +89,21 @@ export function Trends({
|
||||||
const delta = values.length > 1 ? values.at(-1)! - values[0] : null;
|
const delta = values.length > 1 ? values.at(-1)! - values[0] : null;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="page-heading">
|
{mode === "weight" && (
|
||||||
<div>
|
<div className="page-heading">
|
||||||
<span className="eyebrow">THE BIGGER PICTURE</span>
|
<div>
|
||||||
<h1>
|
<span className="eyebrow">THE BIGGER PICTURE</span>
|
||||||
Your rhythms<span>.</span>
|
<h1>
|
||||||
</h1>
|
Weight<span>.</span>
|
||||||
<p>Small moments. A little perspective.</p>
|
</h1>
|
||||||
|
<p>Your weigh-ins and changes over time.</p>
|
||||||
|
</div>
|
||||||
|
<button className="primary" onClick={logWeight}>
|
||||||
|
<Plus size={18} />
|
||||||
|
Log weight
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button className="primary" onClick={logWeight}>
|
)}
|
||||||
<Plus size={18} />
|
|
||||||
Log weight
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="trend-controls">
|
<div className="trend-controls">
|
||||||
<div className="segmented">
|
<div className="segmented">
|
||||||
{[7, 30, 90, 365].map((n) => (
|
{[7, 30, 90, 365].map((n) => (
|
||||||
|
|
@ -150,221 +154,227 @@ export function Trends({
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="trends-grid">
|
<div className="trends-grid single-trend">
|
||||||
<section className="card chart-card">
|
{mode === "nutrition" && (
|
||||||
<div className="card-title">
|
<section className="card chart-card">
|
||||||
<div>
|
<div className="card-title">
|
||||||
<span className="eyebrow">DAILY INTAKE</span>
|
<div>
|
||||||
<h2>{chosen.label}</h2>
|
<span className="eyebrow">DAILY INTAKE</span>
|
||||||
|
<h2>{chosen.label}</h2>
|
||||||
|
</div>
|
||||||
|
<select
|
||||||
|
aria-label="Trend nutrient"
|
||||||
|
value={metric}
|
||||||
|
onChange={(e) => setMetric(e.target.value as Metric)}
|
||||||
|
>
|
||||||
|
{metrics.map((m) => (
|
||||||
|
<option value={m.key} key={m.key}>
|
||||||
|
{m.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<select
|
<div className="stat-large">
|
||||||
aria-label="Trend nutrient"
|
{number(avg)} <span>{chosen.unit} / logged day</span>
|
||||||
value={metric}
|
</div>
|
||||||
onChange={(e) => setMetric(e.target.value as Metric)}
|
<div
|
||||||
|
className="bar-chart"
|
||||||
|
role="img"
|
||||||
|
aria-label={`${chosen.label}: ${number(avg)} ${chosen.unit} average over ${loggedDays.length} logged days`}
|
||||||
>
|
>
|
||||||
{metrics.map((m) => (
|
<div className="chart-grid-lines">
|
||||||
<option value={m.key} key={m.key}>
|
<span>{number(maximum)}</span>
|
||||||
{m.label}
|
<span>{number(maximum / 2)}</span>
|
||||||
</option>
|
<span>0</span>
|
||||||
))}
|
</div>
|
||||||
</select>
|
<div className="bars">
|
||||||
</div>
|
{goal.enabled && (
|
||||||
<div className="stat-large">
|
|
||||||
{number(avg)} <span>{chosen.unit} / logged day</span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="bar-chart"
|
|
||||||
role="img"
|
|
||||||
aria-label={`${chosen.label}: ${number(avg)} ${chosen.unit} average over ${loggedDays.length} logged days`}
|
|
||||||
>
|
|
||||||
<div className="chart-grid-lines">
|
|
||||||
<span>{number(maximum)}</span>
|
|
||||||
<span>{number(maximum / 2)}</span>
|
|
||||||
<span>0</span>
|
|
||||||
</div>
|
|
||||||
<div className="bars">
|
|
||||||
{goal.enabled && (
|
|
||||||
<div
|
|
||||||
className="goal-line"
|
|
||||||
style={{ bottom: `${(goal.target / maximum) * 100}%` }}
|
|
||||||
>
|
|
||||||
<span>Goal {number(goal.target)}</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{days.map((d) => (
|
|
||||||
<div
|
|
||||||
className={"bar-slot " + (!d.logged ? "unlogged" : "")}
|
|
||||||
key={d.date}
|
|
||||||
title={`${displayDate(d.date)}: ${d.logged ? number(d.total) + " " + chosen.unit : "Not logged"}`}
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className="bar"
|
className="goal-line"
|
||||||
style={{
|
style={{ bottom: `${(goal.target / maximum) * 100}%` }}
|
||||||
height: `${d.logged ? Math.max(1, (d.total / maximum) * 100) : 2}%`,
|
>
|
||||||
background: d.logged ? chosen.color : undefined,
|
<span>Goal {number(goal.target)}</span>
|
||||||
}}
|
</div>
|
||||||
/>
|
)}
|
||||||
{period === 7 && (
|
{days.map((d) => (
|
||||||
<span>
|
<div
|
||||||
{displayDate(d.date, { weekday: "short" }).slice(0, 1)}
|
className={"bar-slot " + (!d.logged ? "unlogged" : "")}
|
||||||
</span>
|
key={d.date}
|
||||||
)}
|
title={`${displayDate(d.date)}: ${d.logged ? number(d.total) + " " + chosen.unit : "Not logged"}`}
|
||||||
</div>
|
>
|
||||||
))}
|
<div
|
||||||
|
className="bar"
|
||||||
|
style={{
|
||||||
|
height: `${d.logged ? Math.max(1, (d.total / maximum) * 100) : 2}%`,
|
||||||
|
background: d.logged ? chosen.color : undefined,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{period === 7 && (
|
||||||
|
<span>
|
||||||
|
{displayDate(d.date, { weekday: "short" }).slice(0, 1)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<p className="chart-note">
|
||||||
<p className="chart-note">
|
{loggedDays.length} of {period} days logged · Empty days are
|
||||||
{loggedDays.length} of {period} days logged · Empty days are
|
excluded from the average.
|
||||||
excluded from the average.
|
</p>
|
||||||
</p>
|
</section>
|
||||||
</section>
|
)}
|
||||||
<section className="card chart-card">
|
{mode === "weight" && (
|
||||||
|
<section className="card chart-card">
|
||||||
|
<div className="card-title">
|
||||||
|
<div>
|
||||||
|
<span className="eyebrow">YOUR JOURNEY</span>
|
||||||
|
<h2>Weight</h2>
|
||||||
|
</div>
|
||||||
|
<Scale size={22} className="muted" />
|
||||||
|
</div>
|
||||||
|
{dailyWeights.length ? (
|
||||||
|
<>
|
||||||
|
<div className="stat-large">
|
||||||
|
{number(values.at(-1)!, 1)} <span>{settings.unit}</span>
|
||||||
|
</div>
|
||||||
|
<div className="weight-chart">
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 600 210"
|
||||||
|
role="img"
|
||||||
|
aria-label={`${dailyWeights.length} weigh-ins, latest ${number(values.at(-1)!, 1)} ${settings.unit}`}
|
||||||
|
>
|
||||||
|
<line
|
||||||
|
x1="28"
|
||||||
|
x2="572"
|
||||||
|
y1="30"
|
||||||
|
y2="30"
|
||||||
|
className="grid-line"
|
||||||
|
/>
|
||||||
|
<line
|
||||||
|
x1="28"
|
||||||
|
x2="572"
|
||||||
|
y1="100"
|
||||||
|
y2="100"
|
||||||
|
className="grid-line"
|
||||||
|
/>
|
||||||
|
<line
|
||||||
|
x1="28"
|
||||||
|
x2="572"
|
||||||
|
y1="170"
|
||||||
|
y2="170"
|
||||||
|
className="grid-line"
|
||||||
|
/>
|
||||||
|
<polyline
|
||||||
|
points={points.map((p) => `${p.x},${p.y}`).join(" ")}
|
||||||
|
fill="none"
|
||||||
|
stroke="var(--accent)"
|
||||||
|
strokeWidth="3"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
{points.map((p, i) => (
|
||||||
|
<circle
|
||||||
|
key={i}
|
||||||
|
cx={p.x}
|
||||||
|
cy={p.y}
|
||||||
|
r="4"
|
||||||
|
fill="var(--accent)"
|
||||||
|
>
|
||||||
|
<title>
|
||||||
|
{dailyWeights[i].data.date}: {number(values[i], 1)}{" "}
|
||||||
|
{settings.unit}
|
||||||
|
</title>
|
||||||
|
</circle>
|
||||||
|
))}
|
||||||
|
<text x="28" y="202">
|
||||||
|
{displayDate(start, { month: "short", day: "numeric" })}
|
||||||
|
</text>
|
||||||
|
<text x="572" y="202" textAnchor="end">
|
||||||
|
{displayDate(end, { month: "short", day: "numeric" })}
|
||||||
|
</text>
|
||||||
|
</svg>
|
||||||
|
<div className="weight-axis">
|
||||||
|
<span>{number(maxWeight, 1)}</span>
|
||||||
|
<span>{number(minWeight, 1)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="chart-note">
|
||||||
|
{delta === null ? (
|
||||||
|
"Log another day to see a change over time."
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{delta < 0 ? (
|
||||||
|
<ArrowDownRight size={15} />
|
||||||
|
) : (
|
||||||
|
<ArrowUpRight size={15} />
|
||||||
|
)}{" "}
|
||||||
|
{number(Math.abs(delta), 1)} {settings.unit}{" "}
|
||||||
|
{delta < 0 ? "down" : "up"} in this period
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Empty
|
||||||
|
icon={<Activity size={28} />}
|
||||||
|
title="A starting point, whenever you’re ready"
|
||||||
|
text="Your weigh-ins will become a simple picture of your progress."
|
||||||
|
action={
|
||||||
|
<button className="text-button" onClick={logWeight}>
|
||||||
|
Log your first weight <ArrowUpRight size={16} />
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{mode === "weight" && (
|
||||||
|
<section className="card weight-journal">
|
||||||
<div className="card-title">
|
<div className="card-title">
|
||||||
<div>
|
<div>
|
||||||
<span className="eyebrow">YOUR JOURNEY</span>
|
<span className="eyebrow">ONE CHECK-IN AT A TIME</span>
|
||||||
<h2>Weight</h2>
|
<h2>Weight journal</h2>
|
||||||
</div>
|
</div>
|
||||||
<Scale size={22} className="muted" />
|
<span className="pill">{weights.length} in this period</span>
|
||||||
</div>
|
</div>
|
||||||
{dailyWeights.length ? (
|
{weights.length === 0 ? (
|
||||||
<>
|
<p className="muted">No weigh-ins in this date range.</p>
|
||||||
<div className="stat-large">
|
|
||||||
{number(values.at(-1)!, 1)} <span>{settings.unit}</span>
|
|
||||||
</div>
|
|
||||||
<div className="weight-chart">
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 600 210"
|
|
||||||
role="img"
|
|
||||||
aria-label={`${dailyWeights.length} weigh-ins, latest ${number(values.at(-1)!, 1)} ${settings.unit}`}
|
|
||||||
>
|
|
||||||
<line
|
|
||||||
x1="28"
|
|
||||||
x2="572"
|
|
||||||
y1="30"
|
|
||||||
y2="30"
|
|
||||||
className="grid-line"
|
|
||||||
/>
|
|
||||||
<line
|
|
||||||
x1="28"
|
|
||||||
x2="572"
|
|
||||||
y1="100"
|
|
||||||
y2="100"
|
|
||||||
className="grid-line"
|
|
||||||
/>
|
|
||||||
<line
|
|
||||||
x1="28"
|
|
||||||
x2="572"
|
|
||||||
y1="170"
|
|
||||||
y2="170"
|
|
||||||
className="grid-line"
|
|
||||||
/>
|
|
||||||
<polyline
|
|
||||||
points={points.map((p) => `${p.x},${p.y}`).join(" ")}
|
|
||||||
fill="none"
|
|
||||||
stroke="var(--accent)"
|
|
||||||
strokeWidth="3"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
/>
|
|
||||||
{points.map((p, i) => (
|
|
||||||
<circle
|
|
||||||
key={i}
|
|
||||||
cx={p.x}
|
|
||||||
cy={p.y}
|
|
||||||
r="4"
|
|
||||||
fill="var(--accent)"
|
|
||||||
>
|
|
||||||
<title>
|
|
||||||
{dailyWeights[i].data.date}: {number(values[i], 1)}{" "}
|
|
||||||
{settings.unit}
|
|
||||||
</title>
|
|
||||||
</circle>
|
|
||||||
))}
|
|
||||||
<text x="28" y="202">
|
|
||||||
{displayDate(start, { month: "short", day: "numeric" })}
|
|
||||||
</text>
|
|
||||||
<text x="572" y="202" textAnchor="end">
|
|
||||||
{displayDate(end, { month: "short", day: "numeric" })}
|
|
||||||
</text>
|
|
||||||
</svg>
|
|
||||||
<div className="weight-axis">
|
|
||||||
<span>{number(maxWeight, 1)}</span>
|
|
||||||
<span>{number(minWeight, 1)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p className="chart-note">
|
|
||||||
{delta === null ? (
|
|
||||||
"Log another day to see a change over time."
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{delta < 0 ? (
|
|
||||||
<ArrowDownRight size={15} />
|
|
||||||
) : (
|
|
||||||
<ArrowUpRight size={15} />
|
|
||||||
)}{" "}
|
|
||||||
{number(Math.abs(delta), 1)} {settings.unit}{" "}
|
|
||||||
{delta < 0 ? "down" : "up"} in this period
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
<Empty
|
[...weights].reverse().map((r) => (
|
||||||
icon={<Activity size={28} />}
|
<div className="journal-row" key={r.id}>
|
||||||
title="A starting point, whenever you’re ready"
|
<div className="food-avatar weight-avatar">
|
||||||
text="Your weigh-ins will become a simple picture of your progress."
|
<Scale size={19} />
|
||||||
action={
|
</div>
|
||||||
<button className="text-button" onClick={logWeight}>
|
<div className="row-copy">
|
||||||
Log your first weight <ArrowUpRight size={16} />
|
<strong>
|
||||||
|
{number(weightValue(r.data.valueKg, settings.unit), 1)}{" "}
|
||||||
|
{settings.unit}
|
||||||
|
</strong>
|
||||||
|
<small>
|
||||||
|
{displayDate(r.data.date)}
|
||||||
|
{r.data.notes ? " · " + r.data.notes : ""}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
className="icon-button"
|
||||||
|
aria-label={`Edit weight ${r.data.date}`}
|
||||||
|
onClick={() => editWeight?.(r)}
|
||||||
|
>
|
||||||
|
<Pencil size={16} />
|
||||||
</button>
|
</button>
|
||||||
}
|
<button
|
||||||
/>
|
className="icon-button danger-hover"
|
||||||
|
aria-label={`Delete weight ${r.data.date}`}
|
||||||
|
onClick={() => remove?.(r)}
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
)}
|
||||||
<section className="card weight-journal">
|
|
||||||
<div className="card-title">
|
|
||||||
<div>
|
|
||||||
<span className="eyebrow">ONE CHECK-IN AT A TIME</span>
|
|
||||||
<h2>Weight journal</h2>
|
|
||||||
</div>
|
|
||||||
<span className="pill">{weights.length} in this period</span>
|
|
||||||
</div>
|
|
||||||
{weights.length === 0 ? (
|
|
||||||
<p className="muted">No weigh-ins in this date range.</p>
|
|
||||||
) : (
|
|
||||||
[...weights].reverse().map((r) => (
|
|
||||||
<div className="journal-row" key={r.id}>
|
|
||||||
<div className="food-avatar weight-avatar">
|
|
||||||
<Scale size={19} />
|
|
||||||
</div>
|
|
||||||
<div className="row-copy">
|
|
||||||
<strong>
|
|
||||||
{number(weightValue(r.data.valueKg, settings.unit), 1)}{" "}
|
|
||||||
{settings.unit}
|
|
||||||
</strong>
|
|
||||||
<small>
|
|
||||||
{displayDate(r.data.date)}
|
|
||||||
{r.data.notes ? " · " + r.data.notes : ""}
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
className="icon-button"
|
|
||||||
aria-label={`Edit weight ${r.data.date}`}
|
|
||||||
onClick={() => editWeight(r)}
|
|
||||||
>
|
|
||||||
<Pencil size={16} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="icon-button danger-hover"
|
|
||||||
aria-label={`Delete weight ${r.data.date}`}
|
|
||||||
onClick={() => remove(r)}
|
|
||||||
>
|
|
||||||
<Trash2 size={16} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,5 @@
|
||||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||||
import {
|
import { X, ArrowUpRight, Plus, Minus, Leaf } from "lucide-react";
|
||||||
X,
|
|
||||||
ArrowUpRight,
|
|
||||||
Plus,
|
|
||||||
Minus,
|
|
||||||
Leaf,
|
|
||||||
Smartphone,
|
|
||||||
RotateCcw,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { bubbleCount } from "../shared/bubble-physics.js";
|
import { bubbleCount } from "../shared/bubble-physics.js";
|
||||||
import { useBubblePhysics } from "./useBubblePhysics";
|
import { useBubblePhysics } from "./useBubblePhysics";
|
||||||
import {
|
import {
|
||||||
|
|
@ -22,7 +14,8 @@ import {
|
||||||
type Weight,
|
type Weight,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { emptyNutrients } from "../shared/domain.js";
|
import { emptyNutrients } from "../shared/domain.js";
|
||||||
import { saveRecord, putRecords } from "./store";
|
import { saveRecord, putRecords, useJournal } from "./store";
|
||||||
|
import { localTime, nextFoodName } from "../shared/entry.js";
|
||||||
import { displayDate, number, today, weightValue } from "./utils";
|
import { displayDate, number, today, weightValue } from "./utils";
|
||||||
|
|
||||||
export function Modal({
|
export function Modal({
|
||||||
|
|
@ -91,15 +84,12 @@ export function CalorieOrb({
|
||||||
goal,
|
goal,
|
||||||
enabled,
|
enabled,
|
||||||
small = false,
|
small = false,
|
||||||
interactive = true,
|
|
||||||
}: {
|
}: {
|
||||||
value: number;
|
value: number;
|
||||||
goal: number;
|
goal: number;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
small?: boolean;
|
small?: boolean;
|
||||||
interactive?: boolean;
|
|
||||||
}) {
|
}) {
|
||||||
const ratio = enabled ? Math.min(value / goal, 1) : Math.min(value / 2500, 1);
|
|
||||||
const physics = useBubblePhysics(bubbleCount(value, goal, enabled));
|
const physics = useBubblePhysics(bubbleCount(value, goal, enabled));
|
||||||
const readout = (
|
const readout = (
|
||||||
<>
|
<>
|
||||||
|
|
@ -141,55 +131,8 @@ export function CalorieOrb({
|
||||||
ref={physics.canvas}
|
ref={physics.canvas}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
{!small && ratio < 0.85 && (
|
|
||||||
<div
|
|
||||||
className={"orb-number " + (ratio > 0.47 ? "orb-number-high" : "")}
|
|
||||||
>
|
|
||||||
{readout}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{!small && ratio >= 0.85 && (
|
{!small && <div className="orb-number orb-number-outside">{readout}</div>}
|
||||||
<div className="orb-number orb-number-outside">{readout}</div>
|
|
||||||
)}
|
|
||||||
{interactive && !small && (
|
|
||||||
<>
|
|
||||||
<div className="orb-motion-controls">
|
|
||||||
<button
|
|
||||||
disabled={physics.reduced}
|
|
||||||
aria-pressed={physics.enabled}
|
|
||||||
onClick={() => void physics.toggleTilt()}
|
|
||||||
>
|
|
||||||
<Smartphone size={12} />
|
|
||||||
{physics.reduced
|
|
||||||
? "Reduced motion"
|
|
||||||
: physics.motion === "on"
|
|
||||||
? "Tilt enabled"
|
|
||||||
: physics.motion === "waiting"
|
|
||||||
? "Waiting for tilt…"
|
|
||||||
: physics.enabled
|
|
||||||
? "Turn tilt off"
|
|
||||||
: "Enable tilt"}
|
|
||||||
</button>
|
|
||||||
<span />
|
|
||||||
<button disabled={physics.reduced} onClick={physics.nudge}>
|
|
||||||
<RotateCcw size={12} />
|
|
||||||
Give a nudge
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{physics.motion === "denied" && (
|
|
||||||
<p className="motion-help" role="status">
|
|
||||||
Motion access was not granted. You can allow it in your browser’s
|
|
||||||
website settings.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{physics.motion === "unavailable" && (
|
|
||||||
<p className="motion-help" role="status">
|
|
||||||
No tilt data yet. Falling bubbles still work on this device.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -272,6 +215,7 @@ export function FoodEditor({
|
||||||
notify: (text: string) => void;
|
notify: (text: string) => void;
|
||||||
}) {
|
}) {
|
||||||
const initial = existing?.data;
|
const initial = existing?.data;
|
||||||
|
const { records } = useJournal();
|
||||||
const [tab, setTab] = useState<"manual" | "saved" | "plates">("manual");
|
const [tab, setTab] = useState<"manual" | "saved" | "plates">("manual");
|
||||||
const [name, setName] = useState(initial?.name || "");
|
const [name, setName] = useState(initial?.name || "");
|
||||||
const [serving, setServing] = useState(initial?.serving || "1 serving");
|
const [serving, setServing] = useState(initial?.serving || "1 serving");
|
||||||
|
|
@ -287,6 +231,24 @@ export function FoodEditor({
|
||||||
const [selectedDate, setDate] = useState(
|
const [selectedDate, setDate] = useState(
|
||||||
existing?.type === "entry" ? (initial as Entry).date : date,
|
existing?.type === "entry" ? (initial as Entry).date : date,
|
||||||
);
|
);
|
||||||
|
const [time, setTime] = useState(
|
||||||
|
existing?.type === "entry" ? (initial as Entry).time || "" : localTime(),
|
||||||
|
);
|
||||||
|
const fallbackName = nextFoodName(
|
||||||
|
mode === "food" ? "Food" : selectedMeal,
|
||||||
|
records
|
||||||
|
.filter(
|
||||||
|
(r) =>
|
||||||
|
!r.deleted &&
|
||||||
|
r.id !== existing?.id &&
|
||||||
|
(mode === "food"
|
||||||
|
? r.type === "food"
|
||||||
|
: r.type === "entry" &&
|
||||||
|
(r.data as Entry).date === selectedDate &&
|
||||||
|
(r.data as Entry).meal === selectedMeal),
|
||||||
|
)
|
||||||
|
.map((r) => (r.data as Food).name),
|
||||||
|
);
|
||||||
const [saveFood, setSaveFood] = useState(false);
|
const [saveFood, setSaveFood] = useState(false);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
@ -296,7 +258,13 @@ export function FoodEditor({
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
const food = { name: name.trim(), serving: serving.trim(), nutrients };
|
if (mode === "log" && (!selectedDate || (!existing && !time)))
|
||||||
|
throw new Error("Choose an entry date and time.");
|
||||||
|
const food = {
|
||||||
|
name: name.trim() || fallbackName,
|
||||||
|
serving: serving.trim(),
|
||||||
|
nutrients,
|
||||||
|
};
|
||||||
const items: Parameters<typeof putRecords>[0] = [
|
const items: Parameters<typeof putRecords>[0] = [
|
||||||
{
|
{
|
||||||
type: mode === "food" ? "food" : "entry",
|
type: mode === "food" ? "food" : "entry",
|
||||||
|
|
@ -304,7 +272,13 @@ export function FoodEditor({
|
||||||
data:
|
data:
|
||||||
mode === "food"
|
mode === "food"
|
||||||
? food
|
? food
|
||||||
: { ...food, date: selectedDate, meal: selectedMeal, quantity },
|
: {
|
||||||
|
...food,
|
||||||
|
date: selectedDate,
|
||||||
|
...(time ? { time } : {}),
|
||||||
|
meal: selectedMeal,
|
||||||
|
quantity,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (saveFood && mode === "log") items.push({ type: "food", data: food });
|
if (saveFood && mode === "log") items.push({ type: "food", data: food });
|
||||||
|
|
@ -327,10 +301,12 @@ export function FoodEditor({
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
|
if (!selectedDate || !time)
|
||||||
|
throw new Error("Choose an entry date and time.");
|
||||||
await putRecords(
|
await putRecords(
|
||||||
plate.items.map((item) => ({
|
plate.items.map((item) => ({
|
||||||
type: "entry",
|
type: "entry",
|
||||||
data: { ...item, date: selectedDate, meal: selectedMeal },
|
data: { ...item, date: selectedDate, time, meal: selectedMeal },
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
notify(`${plate.name} added to your day`);
|
notify(`${plate.name} added to your day`);
|
||||||
|
|
@ -379,7 +355,7 @@ export function FoodEditor({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{mode === "log" && (
|
{mode === "log" && (
|
||||||
<div className="form-row">
|
<div className="form-row entry-details">
|
||||||
<label>
|
<label>
|
||||||
Day
|
Day
|
||||||
<input
|
<input
|
||||||
|
|
@ -390,6 +366,16 @@ export function FoodEditor({
|
||||||
onChange={(e) => setDate(e.target.value)}
|
onChange={(e) => setDate(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
Time
|
||||||
|
<input
|
||||||
|
aria-label="Entry time"
|
||||||
|
type="time"
|
||||||
|
required={!existing}
|
||||||
|
value={time}
|
||||||
|
onChange={(e) => setTime(e.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Meal
|
Meal
|
||||||
<select
|
<select
|
||||||
|
|
@ -446,7 +432,7 @@ export function FoodEditor({
|
||||||
)
|
)
|
||||||
.map((r) => (
|
.map((r) => (
|
||||||
<button
|
<button
|
||||||
disabled={busy || !selectedDate}
|
disabled={busy || !selectedDate || !time}
|
||||||
className="picker-row"
|
className="picker-row"
|
||||||
key={r.id}
|
key={r.id}
|
||||||
onClick={() => void addPlate(r.data)}
|
onClick={() => void addPlate(r.data)}
|
||||||
|
|
@ -480,12 +466,11 @@ export function FoodEditor({
|
||||||
) : (
|
) : (
|
||||||
<form onSubmit={submit}>
|
<form onSubmit={submit}>
|
||||||
<label>
|
<label>
|
||||||
Food name
|
Food name <span className="muted">(optional)</span>
|
||||||
<input
|
<input
|
||||||
autoFocus
|
autoFocus
|
||||||
required
|
|
||||||
maxLength={160}
|
maxLength={160}
|
||||||
placeholder="e.g. Greek yogurt & berries"
|
placeholder={fallbackName}
|
||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -570,38 +570,6 @@ main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.orb-motion-controls {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
gap: 13px;
|
|
||||||
margin: -2px 0 10px;
|
|
||||||
}
|
|
||||||
.orb-motion-controls button {
|
|
||||||
min-height: 36px;
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 5px;
|
|
||||||
align-items: center;
|
|
||||||
color: var(--muted);
|
|
||||||
font-size: 9px;
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
.orb-motion-controls button[aria-pressed="true"],
|
|
||||||
.orb-motion-controls button:hover {
|
|
||||||
color: var(--accent-text);
|
|
||||||
}
|
|
||||||
.orb-motion-controls > span {
|
|
||||||
width: 1px;
|
|
||||||
height: 10px;
|
|
||||||
background: var(--line);
|
|
||||||
}
|
|
||||||
.motion-help {
|
|
||||||
font-size: 9px;
|
|
||||||
color: var(--muted);
|
|
||||||
text-align: center;
|
|
||||||
max-width: 270px;
|
|
||||||
margin: 0 auto 12px;
|
|
||||||
}
|
|
||||||
.orb-number {
|
.orb-number {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
@ -628,27 +596,21 @@ main {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
.orb-number-high {
|
|
||||||
background: var(--surface);
|
|
||||||
box-shadow: 0 0 20px 10px var(--surface);
|
|
||||||
border-radius: 60%;
|
|
||||||
inset: 26% 22% auto;
|
|
||||||
}
|
|
||||||
.orb-number.orb-number-outside {
|
.orb-number.orb-number-outside {
|
||||||
position: static;
|
position: static;
|
||||||
flex-direction: row;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 8px;
|
gap: 3px;
|
||||||
margin: 9px 0 5px;
|
margin: 10px 0 16px;
|
||||||
min-height: 32px;
|
min-height: 32px;
|
||||||
}
|
}
|
||||||
.orb-number.orb-number-outside strong {
|
.orb-number.orb-number-outside strong {
|
||||||
font-size: 26px;
|
font-size: 42px;
|
||||||
letter-spacing: -1px;
|
letter-spacing: -1px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.orb-number.orb-number-outside .eyebrow {
|
.orb-number.orb-number-outside .eyebrow {
|
||||||
font-size: 7px;
|
font-size: 8px;
|
||||||
}
|
}
|
||||||
.orb-number.orb-number-outside .orb-unit {
|
.orb-number.orb-number-outside .orb-unit {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
@ -681,12 +643,20 @@ main {
|
||||||
background: var(--line);
|
background: var(--line);
|
||||||
}
|
}
|
||||||
.macro-grid {
|
.macro-grid {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
gap: 19px;
|
gap: 19px;
|
||||||
padding: 24px 0 26px;
|
padding: 24px 0 26px;
|
||||||
border-top: 1px solid var(--line);
|
border-top: 1px solid var(--line);
|
||||||
}
|
}
|
||||||
|
.macro-grid > .macro {
|
||||||
|
flex: 0 1 calc((100% - 40px) / 3);
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.trends-grid.single-trend {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
}
|
||||||
.macro-label {
|
.macro-label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -722,6 +692,7 @@ main {
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
transition: width 650ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
}
|
}
|
||||||
.balance-footer {
|
.balance-footer {
|
||||||
border-top: 1px solid var(--line);
|
border-top: 1px solid var(--line);
|
||||||
|
|
@ -1046,6 +1017,12 @@ main {
|
||||||
.sheet-head > .icon-button {
|
.sheet-head > .icon-button {
|
||||||
margin: -7px -8px 0 0;
|
margin: -7px -8px 0 0;
|
||||||
}
|
}
|
||||||
|
.sheet-head > div {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.sheet-head .eyebrow {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
.sheet .eyebrow {
|
.sheet .eyebrow {
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
}
|
}
|
||||||
|
|
@ -1084,10 +1061,13 @@ textarea {
|
||||||
}
|
}
|
||||||
.form-row {
|
.form-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
margin-bottom: 18px;
|
margin-bottom: 18px;
|
||||||
}
|
}
|
||||||
|
.entry-details {
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
}
|
||||||
.unit-input {
|
.unit-input {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -1124,10 +1104,11 @@ textarea {
|
||||||
}
|
}
|
||||||
.nutrient-fields {
|
.nutrient-fields {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
.nutrient-fields label {
|
.nutrient-fields label {
|
||||||
|
min-width: 0;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
|
@ -1624,7 +1605,12 @@ textarea {
|
||||||
gap: 25px;
|
gap: 25px;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
.settings-grid > *, .settings-stack, .settings-card, .form-row > label { min-width: 0; }
|
.settings-grid > *,
|
||||||
|
.settings-stack,
|
||||||
|
.settings-card,
|
||||||
|
.form-row > label {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
.settings-card {
|
.settings-card {
|
||||||
padding: 26px;
|
padding: 26px;
|
||||||
}
|
}
|
||||||
|
|
@ -2550,6 +2536,8 @@ textarea {
|
||||||
}
|
}
|
||||||
.sheet .segmented button {
|
.sheet .segmented button {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
padding-inline: 10px;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
.section-caption > span:last-child {
|
.section-caption > span:last-child {
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
|
|
@ -2557,6 +2545,12 @@ textarea {
|
||||||
.form-row {
|
.form-row {
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
.entry-details {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
.entry-details > label:first-child {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
.sheet .picker-row {
|
.sheet .picker-row {
|
||||||
min-height: 64px;
|
min-height: 64px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,12 @@ export type Metric =
|
||||||
export type Nutrients = Record<Metric, number>;
|
export type Nutrients = Record<Metric, number>;
|
||||||
export type Food = { name: string; serving: string; nutrients: Nutrients };
|
export type Food = { name: string; serving: string; nutrients: Nutrients };
|
||||||
export type Meal = "Breakfast" | "Lunch" | "Dinner" | "Snacks";
|
export type Meal = "Breakfast" | "Lunch" | "Dinner" | "Snacks";
|
||||||
export type Entry = Food & { date: string; meal: Meal; quantity: number };
|
export type Entry = Food & {
|
||||||
|
date: string;
|
||||||
|
time?: string;
|
||||||
|
meal: Meal;
|
||||||
|
quantity: number;
|
||||||
|
};
|
||||||
export type Plate = { name: string; items: (Food & { quantity: number })[] };
|
export type Plate = { name: string; items: (Food & { quantity: number })[] };
|
||||||
export type Weight = { date: string; valueKg: number; notes: string };
|
export type Weight = { date: string; valueKg: number; notes: string };
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { useTilt } from "./useTilt";
|
||||||
import {
|
import {
|
||||||
createBubbleWorld,
|
createBubbleWorld,
|
||||||
screenGravity,
|
screenGravity,
|
||||||
DRAW_BUBBLE_RADIUS,
|
DRAW_BUBBLE_RADIUS,
|
||||||
} from "../shared/bubble-physics.js";
|
} from "../shared/bubble-physics.js";
|
||||||
|
|
||||||
let tiltAllowedThisSession = false;
|
|
||||||
type MotionStatus = "off" | "waiting" | "on" | "denied" | "unavailable";
|
|
||||||
export function useBubblePhysics(count: number) {
|
export function useBubblePhysics(count: number) {
|
||||||
const canvas = useRef<HTMLCanvasElement>(null);
|
const canvas = useRef<HTMLCanvasElement>(null);
|
||||||
const world = useRef<ReturnType<typeof createBubbleWorld> | null>(null);
|
const world = useRef<ReturnType<typeof createBubbleWorld> | null>(null);
|
||||||
const kick = useRef<() => void>(() => {});
|
const kick = useRef<() => void>(() => {});
|
||||||
const redraw = useRef<() => void>(() => {});
|
const redraw = useRef<() => void>(() => {});
|
||||||
const [enabled, setEnabled] = useState(tiltAllowedThisSession);
|
const { enabled } = useTilt();
|
||||||
const [motion, setMotion] = useState<MotionStatus>("off");
|
|
||||||
const [reduced, setReduced] = useState(
|
const [reduced, setReduced] = useState(
|
||||||
() => matchMedia("(prefers-reduced-motion: reduce)").matches,
|
() => matchMedia("(prefers-reduced-motion: reduce)").matches,
|
||||||
);
|
);
|
||||||
|
|
@ -154,8 +152,6 @@ export function useBubblePhysics(count: number) {
|
||||||
kick.current();
|
kick.current();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMotion("waiting");
|
|
||||||
let received = false;
|
|
||||||
let lastBeta = 0;
|
let lastBeta = 0;
|
||||||
let lastGamma = 0;
|
let lastGamma = 0;
|
||||||
const apply = () => {
|
const apply = () => {
|
||||||
|
|
@ -177,57 +173,15 @@ export function useBubblePhysics(count: number) {
|
||||||
return;
|
return;
|
||||||
lastBeta = event.beta;
|
lastBeta = event.beta;
|
||||||
lastGamma = event.gamma;
|
lastGamma = event.gamma;
|
||||||
if (!received) {
|
|
||||||
received = true;
|
|
||||||
setMotion("on");
|
|
||||||
}
|
|
||||||
apply();
|
apply();
|
||||||
};
|
};
|
||||||
window.addEventListener("deviceorientation", orientation);
|
window.addEventListener("deviceorientation", orientation);
|
||||||
screen.orientation?.addEventListener("change", apply);
|
screen.orientation?.addEventListener("change", apply);
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
if (!received) setMotion("unavailable");
|
|
||||||
}, 5000);
|
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(timeout);
|
|
||||||
window.removeEventListener("deviceorientation", orientation);
|
window.removeEventListener("deviceorientation", orientation);
|
||||||
screen.orientation?.removeEventListener("change", apply);
|
screen.orientation?.removeEventListener("change", apply);
|
||||||
};
|
};
|
||||||
}, [enabled, reduced]);
|
}, [enabled, reduced]);
|
||||||
|
|
||||||
const toggleTilt = useCallback(async () => {
|
return { canvas };
|
||||||
if (enabled) {
|
|
||||||
setEnabled(false);
|
|
||||||
setMotion("off");
|
|
||||||
tiltAllowedThisSession = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof DeviceOrientationEvent === "undefined") {
|
|
||||||
setMotion("unavailable");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const sensor = DeviceOrientationEvent as typeof DeviceOrientationEvent & {
|
|
||||||
requestPermission?: () => Promise<string>;
|
|
||||||
};
|
|
||||||
if (
|
|
||||||
sensor.requestPermission &&
|
|
||||||
(await sensor.requestPermission()) !== "granted"
|
|
||||||
) {
|
|
||||||
setMotion("denied");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tiltAllowedThisSession = true;
|
|
||||||
setEnabled(true);
|
|
||||||
} catch {
|
|
||||||
setMotion("denied");
|
|
||||||
}
|
|
||||||
}, [enabled]);
|
|
||||||
const nudge = useCallback(() => {
|
|
||||||
if (!reduced) {
|
|
||||||
world.current?.nudge();
|
|
||||||
kick.current();
|
|
||||||
}
|
|
||||||
}, [reduced]);
|
|
||||||
return { canvas, motion, enabled, reduced, toggleTilt, nudge };
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
68
src/useTilt.ts
Normal file
68
src/useTilt.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { useSyncExternalStore } from "react";
|
||||||
|
|
||||||
|
type Sensor = typeof DeviceOrientationEvent & {
|
||||||
|
requestPermission?: () => Promise<string>;
|
||||||
|
};
|
||||||
|
type TiltState = {
|
||||||
|
enabled: boolean;
|
||||||
|
status: "off" | "enabled" | "permission" | "denied" | "unavailable";
|
||||||
|
};
|
||||||
|
const needsPermission = () =>
|
||||||
|
typeof DeviceOrientationEvent !== "undefined" &&
|
||||||
|
Boolean((DeviceOrientationEvent as Sensor).requestPermission);
|
||||||
|
let wanted = false;
|
||||||
|
try {
|
||||||
|
wanted = localStorage.getItem("calio-tilt") === "true";
|
||||||
|
} catch {}
|
||||||
|
let state: TiltState = {
|
||||||
|
enabled: wanted && !needsPermission(),
|
||||||
|
status: wanted ? (needsPermission() ? "permission" : "enabled") : "off",
|
||||||
|
};
|
||||||
|
const listeners = new Set<() => void>();
|
||||||
|
function update(next: TiltState) {
|
||||||
|
state = next;
|
||||||
|
listeners.forEach((fn) => fn());
|
||||||
|
}
|
||||||
|
function remember(enabled: boolean) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem("calio-tilt", String(enabled));
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
async function toggleTilt() {
|
||||||
|
if (state.enabled) {
|
||||||
|
remember(false);
|
||||||
|
update({ enabled: false, status: "off" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof DeviceOrientationEvent === "undefined") {
|
||||||
|
update({ enabled: false, status: "unavailable" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const sensor = DeviceOrientationEvent as Sensor;
|
||||||
|
// Invoke directly from the settings gesture, before any other async work (iOS).
|
||||||
|
if (
|
||||||
|
sensor.requestPermission &&
|
||||||
|
(await sensor.requestPermission()) !== "granted"
|
||||||
|
) {
|
||||||
|
update({ enabled: false, status: "denied" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
remember(true);
|
||||||
|
update({ enabled: true, status: "enabled" });
|
||||||
|
} catch {
|
||||||
|
update({ enabled: false, status: "denied" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export function useTilt() {
|
||||||
|
const snapshot = useSyncExternalStore(
|
||||||
|
(fn) => {
|
||||||
|
listeners.add(fn);
|
||||||
|
return () => {
|
||||||
|
listeners.delete(fn);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
() => state,
|
||||||
|
);
|
||||||
|
return { ...snapshot, toggleTilt };
|
||||||
|
}
|
||||||
65
src/utils.ts
65
src/utils.ts
|
|
@ -21,6 +21,12 @@ export const displayDate = (
|
||||||
);
|
);
|
||||||
export const number = (value: number, decimals = 0) =>
|
export const number = (value: number, decimals = 0) =>
|
||||||
value.toLocaleString(undefined, { maximumFractionDigits: decimals });
|
value.toLocaleString(undefined, { maximumFractionDigits: decimals });
|
||||||
|
export function displayTime(time: string) {
|
||||||
|
return new Date(`2000-01-01T${time}:00`).toLocaleTimeString(undefined, {
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "2-digit",
|
||||||
|
});
|
||||||
|
}
|
||||||
export const weightValue = (kg: number, unit: Settings["unit"]) =>
|
export const weightValue = (kg: number, unit: Settings["unit"]) =>
|
||||||
unit === "lb" ? kg * 2.2046226218 : kg;
|
unit === "lb" ? kg * 2.2046226218 : kg;
|
||||||
export function recordsOf<T>(records: JournalRecord[], type: string) {
|
export function recordsOf<T>(records: JournalRecord[], type: string) {
|
||||||
|
|
@ -44,7 +50,8 @@ export function downloadExport(
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
a.data.date.localeCompare(b.data.date) ||
|
a.data.date.localeCompare(b.data.date) ||
|
||||||
a.updatedAt.localeCompare(b.updatedAt),
|
(a.data.time || "").localeCompare(b.data.time || "") ||
|
||||||
|
a.id.localeCompare(b.id),
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
const weights = includeWeight
|
const weights = includeWeight
|
||||||
|
|
@ -76,13 +83,14 @@ export function downloadExport(
|
||||||
goals: Object.fromEntries(
|
goals: Object.fromEntries(
|
||||||
selected.map((key) => [key, settings.goals[key]]),
|
selected.map((key) => [key, settings.goals[key]]),
|
||||||
),
|
),
|
||||||
note: "Days without food entries are unlogged, not zero-intake days. Entry nutrients are totals for the recorded quantity. Weight is stored in kg.",
|
note: "Days without food entries are unlogged, not zero-intake days. Entry times are local clock times as entered; older entries may have no time. Entry nutrients are totals for the recorded quantity. Weight is stored in kg.",
|
||||||
};
|
};
|
||||||
const logs = entries.map(
|
const logs = entries.map(
|
||||||
(r) =>
|
(r) =>
|
||||||
({
|
({
|
||||||
id: r.id,
|
id: r.id,
|
||||||
date: r.data.date,
|
date: r.data.date,
|
||||||
|
time: r.data.time || null,
|
||||||
meal: r.data.meal,
|
meal: r.data.meal,
|
||||||
name: r.data.name,
|
name: r.data.name,
|
||||||
serving: r.data.serving,
|
serving: r.data.serving,
|
||||||
|
|
@ -96,6 +104,7 @@ export function downloadExport(
|
||||||
}) as {
|
}) as {
|
||||||
id: string;
|
id: string;
|
||||||
date: string;
|
date: string;
|
||||||
|
time: string | null;
|
||||||
meal: string;
|
meal: string;
|
||||||
name: string;
|
name: string;
|
||||||
serving: string;
|
serving: string;
|
||||||
|
|
@ -123,6 +132,7 @@ export function downloadExport(
|
||||||
const header = [
|
const header = [
|
||||||
"record_type",
|
"record_type",
|
||||||
"date",
|
"date",
|
||||||
|
"time",
|
||||||
"meal",
|
"meal",
|
||||||
"name",
|
"name",
|
||||||
"serving",
|
"serving",
|
||||||
|
|
@ -135,6 +145,7 @@ export function downloadExport(
|
||||||
...logs.map((r) => [
|
...logs.map((r) => [
|
||||||
"entry",
|
"entry",
|
||||||
r.date,
|
r.date,
|
||||||
|
r.time,
|
||||||
r.meal,
|
r.meal,
|
||||||
r.name,
|
r.name,
|
||||||
r.serving,
|
r.serving,
|
||||||
|
|
@ -150,6 +161,7 @@ export function downloadExport(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
...selected.map((k) => r[k]),
|
...selected.map((k) => r[k]),
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
@ -161,6 +173,7 @@ export function downloadExport(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
...selected.map(() => ""),
|
...selected.map(() => ""),
|
||||||
r.data.valueKg,
|
r.data.valueKg,
|
||||||
r.data.notes,
|
r.data.notes,
|
||||||
|
|
@ -176,16 +189,46 @@ export function downloadExport(
|
||||||
`# Calio nutrition journal\n\n${start} to ${end}\n\n${metadata.note}\nPending local changes: ${pending}`,
|
`# Calio nutrition journal\n\n${start} to ${end}\n\n${metadata.note}\nPending local changes: ${pending}`,
|
||||||
];
|
];
|
||||||
if (selected.length) {
|
if (selected.length) {
|
||||||
sections.push("## Goals\n" + selected.map(k => `- ${k}: ${settings.goals[k].enabled ? settings.goals[k].target + " " + metadata.units[k] : "disabled"}`).join("\n"));
|
sections.push(
|
||||||
sections.push([
|
"## Goals\n" +
|
||||||
"## Daily totals (logged days)",
|
selected
|
||||||
`| Date | ${selected.map(k => k + " (" + metadata.units[k] + ")").join(" | ")} |`,
|
.map(
|
||||||
`| --- | ${selected.map(() => "---").join(" | ")} |`,
|
(k) =>
|
||||||
...days.map(d => "| " + [d.date, ...selected.map(k => d[k])].join(" | ") + " |"),
|
`- ${k}: ${settings.goals[k].enabled ? settings.goals[k].target + " " + metadata.units[k] : "disabled"}`,
|
||||||
].join("\n"));
|
)
|
||||||
sections.push("## Food entries\n" + logs.map(r => `- ${r.date} · ${r.meal} · ${clean(r.name)} · ${r.quantity} × ${clean(r.serving)}: ${selected.map(k => `${r[k]} ${metadata.units[k]} ${k}`).join(", ")}`).join("\n"));
|
.join("\n"),
|
||||||
|
);
|
||||||
|
sections.push(
|
||||||
|
[
|
||||||
|
"## Daily totals (logged days)",
|
||||||
|
`| Date | ${selected.map((k) => k + " (" + metadata.units[k] + ")").join(" | ")} |`,
|
||||||
|
`| --- | ${selected.map(() => "---").join(" | ")} |`,
|
||||||
|
...days.map(
|
||||||
|
(d) =>
|
||||||
|
"| " + [d.date, ...selected.map((k) => d[k])].join(" | ") + " |",
|
||||||
|
),
|
||||||
|
].join("\n"),
|
||||||
|
);
|
||||||
|
sections.push(
|
||||||
|
"## Food entries\n" +
|
||||||
|
logs
|
||||||
|
.map(
|
||||||
|
(r) =>
|
||||||
|
`- ${r.date}${r.time ? " " + r.time : ""} · ${r.meal} · ${clean(r.name)} · ${r.quantity} × ${clean(r.serving)}: ${selected.map((k) => `${r[k]} ${metadata.units[k]} ${k}`).join(", ")}`,
|
||||||
|
)
|
||||||
|
.join("\n"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (includeWeight) sections.push("## Weight (kg)\n" + weights.map(r => `- ${r.data.date}: ${number(r.data.valueKg, 2)} kg${r.data.notes ? " · " + clean(r.data.notes) : ""}`).join("\n"));
|
if (includeWeight)
|
||||||
|
sections.push(
|
||||||
|
"## Weight (kg)\n" +
|
||||||
|
weights
|
||||||
|
.map(
|
||||||
|
(r) =>
|
||||||
|
`- ${r.data.date}: ${number(r.data.valueKg, 2)} kg${r.data.notes ? " · " + clean(r.data.notes) : ""}`,
|
||||||
|
)
|
||||||
|
.join("\n"),
|
||||||
|
);
|
||||||
content = sections.join("\n\n") + "\n";
|
content = sections.join("\n\n") + "\n";
|
||||||
}
|
}
|
||||||
const blob = new Blob([content], {
|
const blob = new Blob([content], {
|
||||||
|
|
|
||||||
67
tests/entry.test.js
Normal file
67
tests/entry.test.js
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
import test from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { suggestedMeal, localTime, nextFoodName } from "../shared/entry.js";
|
||||||
|
import { recordSchema, emptyNutrients } from "../shared/domain.js";
|
||||||
|
|
||||||
|
test("meal suggestions follow local time at each meal boundary, including overnight snacks", () => {
|
||||||
|
for (const [hour, expected] of [
|
||||||
|
[0, "Snacks"],
|
||||||
|
[4, "Snacks"],
|
||||||
|
[5, "Breakfast"],
|
||||||
|
[7, "Breakfast"],
|
||||||
|
[10, "Breakfast"],
|
||||||
|
[11, "Lunch"],
|
||||||
|
[15, "Lunch"],
|
||||||
|
[16, "Dinner"],
|
||||||
|
[21, "Dinner"],
|
||||||
|
[22, "Snacks"],
|
||||||
|
[23, "Snacks"],
|
||||||
|
]) {
|
||||||
|
assert.equal(suggestedMeal(new Date(2026, 9, 20, hour, 28)), expected);
|
||||||
|
}
|
||||||
|
assert.equal(localTime(new Date(2026, 9, 20, 6, 28)), "06:28");
|
||||||
|
assert.equal(localTime(new Date(2026, 9, 20, 0, 5)), "00:05");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("unnamed entries advance the category sequence without collisions after removals", () => {
|
||||||
|
assert.equal(nextFoodName("Dinner", []), "Dinner 1");
|
||||||
|
assert.equal(
|
||||||
|
nextFoodName("Dinner", ["Dinner 1", "Dinner 3", "Pasta", "Lunch 8"]),
|
||||||
|
"Dinner 4",
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
nextFoodName("Breakfast", ["Breakfast 1", "Breakfast toast"]),
|
||||||
|
"Breakfast 2",
|
||||||
|
);
|
||||||
|
assert.equal(nextFoodName("Food", ["Food 1"]), "Food 2");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("entry times validate, while legacy records without a time remain compatible", () => {
|
||||||
|
const entry = {
|
||||||
|
id: "e1",
|
||||||
|
type: "entry",
|
||||||
|
updatedAt: "2026-10-20T12:00:00.000Z",
|
||||||
|
deleted: false,
|
||||||
|
data: {
|
||||||
|
name: "Dinner 1",
|
||||||
|
date: "2026-10-20",
|
||||||
|
meal: "Dinner",
|
||||||
|
quantity: 1,
|
||||||
|
serving: "1 serving",
|
||||||
|
nutrients: emptyNutrients(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
assert.equal(recordSchema.safeParse(entry).success, true);
|
||||||
|
for (const time of ["00:00", "06:28", "23:59"])
|
||||||
|
assert.equal(
|
||||||
|
recordSchema.safeParse({ ...entry, data: { ...entry.data, time } })
|
||||||
|
.success,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
for (const time of ["24:00", "12:60", "6:28", "invalid", ""])
|
||||||
|
assert.equal(
|
||||||
|
recordSchema.safeParse({ ...entry, data: { ...entry.data, time } })
|
||||||
|
.success,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
@ -11,6 +11,7 @@ const record = (id, type, data, deleted = false) => ({
|
||||||
});
|
});
|
||||||
const entry = {
|
const entry = {
|
||||||
date: "2026-10-20",
|
date: "2026-10-20",
|
||||||
|
time: "06:28",
|
||||||
meal: "Lunch",
|
meal: "Lunch",
|
||||||
name: "=danger|\nfood",
|
name: "=danger|\nfood",
|
||||||
serving: "1 bowl",
|
serving: "1 bowl",
|
||||||
|
|
@ -64,6 +65,7 @@ test("JSON export includes fractional serving totals, chosen dates/metrics, kg w
|
||||||
assert.equal(data.pendingChanges, 2);
|
assert.equal(data.pendingChanges, 2);
|
||||||
assert.equal(data.entries.length, 1);
|
assert.equal(data.entries.length, 1);
|
||||||
assert.equal(data.entries[0].calories, 300);
|
assert.equal(data.entries[0].calories, 300);
|
||||||
|
assert.equal(data.entries[0].time, "06:28");
|
||||||
assert.equal(data.entries[0].protein, 30);
|
assert.equal(data.entries[0].protein, 30);
|
||||||
assert.equal("fat" in data.entries[0], false);
|
assert.equal("fat" in data.entries[0], false);
|
||||||
assert.equal(data.weights[0].valueKg, 75);
|
assert.equal(data.weights[0].valueKg, 75);
|
||||||
|
|
@ -74,9 +76,11 @@ test("CSV quotes text and guards spreadsheet formula fields; Markdown keeps clea
|
||||||
assert.match(csv, /"'=danger\|\nfood"/);
|
assert.match(csv, /"'=danger\|\nfood"/);
|
||||||
assert.match(csv, /"'=untrusted"/);
|
assert.match(csv, /"'=untrusted"/);
|
||||||
assert.match(csv, /"daily_total"/);
|
assert.match(csv, /"daily_total"/);
|
||||||
|
assert.match(csv, /"06:28"/);
|
||||||
const markdown = await capture("markdown");
|
const markdown = await capture("markdown");
|
||||||
assert.match(markdown, /\| 2026-10-20 \| 300 \| 30 \|/);
|
assert.match(markdown, /\| 2026-10-20 \| 300 \| 30 \|/);
|
||||||
assert.match(markdown, /=danger\/ food/);
|
assert.match(markdown, /=danger\/ food/);
|
||||||
|
assert.match(markdown, /2026-10-20 06:28/);
|
||||||
assert.doesNotMatch(markdown, /2026-10-19/);
|
assert.doesNotMatch(markdown, /2026-10-19/);
|
||||||
});
|
});
|
||||||
test("weight-only exports omit food records; excluding weight omits all weigh-ins", async () => {
|
test("weight-only exports omit food records; excluding weight omits all weigh-ins", async () => {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,16 @@ test("bubble count tracks calories, remains visible at small amounts, and caps o
|
||||||
assert.equal(bubbleCount(2000, 2000, true), MAX_BUBBLES);
|
assert.equal(bubbleCount(2000, 2000, true), MAX_BUBBLES);
|
||||||
assert.equal(bubbleCount(20000, 2000, true), MAX_BUBBLES);
|
assert.equal(bubbleCount(20000, 2000, true), MAX_BUBBLES);
|
||||||
});
|
});
|
||||||
|
test("an 800 calorie meal drops in with 50 percent more bubbles per second", () => {
|
||||||
|
const world = createBubbleWorld(0, () => 0.5);
|
||||||
|
const target = bubbleCount(800, 2000, true);
|
||||||
|
world.setTarget(target);
|
||||||
|
for (let i = 0; i < 60; i++) world.step();
|
||||||
|
assert.equal(world.balls.length, 30);
|
||||||
|
for (let i = 0; i < target * 2 - 60; i++) world.step();
|
||||||
|
assert.equal(world.balls.length, target);
|
||||||
|
world.dispose();
|
||||||
|
});
|
||||||
test("new bubbles enter at the top, fall, collide and stay inside the calorie vessel", () => {
|
test("new bubbles enter at the top, fall, collide and stay inside the calorie vessel", () => {
|
||||||
const world = createBubbleWorld(0, () => 0.5);
|
const world = createBubbleWorld(0, () => 0.5);
|
||||||
world.setTarget(8);
|
world.setTarget(8);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue