| @@ -10,10 +10,17 @@ | ||
| 10 | 10 | children?: ReactNode |
| 11 | 11 | type?: NoticeType |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | +const isAssertive = (type?: NoticeType): boolean => 'error' === type || 'warning' === type | |
| 15 | + | |
| 14 | 16 | export const Notice: React.FC<NoticeProps> = ({ className, type, children, ...props }) => |
| 15 | - <div className={classnames('notice', { [`notice-${type}`]: type }, className)} {...props}> | |
| 17 | + <div | |
| 18 | + className={classnames('notice', 'code-snippets-notice', { [`notice-${type}`]: type }, className)} | |
| 19 | + role={isAssertive(type) ? 'alert' : 'status'} | |
| 20 | + aria-live={isAssertive(type) ? 'assertive' : 'polite'} | |
| 21 | + {...props} | |
| 22 | + > | |
| 16 | 23 | {children} |
| 17 | 24 | </div> |
| 18 | 25 | |
| 19 | 26 | export interface DismissibleNoticeProps extends NoticeProps { |