import SlAlert from '@shoelace-style/shoelace/dist/components/alert/alert.component.js';
type AlertType = 'primary' | 'success' | 'neutral' | 'warning' | 'danger';
export class AlertHelper {
static toasted = false;
static toastAlert(variant: AlertType, icon: string, headerMessage: string, subMessage: string): void {
// Merge the header and sub message
const fullMessage = (headerMessage + (headerMessage != "" && subMessage != "" ? " - " : "") + subMessage);
if (variant == 'danger') {
console.error(fullMessage);
return;
}
if (variant == 'success') {
// Currently there is no way to show a success notification in WebWriter
console.error(fullMessage);
return;
}
const alert = document.createElement('sl-alert') as SlAlert;
alert.closable = true;
alert.innerHTML = ``;
alert.innerHTML +=
headerMessage != null && headerMessage != '' ? `` + headerMessage + `
` : '';
alert.innerHTML += subMessage != null && subMessage != '' ? subMessage : '';
alert.variant = variant;
alert.toast();
}
}