import { useState } from 'react' import { CloseIcon, DownIcon } from 'shared/components/icons.mjs' const OpenTitleButton = ({ title, toggle, color = 'primary' }) => ( ) export const Collapse = ({ title, openTitle = false, children = [], buttons = [], top = true, bottom = false, color = 'primary', opened = false, toggle = false, toggleClasses = '', toggleIcon = '', }) => { const [open, setOpen] = useState(opened) const titleBtn = open ? ( setOpen(false)} color={color} /> ) : null return open ? (
{top ? titleBtn : null}
{children}
{bottom ? titleBtn : null}
) : (
setOpen(true)} > {title}
{toggle ? ( ) : ( buttons )}
) } export const useCollapseButton = (props) => { // Shared state const [open, setOpen] = useState(false) // Method to allow closing the button const close = () => setOpen(false) // The component const CollapseButton = ({ title, openTitle = false, children = [], className = 'btn btn-lg btn-primary', top = true, bottom = false, color = 'primary', }) => { const titleBtn = open ? ( setOpen(false)} color={color} /> ) : null return open ? (
{top ? titleBtn : null}
{children}
{bottom ? titleBtn : null}
) : ( ) } return { CollapseButton, closeCollapseButton: close } }