import React, { HTMLProps } from 'react'; import { useTheme } from '../theme.ts'; export interface ExpandableProps extends Omit, 'onClick' | 'type'> { children: React.ReactNode; isExpandable: boolean; expanded: boolean; setExpanded: React.Dispatch>; } export const Expandable = React.forwardRef( ( { expanded, isExpandable, children, setExpanded, className = '', ...props }, ref, ) => { const [hoverDiv, setHoverDiv] = React.useState(false); const [hoverButton, setHoverButton] = React.useState(false); const hover = hoverDiv || hoverButton; const { background } = useTheme(); return (
setHoverDiv(true)} onMouseLeave={() => setHoverDiv(false)} ref={ref} {...props} >
setHoverButton(true)} onMouseLeave={() => setHoverButton(false)} hidden={!isExpandable} onClick={() => setExpanded(p => !p)} >
{expanded ? ( ) : ( )}
{children}
); }, );