Skip to content

Commit

Permalink
Revert "Add ability to show/hide panel options"
Browse files Browse the repository at this point in the history
For preview.
  • Loading branch information
victorlin committed Nov 10, 2023
1 parent b25e783 commit afd600f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 74 deletions.
33 changes: 0 additions & 33 deletions src/components/controls/panelChevron.tsx

This file was deleted.

32 changes: 4 additions & 28 deletions src/components/controls/panelHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React from "react";
import { useSelector } from "react-redux";
import { RootState } from "../../store";
import { useAppDispatch } from "../../hooks";
import { togglePanelDisplay } from "../../actions/panelDisplay";
import { HeaderContainer } from "./styles";
import { PanelToggle, On } from "./panelToggle";
import { AnnotatedTitle, Title, Tooltip } from "./annotatedTitle";
import { PanelChevron } from "./panelChevron";

/** Panel identifier used internally. */
export type PanelId = string;
Expand All @@ -16,45 +13,24 @@ type Props = {
title: Title
tooltip?: Tooltip
panelIsVisible: On

/** Indicates whether there are options for the panel. */
hasOptions: boolean

/** Indicates options visibility. */
optionsAreVisible: boolean

/** Update options visibility. */
setOptionsAreVisible: React.Dispatch<React.SetStateAction<boolean>>
}

/**
* A header used by all panel controls, containing an interactive title.
*/
export const PanelHeader = ({ panel, title, tooltip, panelIsVisible, hasOptions, optionsAreVisible, setOptionsAreVisible }: Props) => {
export const PanelHeader = ({ panel, title, tooltip, panelIsVisible }: Props) => {
const dispatch = useAppDispatch();

const mobile = useSelector((state: RootState) => state.general.mobileDisplay);

function togglePanelVisibility() {
dispatch(togglePanelDisplay(panel))
}

function toggleOptionsVisibility() {
setOptionsAreVisible(!optionsAreVisible);
}

return (
// Clicking anywhere in the element, even whitespace, will toggle panel visibility.
<HeaderContainer onClick={togglePanelVisibility}>
<span>
{hasOptions && !mobile &&
<PanelChevron
show={optionsAreVisible}
onClick={toggleOptionsVisibility} />}
<AnnotatedTitle
title={title}
tooltip={tooltip} />
</span>
<AnnotatedTitle
title={title}
tooltip={tooltip} />
<PanelToggle
on={panelIsVisible}
callback={(togglePanelVisibility)} />
Expand Down
13 changes: 1 addition & 12 deletions src/components/controls/panelSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,15 @@ export const PanelSection = ({ panel, title, tooltip, options=undefined }: Props

const panelIsVisible = panelsToDisplay.includes(panel)

// Initially, panel visibility determines options visibility.
const [optionsAreVisible, setOptionsAreVisible] = React.useState(panelIsVisible);

// Subsequent panel visibility updates also determines options visibility.
React.useEffect(() => {
setOptionsAreVisible(panelIsVisible)
}, [panelIsVisible])

return (
<PanelSectionContainer>
<PanelHeader
panel={panel}
title={title}
tooltip={tooltip}
panelIsVisible={panelIsVisible}
hasOptions={options!==undefined}
optionsAreVisible={optionsAreVisible}
setOptionsAreVisible={setOptionsAreVisible}
/>
{optionsAreVisible && options}
{panelIsVisible && options}
</PanelSectionContainer>
);
};
2 changes: 1 addition & 1 deletion src/components/controls/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const PanelSectionContainer = styled.div`
`;

export const TitleAndIconContainer = styled.span`
display: inline-flex;
display: flex;
align-items: center;
`;

Expand Down

0 comments on commit afd600f

Please sign in to comment.