1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-26 00:21:36 +01:00

Add optional close button to ModalHeader component

This commit is contained in:
Aleksandr Gumroian 2024-12-04 14:02:35 +01:00
parent 5a53eca138
commit 66f83b24bd
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -88,18 +88,21 @@ export function Modal({ shown, setShown, scrollable, size, children }) {
ModalHeader.propTypes = { ModalHeader.propTypes = {
setShown: PropTypes.func.isRequired, setShown: PropTypes.func.isRequired,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
showCloseButton: PropTypes.bool,
}; };
export function ModalHeader({ setShown, title }) { export function ModalHeader({ setShown, title, showCloseButton = true }) {
return ( return (
<div className="modal-header"> <div className="modal-header">
<h1 className="modal-title fs-5">{title}</h1> <h1 className="modal-title fs-5">{title}</h1>
<button {showCloseButton && (
type="button" <button
className="btn-close" type="button"
onClick={() => setShown(false)} className="btn-close"
aria-label={_("Close")} onClick={() => setShown(false)}
/> aria-label={_("Close")}
/>
)}
</div> </div>
); );
} }