collapse on border click
This commit is contained in:
parent
c401f39520
commit
a4684ddf39
|
@ -48,24 +48,41 @@ const VariableBox: React.FC<VariableBoxProps> = ({
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||||
|
|
||||||
|
const toggleCollapsed = () => {
|
||||||
|
setIsCollapsed(!isCollapsed);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{name ? (
|
<div>
|
||||||
<header
|
{name ? (
|
||||||
className="inline-flex space-x-1 text-slate-500 font-mono text-sm cursor-pointer"
|
<header
|
||||||
onClick={() => setIsCollapsed(!isCollapsed)}
|
className="inline-flex space-x-1 text-slate-500 font-mono text-sm cursor-pointer"
|
||||||
>
|
onClick={toggleCollapsed}
|
||||||
{name ? (
|
>
|
||||||
<Tooltip text={heading}>
|
{name ? (
|
||||||
<span>{name}:</span>
|
<Tooltip text={heading}>
|
||||||
</Tooltip>
|
<span>{name}:</span>
|
||||||
) : null}
|
</Tooltip>
|
||||||
{isCollapsed ? (
|
) : null}
|
||||||
<span className="bg-slate-200 rounded p-0.5 font-xs">...</span>
|
{isCollapsed ? (
|
||||||
) : null}
|
<span className="bg-slate-200 rounded p-0.5 font-xs">...</span>
|
||||||
</header>
|
) : null}
|
||||||
) : null}
|
</header>
|
||||||
{isCollapsed ? null : <div>{children}</div>}
|
) : null}
|
||||||
|
{isCollapsed ? null : (
|
||||||
|
<div className="flex w-full">
|
||||||
|
{name ? (
|
||||||
|
<div
|
||||||
|
className="border-l-2 border-slate-200 hover:border-green-600 w-4 cursor-pointer"
|
||||||
|
onClick={toggleCollapsed}
|
||||||
|
></div>
|
||||||
|
) : null}
|
||||||
|
<div className="grow">{children}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -76,7 +93,7 @@ const VariableList: React.FC<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}> = ({ name, heading, children }) => (
|
}> = ({ name, heading, children }) => (
|
||||||
<VariableBox name={name} heading={heading}>
|
<VariableBox name={name} heading={heading}>
|
||||||
<div className={clsx("space-y-3", name ? "border-l pl-4 pt-1 mt-1" : null)}>
|
<div className={clsx("space-y-3", name ? "pt-1 mt-1" : null)}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</VariableBox>
|
</VariableBox>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user