This commit is contained in:
QkoSad
2023-08-08 16:02:54 +03:00
commit 0a7a469d56
315 changed files with 426907 additions and 0 deletions
@@ -0,0 +1,23 @@
import { useState } from "react";
const Togglable = ({ children, buttonLabel1, buttonLabel2 = "cancel" }) => {
const [visible, setVisible] = useState(false);
const hideWhenVisible = { display: visible ? "none" : "" };
const showWhenVisible = { display: visible ? "" : "none" };
const toggleVisibility = () => {
setVisible(!visible);
};
return (
<div>
<div style={hideWhenVisible}>
<button onClick={toggleVisibility}>{buttonLabel1}</button>
</div>
<div style={showWhenVisible}>
{children}
<button onClick={toggleVisibility}>{buttonLabel2}</button>
</div>
</div>
);
};
export default Togglable;