Implement progressive enhancement for recipe multiplier with form fallbacks

Add form-based multiplier controls that work without JavaScript while providing enhanced UX when JS is available. Fixed fraction display and NaN flash issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-04 17:34:43 +02:00
parent aeec3b4865
commit 88f9531a6f
2 changed files with 154 additions and 43 deletions

View File

@@ -1,6 +1,6 @@
import { error } from "@sveltejs/kit";
export async function load({ fetch, params}) {
export async function load({ fetch, params, url}) {
const res = await fetch(`/api/rezepte/items/${params.name}`);
let item = await res.json();
if(!res.ok){
@@ -19,8 +19,12 @@ export async function load({ fetch, params}) {
// Silently fail if not authenticated or other error
}
// Get multiplier from URL parameters
const multiplier = parseFloat(url.searchParams.get('multiplier') || '1');
return {
...item,
isFavorite
isFavorite,
multiplier
};
}