collapse on border click
This commit is contained in:
parent
c401f39520
commit
a4684ddf39
|
@ -48,12 +48,18 @@ 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>
|
<div>
|
||||||
{name ? (
|
{name ? (
|
||||||
<header
|
<header
|
||||||
className="inline-flex space-x-1 text-slate-500 font-mono text-sm cursor-pointer"
|
className="inline-flex space-x-1 text-slate-500 font-mono text-sm cursor-pointer"
|
||||||
onClick={() => setIsCollapsed(!isCollapsed)}
|
onClick={toggleCollapsed}
|
||||||
>
|
>
|
||||||
{name ? (
|
{name ? (
|
||||||
<Tooltip text={heading}>
|
<Tooltip text={heading}>
|
||||||
|
@ -65,7 +71,18 @@ const VariableBox: React.FC<VariableBoxProps> = ({
|
||||||
) : null}
|
) : null}
|
||||||
</header>
|
</header>
|
||||||
) : null}
|
) : null}
|
||||||
{isCollapsed ? null : <div>{children}</div>}
|
{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