import './style.scss'; import clsx from 'clsx'; import { translate } from 'i18n-calypso'; import closeIcon from './images/close.svg'; import errorIcon from './images/error.svg'; import successIcon from './images/success.svg'; import warningIcon from './images/warning.svg'; export enum NoticeType { Success = 'success', Warning = 'warning', Error = 'error', } export type NoticeState = { type: NoticeType; message: string | React.ReactNode; onClose?: () => void; action?: React.ReactNode; }; type NoticeProps = { children: React.ReactNode; className?: string; action?: React.ReactNode; type?: NoticeType; onClose?: () => void; visible?: boolean; }; const Notice = ( { children, className, action, type = NoticeType.Success, onClose, visible = true, }: NoticeProps ) => { return visible ? (
{ onClose && ( { e.preventDefault(); onClose?.(); } } > { ) }
{ children }
{ action &&
{ action }
}
) : null; }; export default Notice;