fixed blinking

This commit is contained in:
2026-05-16 20:01:48 +02:00
parent ed0edc4c99
commit 23c62fb1e6
4 changed files with 80 additions and 45 deletions
+11 -4
View File
@@ -117,15 +117,22 @@ export function confirmDialog(opts: ConfirmOptions): Promise<boolean> {
});
}
/** Transient bottom-center toast. Replaces window.alert for failures. */
/** Transient hovering toast at the top of the viewport. Replaces
* window.alert and the old inline save banners. */
export function notify(message: string, tone: 'error' | 'success' = 'error') {
document.querySelector('.toast[data-notify]')?.remove();
const el = document.createElement('div');
el.className = `toast${tone === 'error' ? ' toast--error' : ''}`;
el.className = `toast toast--${tone}`;
el.dataset.notify = '';
el.setAttribute('role', tone === 'error' ? 'alert' : 'status');
el.textContent = message;
el.addEventListener('click', () => el.remove());
const dismiss = () => {
if (el.classList.contains('toast--out')) return;
el.classList.add('toast--out');
window.setTimeout(() => el.remove(), 220);
};
el.addEventListener('click', dismiss);
document.body.appendChild(el);
window.setTimeout(() => el.remove(), 4500);
window.setTimeout(dismiss, 4500);
}