import { JSX, ParentComponent, Show, createMemo } from 'solid-js' import { twMerge } from 'tailwind-merge' import { renderInTwoColumn } from '~/signals/config' type Props = { title: JSX.Element content: JSX.Element isOpen: boolean | undefined onCollapse: (collapsed: boolean) => void } const Collapse: ParentComponent = (props) => { const { title, content, onCollapse } = props const getCollapseClassName = () => { const openedClassName = 'collapse-open' const closedClassName = 'collapse-close' return props.isOpen ? openedClassName : closedClassName } const getCollapseContentClassName = () => { const openedClassName = 'opacity-100' const closedClassName = 'opacity-0' return props.isOpen ? openedClassName : closedClassName } const mediaQueryClassName = createMemo(() => { if (renderInTwoColumn()) { return 'lg:grid-cols-3 xl:grid-cols-4' } else { return 'sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7' } }) return (
onCollapse(!props.isOpen)} > {title}
{content}
) } export default Collapse