UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

34 lines (33 loc) 1.24 kB
import type { ComponentChildren } from 'preact'; export type ToastMessage = { id: string; type: 'error' | 'success' | 'notice'; message: ComponentChildren; /** * Visually hidden messages are announced to screen readers but not visible. * Defaults to false. */ visuallyHidden?: boolean; /** * Determines if the toast message should be auto-dismissed. * Defaults to true. */ autoDismiss?: boolean; }; export type ToastMessageTransitionClasses = { /** Classes to apply to a toast message when appended. Defaults to 'animate-fade-in' */ transitionIn?: string; /** Classes to apply to a toast message being dismissed. Defaults to 'animate-fade-out' */ transitionOut?: string; }; export type ToastMessagesProps = { messages: ToastMessage[]; onMessageDismiss: (id: string) => void; transitionClasses?: ToastMessageTransitionClasses; setTimeout_?: typeof setTimeout; }; /** * A collection of toast messages. These are rendered within an `aria-live` * region for accessibility with screen readers. */ export default function ToastMessages({ messages, onMessageDismiss, transitionClasses, setTimeout_, }: ToastMessagesProps): import("preact").JSX.Element;