From a4684ddf39c5acb8564459dbaeb07c2fefb1ddf1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 8 Jul 2022 17:09:46 +0400 Subject: [PATCH] collapse on border click --- .../src/components/SquiggleItem.tsx | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/packages/components/src/components/SquiggleItem.tsx b/packages/components/src/components/SquiggleItem.tsx index 647cc08c..e9b9c2f6 100644 --- a/packages/components/src/components/SquiggleItem.tsx +++ b/packages/components/src/components/SquiggleItem.tsx @@ -48,24 +48,41 @@ const VariableBox: React.FC = ({ children, }) => { const [isCollapsed, setIsCollapsed] = useState(false); + + const toggleCollapsed = () => { + setIsCollapsed(!isCollapsed); + }; + return (
- {name ? ( -
setIsCollapsed(!isCollapsed)} - > - {name ? ( - - {name}: - - ) : null} - {isCollapsed ? ( - ... - ) : null} -
- ) : null} - {isCollapsed ? null :
{children}
} +
+ {name ? ( +
+ {name ? ( + + {name}: + + ) : null} + {isCollapsed ? ( + ... + ) : null} +
+ ) : null} + {isCollapsed ? null : ( +
+ {name ? ( +
+ ) : null} +
{children}
+
+ )} +
); }; @@ -76,7 +93,7 @@ const VariableList: React.FC<{ children: React.ReactNode; }> = ({ name, heading, children }) => ( -
+
{children}