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 9, 2023
1 parent 6753065 commit f3719d5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 71 deletions.
33 changes: 0 additions & 33 deletions src/components/controls/panelChevron.tsx

This file was deleted.

30 changes: 5 additions & 25 deletions src/components/controls/panelHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { togglePanelDisplay } from "../../actions/panelDisplay";
import { HeaderContainer } from "./styles";
import { PanelToggle, On } from "./panelToggle";
import { AnnotatedTitle, Mobile, Title, Tooltip } from "./annotatedTitle";
import { PanelChevron } from "./panelChevron";

/** Panel identifier used internally. */
export type PanelId = string;
Expand All @@ -15,44 +14,25 @@ type Props = {
tooltip?: Tooltip
panelIsVisible: On
mobile: Mobile

/** 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, mobile }: Props) => {
export const PanelHeader = ({ panel, title, tooltip, panelIsVisible, mobile }: Props) => {
const dispatch = useAppDispatch();

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}
mobile={mobile} />
</span>
<AnnotatedTitle
title={title}
tooltip={tooltip}
mobile={mobile} />
<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 @@ -24,14 +24,6 @@ export const PanelSection = ({ panel, title, tooltip, options=undefined, mobile

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
Expand All @@ -40,11 +32,8 @@ export const PanelSection = ({ panel, title, tooltip, options=undefined, mobile
tooltip={tooltip}
panelIsVisible={panelIsVisible}
mobile={mobile}
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 f3719d5

Please sign in to comment.