14 lines
868 B
JavaScript
14 lines
868 B
JavaScript
// Generated, do not edit. sha256:9524042357ce22fcf244cdc26ee3cb73b68a915569fd002433a8ce0705465b4d
|
||||
|
|
import { esc } from './escape.js';
|
|||
|
|
|
|||
|
|
const ICONS = { info: 'ℹ️', success: '✓', error: '⚠️', neutral: '' };
|
|||
|
|
|
|||
|
|
export function alertHtml({ kind = 'neutral', title = '', body = '', icon, extra = '', className = '' }) {
|
|||
|
|
if (!(kind in ICONS)) throw new Error(`Unknown alert kind: ${kind}.`);
|
|||
|
|
const teken = icon === undefined ? ICONS[kind] : (icon || '');
|
|||
|
|
const iconHtml = teken ? `<span class="alert-icon">${teken}</span>` : '';
|
|||
|
|
const titleHtml = title ? `<div class="alert-title">${esc(title)}</div>` : '';
|
|||
|
|
const bodyHtml = body ? `<div class="alert-body">${esc(body)}</div>` : '';
|
|||
|
|
return `<div class="alert alert-${kind}${className ? ` ${className}` : ''}">${iconHtml}`
|
|||
|
|
+ `<div class="alert-content">${titleHtml}${bodyHtml}${extra}</div></div>`;
|
|||
|
|
}
|