import { html, type TemplateResult } from 'lit'; import type { PlaygroundControl, PlaygroundDefinition, PlaygroundPreviewHandlers, PlaygroundProps, } from '../types.js'; import { formatUsageFromDefaults, whenBoolean, whenString } from '../types.js'; export const NUI_TOAST_DEFAULTS: PlaygroundProps = { position: 'top-right', unstyled: false, nuiType: '', }; export const ATTRIBUTE_NAMES: string[] = ['position', 'unstyled', 'nui-type']; export const CONTROLS: PlaygroundControl[] = [ { key: 'position', label: 'position', type: 'select', options: [ { value: 'top-right', label: 'top-right' }, { value: 'top-left', label: 'top-left' }, { value: 'bottom-right', label: 'bottom-right' }, { value: 'bottom-left', label: 'bottom-left' }, { value: 'top-center', label: 'top-center' }, { value: 'bottom-center', label: 'bottom-center' }, ], section: 'Layout', }, { key: 'unstyled', label: 'unstyled', type: 'boolean', section: 'Modifiers', }, { key: 'nuiType', label: 'nui-type', type: 'text', section: 'Modifiers', }, ]; function renderPreview( props: PlaygroundProps, _handlers?: PlaygroundPreviewHandlers, ): TemplateResult { const triggerToast = (severity: 'success' | 'info' | 'warn' | 'error') => { window.dispatchEvent( new CustomEvent('nui-toast-add', { detail: { severity, summary: `${severity.charAt(0).toUpperCase() + severity.slice(1)} Message`, detail: `This is a sample ${severity} notification content.`, life: 3000, }, }), ); }; return html`
`; } export const nuiToastPlayground: PlaygroundDefinition = { tag: 'nui-toast', label: 'Toast', description: 'A global overlay notification component.', defaults: NUI_TOAST_DEFAULTS, controls: CONTROLS, renderPreview, formatUsage: (props) => formatUsageFromDefaults('nui-toast', props, NUI_TOAST_DEFAULTS, {}), };