| 1 |
import { __ } from '@wordpress/i18n' |
| 2 |
import classnames from 'classnames' |
| 3 |
import React from 'react' |
| 4 |
import type { ReactNode } from 'react' |
| 5 |
|
| 6 |
export interface DismissibleNoticeProps { |
| 7 |
className?: classnames.Argument |
| 8 |
onDismiss: VoidFunction |
| 9 |
children?: ReactNode |
| 10 |
} |
| 11 |
|
| 12 |
export const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ className, onDismiss, children }) => |
| 13 |
<div id="message" className={classnames('notice fade is-dismissible', className)}> |
| 14 |
<>{children}</> |
| 15 |
|
| 16 |
<button type="button" className="notice-dismiss" onClick={event => { |
| 17 |
event.preventDefault() |
| 18 |
onDismiss() |
| 19 |
}}> |
| 20 |
<span className="screen-reader-text">{__('Dismiss notice.', 'code-snippets')}</span> |
| 21 |
</button> |
| 22 |
</div> |
| 23 |
|