26 lines
980 B
JavaScript
26 lines
980 B
JavaScript
// Minimal-API mit Fallbacks: GlassToastra → toastr → eigener Mini-Toast
|
|
export function showToast({ type = 'success', text = '', title = '' } = {}) {
|
|
const t = (type || 'success').toLowerCase();
|
|
const msg = text || '';
|
|
|
|
// 1) Dein Glas-Toast
|
|
if (window.GlassToastra && typeof window.GlassToastra[t] === 'function') {
|
|
window.GlassToastra[t](msg, title);
|
|
return;
|
|
}
|
|
// 2) toastr
|
|
if (window.toastr && typeof window.toastr[t] === 'function') {
|
|
window.toastr.options = { timeOut: 3500, progressBar: true, closeButton: true };
|
|
window.toastr[t](msg, title);
|
|
return;
|
|
}
|
|
// 3) Fallback
|
|
const box = document.createElement('div');
|
|
box.className =
|
|
'fixed top-4 right-4 z-[9999] rounded-xl bg-emerald-500/90 text-white ' +
|
|
'px-4 py-3 backdrop-blur shadow-lg border border-white/10';
|
|
box.textContent = msg;
|
|
document.body.appendChild(box);
|
|
setTimeout(() => box.remove(), 3500);
|
|
}
|