-
Notifications
You must be signed in to change notification settings - Fork 25
Toast notifications: add auto-dismiss, close button, and warning severity #133
Copy link
Copy link
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Summary
The toast notification system (flash/1 component) has several small UX issues that make it feel unfinished. Good starter task — all changes are in 2 files.
Current Behavior
Toasts are rendered via flash/1 in core_components.ex:9-62, triggered by put_flash/2 throughout the app. They slide in from the right with a nice glassmorphism style, but:
- No auto-dismiss — Toasts persist forever until the user clicks them
- No close button — The entire toast is clickable to dismiss, but there's no visible
×affordance. Users don't know they can click it :warningseverity is silently dropped —workspace_live.excallsput_flash(:warning, ...)for agent-unavailable messages, butflash_group/1only renders:infoand:error(line 19:values: [:info, :error]). Warnings vanish into the void
Expected Behavior
- Toasts auto-dismiss after ~5 seconds (with a subtle fade-out animation)
- A small
×button in the top-right corner of each toast for manual dismiss :warningseverity renders with amber/yellow styling (matching the existing emerald/rose pattern)
Implementation Guide
Auto-dismiss
Add a phx-mounted JS hook or use Process.send_after in the LiveView to clear flash after a timeout. Alternatively, a lightweight JS approach:
// In app.js or a Hook
Hooks.AutoDismissFlash = {
mounted() {
this.timer = setTimeout(() => {
this.el.style.opacity = "0"
setTimeout(() => this.el.remove(), 300)
}, 5000)
},
destroyed() { clearTimeout(this.timer) }
}Close button
Add an × button inside the flash div (before the <p> content), wired to the existing lv:clear-flash event.
Warning severity
- In
core_components.ex:19, changevalues: [:info, :error]→values: [:info, :error, :warning] - Add amber styling variant:
@kind == :warning && "bg-amber-950/80 text-amber-200 border-amber-500/30" - In
flash_group/1(line 55-62), add<.flash id="flash-warning" kind={:warning} ... />
Files to Change
lib/loomkin_web/components/core_components.ex— flash component (lines 9-62)assets/js/app.js— auto-dismiss hook (if using JS approach)assets/css/app.css— fade-out animation (optional, for smooth dismiss)
Acceptance Criteria
- Toasts auto-dismiss after ~5 seconds
- Each toast has a visible
×close button -
:warningflash messages render with amber styling - Existing
:info(emerald) and:error(rose) toasts still work - Auto-dismiss timer resets if user hovers over toast (nice-to-have)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers