Repository navigation
Toast CRUD feedback in the top-right corner - #66
Merged
Merged
Conversation
A save on a long form answers at the bottom of that form: off-screen on a
phone, below the fold on a desktop. The work happened and nothing appeared to.
Toasts now slide in from the top-right, say the server's own sentence, and
slide out after five seconds (seven for a warning, nine for a refusal). They
pause while the pointer or the keyboard is over them, carry an icon and the
words so colour is never the only signal, and raise an alert role when the
answer is a refusal. Reduced motion is honoured by the app-wide MotionConfig.
readFeedback() decides what a state means in a pure function: an untouched
form is { ok: false, message: null } — identical in shape to a refusal — and
must not announce that nothing was saved before anything was pressed.
Wired to every CRUD form that already reports through useActionState: settings
(appearance, notifications, support contacts, banner), users (create, details,
role, access, reset, active), trainings (create/update, roster, discussion,
cover), authoring (draft, review decision, publish, archive), complaints
(respond, reset access) and messages. The inline message stays; the toast is a
second copy, which is why the hook falls silent outside the provider.
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slide-in toasts for every create, update and delete that reports through a server action, colour-coded by what happened.
What was wrong
Every action already answers —
{ ok, message }or{ error, done }— but it answers at the bottom of the form it came from. On a phone that is off-screen; on a long desktop form it is below the fold. The save worked and nothing appeared to.What this does
src/components/ui/toast.tsx— aToastProvidermounted once in the root layout, auseToast()hook and auseActionToast(state, { success })bridge. Toasts enter from the right (x: 40 → 0), stack up to four, exit the same way, and are dismissible.role="alert"for a screen reader.prefers-reduced-motionis honoured by the app-wideMotionConfigalready in place.src/lib/action-feedback.ts—readFeedback(), a pure function with tests, decides what a state means. This matters because an untouched form is{ ok: false, message: null }: the same shape as a refusal. Without it, every form would announce "not saved" on mount.Wired
Settings (appearance, notifications, support contacts, banner save and clear) — Users (create, details, role, access, reset link, active, password) — Trainings (create/update, roster add and bulk, discussion, cover image) — Authoring (new draft, submit for review, review decision, publish, archive) — Complaints (respond, reset access) — Messages (send).
The inline
FormFeedbackstays everywhere it was. A toast is a second copy, not a replacement.Deliberately left out
Server-action forms that carry no state at all (the geography and programme-area drawers, the sign-out and menu one-liners). They revalidate the page and show the result inline; wrapping each in a state just to raise a toast would be more machinery than the problem deserves. Say the word and they can be converted.
Gates
npx tsc --noEmitcleannpx eslint .cleannpx vitest run— 62 files / 385 tests (4 new forreadFeedback, 5 DOM tests for the provider and hook: untouched form says nothing, success once with the server's sentence, refusal asalert, no repeat on re-render, silence outside a provider)next buildcompilesdocs/ui-ux.md§"Feedback on every action" now describes the corner and why it exists alongside the inline message.