fixed blinking
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user