Implement the 032-inline-confirm-buttons feature that replaces single-click destructive actions with a reusable ConfirmButton component providing inline two-step confirmation (click to arm, click to execute), applied to the remove combatant and clear encounter buttons, with CSS scale pulse animation, 5-second auto-revert, click-outside/Escape/blur dismissal, full keyboard accessibility, and 13 unit tests via @testing-library/react
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
40
specs/032-inline-confirm-buttons/quickstart.md
Normal file
40
specs/032-inline-confirm-buttons/quickstart.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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 ConfirmButton
|
||||
- `apps/web/src/components/turn-navigation.tsx` — Replace trash Button with ConfirmButton
|
||||
- `apps/web/src/hooks/use-encounter.ts` — Remove `window.confirm()` from clearEncounter
|
||||
- `apps/web/src/index.css` — Add scale pulse keyframe animation
|
||||
|
||||
## How to Test
|
||||
|
||||
```bash
|
||||
# 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 `Button` component (no new base component)
|
||||
- Confirm state is local `useState` — no shared state or context needed
|
||||
- Click-outside detection follows the `HpAdjustPopover` pattern (mousedown listener)
|
||||
- Animation uses CSS `@keyframes` + `@utility` like existing animations
|
||||
- Uses `bg-destructive text-primary-foreground` for the confirm state
|
||||
Reference in New Issue
Block a user