From cb35a5c3dcf850ab9379905d590d0b47b17c2270 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Wed, 8 Apr 2026 10:24:11 +0200 Subject: [PATCH] feat: add liquid tracking card to nutrition page with water cups and beverage detection Track water intake via interactive SVG cups (fill/drain animations) using BLS Trinkwasser entries for mineral tracking. Detect beverages from food log (BLS N-codes + name patterns) and include in liquid totals. Configurable daily goal stored in localStorage. Cups show beverage fills (amber) as non-removable and water fills (blue) as adjustable. --- package.json | 2 +- src/models/FoodLogEntry.ts | 4 +- src/routes/api/fitness/food-log/+server.ts | 2 +- .../[nutrition=fitnessNutrition]/+page.svelte | 388 +++++++++++++++++- 4 files changed, 391 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b115ec3..96ae6c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.9.0", + "version": "1.10.0", "private": true, "type": "module", "scripts": { diff --git a/src/models/FoodLogEntry.ts b/src/models/FoodLogEntry.ts index 0cd4fcc..8bee99c 100644 --- a/src/models/FoodLogEntry.ts +++ b/src/models/FoodLogEntry.ts @@ -3,7 +3,7 @@ import mongoose from 'mongoose'; interface IFoodLogEntry { _id?: string; date: Date; - mealType: 'breakfast' | 'lunch' | 'dinner' | 'snack'; + mealType: 'breakfast' | 'lunch' | 'dinner' | 'snack' | 'water'; name: string; source: 'bls' | 'usda' | 'recipe' | 'custom' | 'off'; sourceId?: string; @@ -45,7 +45,7 @@ const NutritionSnapshotSchema = new mongoose.Schema({ const FoodLogEntrySchema = new mongoose.Schema( { date: { type: Date, required: true }, - mealType: { type: String, enum: ['breakfast', 'lunch', 'dinner', 'snack'], required: true }, + mealType: { type: String, enum: ['breakfast', 'lunch', 'dinner', 'snack', 'water'], required: true }, name: { type: String, required: true, trim: true }, source: { type: String, enum: ['bls', 'usda', 'recipe', 'custom', 'off'], required: true }, sourceId: { type: String }, diff --git a/src/routes/api/fitness/food-log/+server.ts b/src/routes/api/fitness/food-log/+server.ts index 541cf2f..1855cfd 100644 --- a/src/routes/api/fitness/food-log/+server.ts +++ b/src/routes/api/fitness/food-log/+server.ts @@ -4,7 +4,7 @@ import { requireAuth } from '$lib/server/middleware/auth'; import { dbConnect } from '$utils/db'; import { FoodLogEntry } from '$models/FoodLogEntry'; -const VALID_MEALS = ['breakfast', 'lunch', 'dinner', 'snack']; +const VALID_MEALS = ['breakfast', 'lunch', 'dinner', 'snack', 'water']; export const GET: RequestHandler = async ({ locals, url }) => { const user = await requireAuth(locals); diff --git a/src/routes/fitness/[nutrition=fitnessNutrition]/+page.svelte b/src/routes/fitness/[nutrition=fitnessNutrition]/+page.svelte index 99bbb2f..a661a29 100644 --- a/src/routes/fitness/[nutrition=fitnessNutrition]/+page.svelte +++ b/src/routes/fitness/[nutrition=fitnessNutrition]/+page.svelte @@ -1,7 +1,7 @@