import type { ColorInput } from "@opentui/core"; import { Portal } from "@opentui/solid"; import { For } from "solid-js"; import { dismiss, notifications, type NotificationKind } from "../context/notifications.ts"; import { theme } from "../index.ts"; const KIND_LABEL: Record = { info: "Info", success: "Success", warning: "Warning", error: "Error", }; export interface NotificationHostProps { width?: number; colors?: Partial>; } export function NotificationHost(props: NotificationHostProps = {}) { const defaultColor = (): Record => ({ info: theme.primary, success: theme.success, warning: theme.warning, error: theme.error, }); const colorFor = (kind: NotificationKind) => props.colors?.[kind] ?? defaultColor()[kind]; return ( {(toast) => ( dismiss(toast.id) : undefined} > {toast.title ?? KIND_LABEL[toast.kind]} {toast.message} )} ); }