'use client' import type { ReactNode } from 'react' import { cn } from '../../lib/cn' import { IconButton } from '../IconButton' import { Text } from '../Text' import type { IconComponent } from '../../lib/types' import { CrossIcon } from '../internal/icons' export type AlertTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger' const TONES: Record = { neutral: { surface: 'border-line bg-surface-sunken', mark: 'bg-ink-faint' }, accent: { surface: 'border-accent-soft bg-accent-soft/50', mark: 'bg-accent-strong' }, success: { surface: 'border-line bg-surface-sunken', mark: 'bg-success' }, warning: { surface: 'border-line bg-surface-sunken', mark: 'bg-warning' }, danger: { surface: 'border-line bg-surface-sunken', mark: 'bg-danger' }, } /** Danger and warning are assertive; the rest are polite. */ const LIVE: Record = { neutral: 'polite', accent: 'polite', success: 'polite', warning: 'assertive', danger: 'assertive', } export interface AlertProps { tone?: AlertTone /** Heading for the message. */ title?: string /** The message body. */ children?: ReactNode /** Glyph shown before the text. */ icon?: IconComponent /** Right-aligned affordance — usually a Button. */ action?: ReactNode /** Adds a dismiss control. */ onDismiss?: () => void /** Announce when it appears. Leave off for content present on load. */ live?: boolean /** Merged last, so it wins. */ className?: string } /** * A persistent message block. The tone is carried by a coloured rail rather * than by a full colour wash, so an alert sits inside a card without competing * with it — and so tone is never the only signal. */ export function Alert({ tone = 'neutral', title, children, icon: Icon, action, onDismiss, live = false, className, }: AlertProps) { const styles = TONES[tone] return (
) }