| Server IP : 52.25.153.185 / Your IP : 216.73.216.194 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/code-snippets/js/components/common/ |
Upload File : |
import { __ } from '@wordpress/i18n'
import classnames from 'classnames'
import React from 'react'
import type { HTMLAttributes, ReactNode } from 'react'
export type NoticeType = 'info' | 'warning' | 'error' | 'success'
export interface NoticeProps extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
className?: classnames.Argument
children?: ReactNode
type?: NoticeType
}
const isAssertive = (type?: NoticeType): boolean => 'error' === type || 'warning' === type
export const Notice: React.FC<NoticeProps> = ({ className, type, children, ...props }) =>
<div
className={classnames('notice', 'code-snippets-notice', { [`notice-${type}`]: type }, className)}
role={isAssertive(type) ? 'alert' : 'status'}
aria-live={isAssertive(type) ? 'assertive' : 'polite'}
{...props}
>
{children}
</div>
export interface DismissibleNoticeProps extends NoticeProps {
onDismiss: VoidFunction
}
export const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ className, onDismiss, children, ...noticeProps }) =>
<Notice className={classnames('is-dismissible', className)} {...noticeProps}>
{children}
<button type="button" className="notice-dismiss" onClick={event => {
event.preventDefault()
onDismiss()
}}>
<span className="screen-reader-text">{__('Dismiss notice.', 'code-snippets')}</span>
</button>
</Notice>