| 1 |
import styles from '@patternfly/react-styles/css/components/Drawer/drawer'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
import { Button } from '../Button'; |
| 4 |
import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon'; |
| 5 |
|
| 6 |
export interface DrawerCloseButtonProps extends React.HTMLProps<HTMLDivElement> { |
| 7 |
/** Additional classes added to the drawer close button outer <div>. */ |
| 8 |
className?: string; |
| 9 |
/** A callback for when the close button is clicked */ |
| 10 |
onClose?: () => void; |
| 11 |
/** Accessible label for the drawer close button */ |
| 12 |
'aria-label'?: string; |
| 13 |
} |
| 14 |
|
| 15 |
export const DrawerCloseButton: React.FunctionComponent<DrawerCloseButtonProps> = ({ |
| 16 |
className = '', |
| 17 |
onClose = () => undefined as any, |
| 18 |
'aria-label': ariaLabel = 'Close drawer panel', |
| 19 |
...props |
| 20 |
}: DrawerCloseButtonProps) => ( |
| 21 |
<div className={css(styles.drawerClose, className)} {...props}> |
| 22 |
<Button variant="plain" onClick={onClose} aria-label={ariaLabel} icon={<RhMicronsCloseIcon />} /> |
| 23 |
</div> |
| 24 |
); |
| 25 |
DrawerCloseButton.displayName = 'DrawerCloseButton'; |