1.6 KiB
1.6 KiB
Quickstart: Inline Confirmation Buttons
What This Feature Does
Replaces single-click destructive actions and browser window.confirm() dialogs with inline two-step confirmation buttons. Click once to arm, click again to execute. The button visually transforms (checkmark icon, red background, scale pulse) to signal the armed state, and auto-reverts after 5 seconds.
Files to Create
apps/web/src/components/ui/confirm-button.tsx— Reusable ConfirmButton component
Files to Modify
apps/web/src/components/combatant-row.tsx— Replace remove Button with ConfirmButtonapps/web/src/components/turn-navigation.tsx— Replace trash Button with ConfirmButtonapps/web/src/hooks/use-encounter.ts— Removewindow.confirm()from clearEncounterapps/web/src/index.css— Add scale pulse keyframe animation
How to Test
# Run all tests
pnpm test
# Run the dev server and test manually
pnpm --filter web dev
# 1. Add a combatant
# 2. Click the X button — should enter red confirm state
# 3. Click again — combatant removed
# 4. Click X, wait 5 seconds — should revert
# 5. Click trash button — same confirm behavior for clearing encounter
# 6. Test keyboard: Tab to button, Enter, Enter (confirm), Escape (cancel)
Key Design Decisions
- ConfirmButton wraps the existing
Buttoncomponent (no new base component) - Confirm state is local
useState— no shared state or context needed - Click-outside detection follows the
HpAdjustPopoverpattern (mousedown listener) - Animation uses CSS
@keyframes+@utilitylike existing animations - Uses
bg-destructive text-primary-foregroundfor the confirm state