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:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { profileStore } from '$lib/client/profile.svelte';
|
||||
import { confirmAction } from '$lib/client/confirm.svelte';
|
||||
import type { WishlistEntry, SortKey } from '$lib/server/wishlist/repository';
|
||||
|
||||
let entries = $state<WishlistEntry[]>([]);
|
||||
@@ -39,7 +40,13 @@
|
||||
}
|
||||
|
||||
async function remove(entry: WishlistEntry) {
|
||||
if (!confirm(`„${entry.title}" von der Wunschliste entfernen?`)) return;
|
||||
const ok = await confirmAction({
|
||||
title: 'Von der Wunschliste entfernen?',
|
||||
message: `„${entry.title}" wird aus der Wunschliste entfernt. Das Rezept selbst bleibt gespeichert.`,
|
||||
confirmLabel: 'Entfernen',
|
||||
destructive: true
|
||||
});
|
||||
if (!ok) return;
|
||||
await fetch(`/api/wishlist/${entry.recipe_id}`, { method: 'DELETE' });
|
||||
await load();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user