| 1 |
import { Fragment, useState } from 'react'; |
| 2 |
import { Button, Modal, ModalBody, ModalFooter, ModalHeader, Popover } from '@patternfly/react-core'; |
| 3 |
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; |
| 4 |
|
| 5 |
export const ModalWithHelp: React.FunctionComponent = () => { |
| 6 |
const [isModalOpen, setIsModalOpen] = useState(false); |
| 7 |
|
| 8 |
const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { |
| 9 |
setIsModalOpen(!isModalOpen); |
| 10 |
}; |
| 11 |
|
| 12 |
return ( |
| 13 |
<Fragment> |
| 14 |
<Button variant="primary" onClick={handleModalToggle}> |
| 15 |
Show with help modal |
| 16 |
</Button> |
| 17 |
<Modal |
| 18 |
variant="small" |
| 19 |
isOpen={isModalOpen} |
| 20 |
onClose={handleModalToggle} |
| 21 |
aria-labelledby="with-help-modal-title" |
| 22 |
aria-describedby="modal-box-body-with-help" |
| 23 |
> |
| 24 |
<ModalHeader |
| 25 |
title="With help modal" |
| 26 |
labelId="with-help-modal-title" |
| 27 |
help={ |
| 28 |
<Popover |
| 29 |
headerContent={<div>Help Popover</div>} |
| 30 |
bodyContent={ |
| 31 |
<div> |
| 32 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla |
| 33 |
turpis. |
| 34 |
</div> |
| 35 |
} |
| 36 |
footerContent="Popover Footer" |
| 37 |
> |
| 38 |
<Button variant="plain" aria-label="Help" icon={<HelpIcon />} /> |
| 39 |
</Popover> |
| 40 |
} |
| 41 |
/> |
| 42 |
<ModalBody id="modal-box-body-with-help"> |
| 43 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore |
| 44 |
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
| 45 |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla |
| 46 |
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id |
| 47 |
est laborum. |
| 48 |
</ModalBody> |
| 49 |
<ModalFooter> |
| 50 |
<Button key="confirm" variant="primary" onClick={handleModalToggle}> |
| 51 |
Confirm |
| 52 |
</Button> |
| 53 |
<Button key="cancel" variant="link" onClick={handleModalToggle}> |
| 54 |
Cancel |
| 55 |
</Button> |
| 56 |
</ModalFooter> |
| 57 |
</Modal> |
| 58 |
</Fragment> |
| 59 |
); |
| 60 |
}; |