Skip to content

[haxcms-elements] HAX UI toast: same API, new look - #1037

Merged
btopro merged 1 commit into
masterfrom
haxcms-toast-hax-ui
Oct 30, 2026
Merged

btopro merged 1 commit into
masterfrom
haxcms-toast-hax-ui

Conversation

@btopro

@btopro btopro commented Oct 30, 2026

Copy link
Copy Markdown
Member

A proposal to replace the HAXcms toast with a card in the HAX UI admin style. It's the same API, so every existing call keeps working, with a new look and a few long-standing fixes. Part of the HAX UI admin work in haxtheweb/issues#3180.

What changes

  • Look.

    • The toast is one card on HAX UI tokens: surface, line, radius and popover shadow, in light, dark and forced colours.
    • The person's RPG character sits in a tile tinted by tone, with a small tone badge (a check, an exclamation mark, or a spinner while working).
    • The message is 14px and wraps. A close button sits on the right.
    • Anything a caller slots in is styled as a HAX UI button.
    • A thin bar shows the time left, or moves continuously while work is in progress.
    • At 600px and narrower the toast becomes a sheet along the bottom.
  • Tone (new, optional: info, success, warning, danger, working, assistant). When a caller doesn't set it, it's worked out from what callers already send:

    Tone Comes from
    danger hat: "error"
    working hat: "construction" or walking
    assistant merlin: true
    success hat: "save" or "good"
    info everything else
  • Fixes:

    • The timer pauses while the toast is hovered or focused (WCAG 2.2.1).
    • duration: 0 now stays until closed. Today it silently becomes 4s, so the view-only notice closes before its Exit button can be used.
    • Problems are announced as alerts (role="alert", assertive), with the tone spoken in words.
    • Esc closes it while focus is inside, and it never takes focus itself.
    • eventCallback fires once on close; today it fires twice.

API kept

  • store.toast() and HAXStore.toast() keep their signatures (about 220 calls).
  • The haxcms-toast-show and haxcms-toast-hide events are unchanged.
  • Every detail field still works: text, duration, hat, fire, walking, speed, slot, closeText, eventCallback, alwaysvisible, merlin, future and awaitingMerlinInput. The character still wears the hat, catches fire and walks.
  • classStyle, accentColor and dark are accepted and ignored.
  • The hax:loading spinner that "Processing" slots in is hidden, because the working tone already shows progress.

What it touches

  • elements/haxcms-elements/lib/core/haxcms-toast.js
  • elements/haxcms-elements/test/haxcms-toast.test.js

rpg-character-toast, simple-toast and app-hax's toast are untouched.

Tested

  • 20 toast tests, covering the tone mapping, a sticky duration: 0, pause and resume, Esc, eventCallback firing once, slotted actions, the working spinner, Merlin, alert vs status, and axe.
  • The haxcms-elements suite passes (663 tests), and so does precheck.
  • I checked it in the real editor, built on haxcms-nodejs main, with before and after screenshots of each variant in light and dark, on desktop and phone.

Follow-ups

  • Switch the badge icons to hax:admin-check, hax:admin-warning and hax:admin-refresh once the admin icon family (webcomponents#1031) lands.
  • Give high-traffic calls an explicit tone: saves as success, recoverable problems as warning.

https://claude.ai/code/session_01PfFvVUkTpLX8DucJwVoaVk


Generated by Claude Code

Replaces the speech-bubble toast with a card in the HAX UI admin style:
the person's RPG character in a tile tinted by tone with a small tone
badge, the message at 14px that wraps, a close button, HAX UI buttons for
anything a caller slots in, and a thin bar with the time left (a moving
bar while work is in progress). Light, dark and forced colours. At 600px
and narrower it is a sheet along the bottom.

Same API: store.toast() / HAXStore.toast(), haxcms-toast-show and
haxcms-toast-hide, and every detail field. New and optional: `tone`
(info, success, warning, danger, working, assistant); otherwise worked
out from what callers already send (hat "error" is danger, "construction"
or walking is working, merlin is the assistant). The hax:loading spinner
that "Processing" slots in is hidden, since the working tone shows it.

Fixes along the way:
- the timer pauses while hovered or focused (WCAG 2.2.1)
- duration 0 stays until closed (it silently became 4s, closing the
  view-only notice before its Exit button could be used)
- problems are announced as alerts, with the tone in words
- Esc closes it while focus is inside
- eventCallback fires once on close (it fired twice)

Only haxcms-toast.js changes; rpg-character-toast, simple-toast and
app-hax's toast are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PfFvVUkTpLX8DucJwVoaVk
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webcomponents Ready Ready Preview Oct 30, 2026 5:16am UTC

Request Review

@btopro
btopro merged commit bc8eb89 into master Oct 30, 2026
10 checks passed
@btopro
btopro deleted the haxcms-toast-hax-ui branch October 30, 2026 14:41
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 30, 2026

This branch was successfully deployed

1 active deployment
Preview — 0d290065 Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants