feat(ui): custom confirmation dialog replacing native window.confirm
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 51s

Single reusable dialog with a promise-based API: confirmAction({...})
returns Promise<boolean>. Supports title, optional message body,
confirm/cancel labels, and a 'destructive' flag that paints the confirm
button red.

Accessibility: Escape cancels, Enter confirms, confirm button auto-focus,
role=dialog + aria-labelledby, backdrop click = cancel.

Rolled out to: recipe delete, domain remove, profile delete, wishlist
remove. Native confirm() is gone from the codebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 17:15:21 +02:00
parent 3b1950713f
commit 1b9928f806
7 changed files with 229 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
import RecipeView from '$lib/components/RecipeView.svelte';
import StarRating from '$lib/components/StarRating.svelte';
import { profileStore } from '$lib/client/profile.svelte';
import { confirmAction } from '$lib/client/confirm.svelte';
import type { CommentRow } from '$lib/server/recipes/actions';
let { data } = $props();
@@ -109,7 +110,13 @@
}
async function deleteRecipe() {
if (!confirm(`Rezept „${data.recipe.title}" wirklich löschen?`)) return;
const ok = await confirmAction({
title: 'Rezept löschen?',
message: `„${data.recipe.title}" wird endgültig entfernt — mit Bewertungen, Kommentaren und Kochjournal-Einträgen.`,
confirmLabel: 'Löschen',
destructive: true
});
if (!ok) return;
await fetch(`/api/recipes/${data.recipe.id}`, { method: 'DELETE' });
goto('/');
}