import {
__experimentalVStack as VStack,
__experimentalHStack as HStack,
Button,
Card,
CardBody,
Icon,
} from '@wordpress/components';
import { info, published, error, closeSmall } from '@wordpress/icons';
import clsx from 'clsx';
import { forwardRef } from 'react';
import { caution } from './icons';
import type { NoticeVariant, NoticeProps } from './types';
import './style.scss';
const icons: { [ key in NoticeVariant ]: any } = {
info,
warning: caution,
success: published,
error,
};
/**
* The Notice component is a visually non-obtrusive element that communicates the system status
* and provides options and actions related to the message tone.
*
* This component is designed to sit inline with the page area and capture the user’s attention
* to inform them about relevant information.
*
* ```jsx
* import { Notice } from '@automattic/components';
* import { ExternalLink } from '@wordpress/components';
*
* function MyComponent() {
* return (
* Label }
* >
* <>Hello, I’m a notice with an inline link>
*
* );
* }
* ```
*/
function UnforwardedNotice(
{ variant = 'info', title, children, actions, density = 'low', onClose }: NoticeProps,
ref: React.ForwardedRef< HTMLDivElement >
) {
const hasLowDensity = density === 'low';
return (
{ title && { title } }
{ children }
{ actions && (
{ actions }
) }
{ !! onClose && (
) }
);
}
export const Notice = forwardRef( UnforwardedNotice );
export default Notice;