3de82e3b9b
Drop ?v=N version pins from all JS imports and HTML <link>/<script> tags. Cache invalidation is now handled solely by server-side cache-control headers. Update docs and AGENTS.md accordingly.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
/**
|
|
* Hoover — components/toast.js
|
|
*
|
|
* ToastContainer component that renders queued toast notifications.
|
|
* Uses the toast/dismissToast state from api.js.
|
|
*/
|
|
|
|
import { h } from '../vdom.js';
|
|
import { _toasts, dismissToast } from '../api.js';
|
|
|
|
/**
|
|
* Render all pending toast notifications.
|
|
*
|
|
* @returns {VNode}
|
|
*/
|
|
export function ToastContainer() {
|
|
if (!_toasts.length) return h('#text', '');
|
|
|
|
const clsMap = {
|
|
info: 'toast-info',
|
|
success: 'toast-success',
|
|
error: 'toast-error',
|
|
warning: 'toast-warning',
|
|
};
|
|
|
|
return h('div', { class: 'toast' },
|
|
..._toasts.map(t =>
|
|
h('div', {
|
|
class: `toast-message ${clsMap[t.type] || clsMap.info}`,
|
|
'on:click': () => dismissToast(t.id),
|
|
},
|
|
h('span', { class: 'toast-text' }, t.message),
|
|
h('div', { class: 'toast-actions' },
|
|
h('button', {
|
|
class: 'toast-btn toast-close',
|
|
'on:click': (e) => { e.stopPropagation(); dismissToast(t.id); },
|
|
}, '\u00d7'),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|