import { useState, useRef, useEffect } from 'react' import { Box, Text } from 'theme-ui' // Not used atm, but keeping around in case we want to add back in const CollapsableBox = ({ title, children, backgroundColor, isOpen: isOpenProp }) => { const [isOpen, setIsOpen] = useState(isOpenProp || false) const [height, setHeight] = useState(0) const contentRef = useRef(null) useEffect(() => { if (contentRef.current) { setHeight(isOpen ? contentRef.current.scrollHeight : 0) } }, [isOpen]) const toggleOpen = () => { setIsOpen(prev => !prev) } return (
event.key === 'Enter' && toggleOpen()} style={{ cursor: 'pointer', fontWeight: 'bold' }} > {title}
{children}
) } export default CollapsableBox