| 1 |
import { Fragment, useState } from 'react'; |
| 2 |
import { |
| 3 |
Button, |
| 4 |
Modal, |
| 5 |
ModalBody, |
| 6 |
ModalFooter, |
| 7 |
ModalHeader, |
| 8 |
ModalVariant, |
| 9 |
Title, |
| 10 |
TitleSizes, |
| 11 |
Content, |
| 12 |
Flex |
| 13 |
} from '@patternfly/react-core'; |
| 14 |
|
| 15 |
import WarningTriangleIcon from '@patternfly/react-icons/dist/esm/icons/warning-triangle-icon'; |
| 16 |
|
| 17 |
export const ModalCustomHeaderFooter: React.FunctionComponent = () => { |
| 18 |
const [isModalOpen, setIsModalOpen] = useState(false); |
| 19 |
|
| 20 |
const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => { |
| 21 |
setIsModalOpen(!isModalOpen); |
| 22 |
}; |
| 23 |
|
| 24 |
return ( |
| 25 |
<Fragment> |
| 26 |
<Button variant="primary" onClick={handleModalToggle}> |
| 27 |
Show custom header/footer modal |
| 28 |
</Button> |
| 29 |
<Modal |
| 30 |
variant={ModalVariant.large} |
| 31 |
isOpen={isModalOpen} |
| 32 |
onClose={handleModalToggle} |
| 33 |
aria-labelledby="modal-custom-header-label" |
| 34 |
aria-describedby="modal-custom-header-description" |
| 35 |
> |
| 36 |
<ModalHeader> |
| 37 |
<Content> |
| 38 |
<h1 id="modal-custom-header-label">Custom header modal</h1> |
| 39 |
<p>Add custom content to the header by not passing the titles prop the modal box header component.</p> |
| 40 |
</Content> |
| 41 |
</ModalHeader> |
| 42 |
<ModalBody> |
| 43 |
<span id="modal-custom-header-description"> |
| 44 |
When static text describing the modal is available outside of the modal header, it can be given an ID that |
| 45 |
is then passed in as the modal's aria-describedby value. |
| 46 |
</span> |
| 47 |
<br /> |
| 48 |
<br /> |
| 49 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore |
| 50 |
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
| 51 |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla |
| 52 |
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id |
| 53 |
est laborum. |
| 54 |
</ModalBody> |
| 55 |
<ModalFooter> |
| 56 |
<Title headingLevel="h4" size={TitleSizes.md}> |
| 57 |
<Flex spaceItems={{ default: 'spaceItemsSm' }}> |
| 58 |
<WarningTriangleIcon /> |
| 59 |
<span>Custom modal footer.</span> |
| 60 |
</Flex> |
| 61 |
</Title> |
| 62 |
</ModalFooter> |
| 63 |
</Modal> |
| 64 |
</Fragment> |
| 65 |
); |
| 66 |
}; |