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