1 | import * as React from 'react';
|
2 | import * as PropTypes from 'prop-types';
|
3 |
|
4 | import { ButtonProps } from '../Button/Button';
|
5 | import Icon from '../Icon';
|
6 | import VisuallyHidden from '../VisuallyHidden';
|
7 | import { Omit } from '../types';
|
8 | import { ToastClose as _ToastClose } from './styled';
|
9 |
|
10 | export type LocalToastCloseProps = {
|
11 | isAbsolute?: boolean;
|
12 | onClickClose?: ButtonProps['onClick'];
|
13 | };
|
14 | export type ToastCloseProps = Omit<ButtonProps, 'children'> & LocalToastCloseProps;
|
15 |
|
16 | export const ToastClose: React.FunctionComponent<LocalToastCloseProps> = ({ onClickClose, ...props }) => (
|
17 | <_ToastClose kind="link" onClick={onClickClose} {...props}>
|
18 | <VisuallyHidden>Close</VisuallyHidden>
|
19 | <Icon a11yHidden icon="times" />
|
20 | </_ToastClose>
|
21 | );
|
22 |
|
23 | export const toastClosePropTypes = {
|
24 | isAbsolute: PropTypes.bool,
|
25 | onClickClose: PropTypes.func
|
26 | };
|
27 | ToastClose.propTypes = toastClosePropTypes;
|
28 |
|
29 | export const toastCloseDefaultProps = {
|
30 | isAbsolute: false,
|
31 | onClickClose: undefined
|
32 | };
|
33 | ToastClose.defaultProps = toastCloseDefaultProps;
|
34 |
|
35 | const C: React.FunctionComponent<ToastCloseProps> = ToastClose;
|
36 | export default C;
|