UNPKG

@webwriter/network

Version:

Visualization of network topologies. Can represent different kinds of networks.

34 lines (26 loc) 1.26 kB
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 = `<sl-icon slot=\"icon\" name=\"` + icon + `\"></sl-icon>`; alert.innerHTML += headerMessage != null && headerMessage != '' ? `<strong>` + headerMessage + `</strong><br/>` : ''; alert.innerHTML += subMessage != null && subMessage != '' ? subMessage : ''; alert.variant = variant; alert.toast(); } }