diff --git a/src/assets/icons/dropdown.svg b/src/assets/icons/dropdown.svg new file mode 100644 index 00000000..19978c25 --- /dev/null +++ b/src/assets/icons/dropdown.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/components/atoms/BlockGroupField.tsx b/src/components/atoms/BlockGroupField.tsx index a1359c2b..7cf2d027 100644 --- a/src/components/atoms/BlockGroupField.tsx +++ b/src/components/atoms/BlockGroupField.tsx @@ -1,13 +1,60 @@ +import { useCallback, useRef } from "react"; +import { useLocalStorageAdopter } from "../../hooks/localStorage"; +import iconDropdown from "../../assets/icons/dropdown.svg"; + interface Props { label: string; children?: React.ReactNode; + accordionKey?: string; } -export const BlockGroupField: React.FC = ({ label, children }) => { +export const BlockGroupField: React.FC = ({ label, children, accordionKey }) => { + const { state: accordionState, setState: setAccordingState } = useLocalStorageAdopter({ + key: accordionKey, + initialValue: false, + version: "1", + }); + + const contentRef = useRef(null); + + const handleAccordionClick = useCallback(() => { + setAccordingState((v) => { + const next = !v; + if (next) { + setTimeout(() => { + contentRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" }); + }, 0); + } + return next; + }); + }, [setAccordingState]); + + const content = ( +
+ {children} +
+ ); + + if (!accordionKey) { + return ( +
+ {label}: + {content} +
+ ); + } + return ( -
- {label}: -
{children}
+
+ + {accordionState ? content : undefined}
); }; diff --git a/src/components/shapeInspectorPanel/ClipInspector.tsx b/src/components/shapeInspectorPanel/ClipInspector.tsx index 4f4c49f0..9cf6e3b6 100644 --- a/src/components/shapeInspectorPanel/ClipInspector.tsx +++ b/src/components/shapeInspectorPanel/ClipInspector.tsx @@ -41,7 +41,7 @@ export const ClipInspector: React.FC = ({ targetShape, updateTargetShape, ); return ( - + diff --git a/src/components/shapeInspectorPanel/GroupConstraintInspector.tsx b/src/components/shapeInspectorPanel/GroupConstraintInspector.tsx index 9cc373c1..f7c46b25 100644 --- a/src/components/shapeInspectorPanel/GroupConstraintInspector.tsx +++ b/src/components/shapeInspectorPanel/GroupConstraintInspector.tsx @@ -35,7 +35,7 @@ export const GroupConstraintInspector: React.FC = ({ targetShape, updateT ); return ( - +
{gcIcons.map((icon, i) => (