usePublishMark
Three states for the one moment a form is worth animating.
Part of
@aora-bot/surfaces, not@aora-bot/react:pnpm add @aora-bot/surfaces @aora-bot/react, and import@aora-bot/surfaces/styles.cssafter the React stylesheet.
Why only here
Publishing is the rare interaction where a character earns its keep: there is a real wait, a real outcome, and the outcome is good news. So the mark works while the request is out, celebrates when it lands, then puts itself away — a celebration that has to be dismissed stops being one.
Failure returns straight to rest rather than to a sad face. The form is about to show a message saying what went wrong, and a character pulling an expression next to it reads as the library editorialising.
The contract
usePublishMark(options) returns a PublishMark:
Options:
confetti— a ref to aConfettiLayer. The hook firesburst(20 pieces by default) on success so the host never has to notice the moment itself. It is supplied by the caller rather than returned from the hook: the ref belongs to the element it is attached to, and a hook handing one out invites reading.currentduring render.celebrateMs— how long the celebration holds (1600 ms by default).onSettled— called when the celebration has finished. A good place to close a dialog.
A celebration in flight when the component unmounts is cancelled, so nothing fires a state update into a component that has gone. TemplateDialog uses this hook for its Save button.
Next
- ConfettiLayer — paper over anything
- Celebration — work, celebrate, put itself away