feat(ui): custom confirmation dialog replacing native window.confirm
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 51s
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:
@@ -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('/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user