| 1 |
import { css } from '@patternfly/react-styles'; |
| 2 |
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box'; |
| 3 |
import { Button } from '../Button'; |
| 4 |
import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon'; |
| 5 |
import { OUIAProps } from '../../helpers'; |
| 6 |
|
| 7 |
export interface ModalBoxCloseButtonProps extends OUIAProps { |
| 8 |
/** Additional classes added to the close button. */ |
| 9 |
className?: string; |
| 10 |
/** A callback for when the close button is clicked. */ |
| 11 |
onClose?: (event: KeyboardEvent | React.MouseEvent) => void; |
| 12 |
/** Accessible descriptor of the close button. */ |
| 13 |
'aria-label'?: string; |
| 14 |
/** Value to set the data-ouia-component-id.*/ |
| 15 |
ouiaId?: number | string; |
| 16 |
} |
| 17 |
|
| 18 |
export const ModalBoxCloseButton: React.FunctionComponent<ModalBoxCloseButtonProps> = ({ |
| 19 |
className, |
| 20 |
onClose, |
| 21 |
'aria-label': ariaLabel = 'Close', |
| 22 |
ouiaId, |
| 23 |
...props |
| 24 |
}: ModalBoxCloseButtonProps) => ( |
| 25 |
<div className={css(styles.modalBoxClose, className)}> |
| 26 |
<Button |
| 27 |
variant="plain" |
| 28 |
onClick={(event) => onClose(event)} |
| 29 |
aria-label={ariaLabel} |
| 30 |
{...(ouiaId && { ouiaId: `${ouiaId}-${ModalBoxCloseButton.displayName}` })} |
| 31 |
{...props} |
| 32 |
icon={<RhMicronsCloseIcon />} |
| 33 |
/> |
| 34 |
</div> |
| 35 |
); |
| 36 |
ModalBoxCloseButton.displayName = 'ModalBoxCloseButton'; |