From 891ee1a3ba9c29e3cdc9144a0b559cb455e67f7f Mon Sep 17 00:00:00 2001
From: Victor Lin <13424970+victorlin@users.noreply.github.com>
Date: Wed, 18 Oct 2023 15:59:30 -0700
Subject: [PATCH] [wip] Add ability to show/hide options when panel is on
---
src/components/controls/panelSection.tsx | 26 +++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/components/controls/panelSection.tsx b/src/components/controls/panelSection.tsx
index 595569e59..74cffbdca 100644
--- a/src/components/controls/panelSection.tsx
+++ b/src/components/controls/panelSection.tsx
@@ -1,10 +1,25 @@
import React from "react";
import { useSelector } from "react-redux";
+import { FaChevronRight, FaChevronDown } from "react-icons/fa";
import { AnnotatedHeader } from "./annotatedHeader";
import { PanelSectionContainer } from "./styles";
import PanelToggle from "./panel-toggle";
import { RootState } from "../../store";
+
+type ChevronProps = {
+ show: boolean
+ onClick: any
+}
+
+const Chevron = ({ show, onClick }: ChevronProps) => {
+ const icon = show ? :
+
+ return
+ {icon}
+
+}
+
type Props = {
panel: string
title: string
@@ -19,15 +34,24 @@ export const PanelSection = ({ panel, title, tooltip, options, mobile }: Props)
const panelOn = panelsToDisplay.includes(panel)
+ // Initially, the toggle state determines whether options are shown.
+ const [showOptions, setShowOptions] = React.useState(panelOn);
+
+ // Subsequent toggle updates also determine whether options are shown.
+ React.useEffect(() => {
+ setShowOptions(panelOn)
+ }, [panelOn])
+
return (
+ setShowOptions(!showOptions)} />
}
title={title}
tooltip={tooltip}
mobile={mobile}
/>
- {panelOn && options}
+ {showOptions && options}
);
};