Skip to content

Commit

Permalink
Determine panel on states in controls component
Browse files Browse the repository at this point in the history
Instead of determining in the sidebar and passing down as props.
  • Loading branch information
victorlin committed Oct 19, 2023
1 parent 640fa4f commit 1880083
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
15 changes: 10 additions & 5 deletions src/components/controls/controls.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { useSelector } from "react-redux";
import { useTranslation } from 'react-i18next';

import ColorBy, {ColorByInfo} from "./color-by";
Expand All @@ -25,18 +26,22 @@ import {TreeOptionsInfo, MapOptionsInfo, AnimationOptionsInfo, PanelOptionsInfo,
ExplodeTreeInfo, FrequencyInfo, MeasurementsOptionsInfo} from "./miscInfoText";
import { AnnotatedHeader } from "./annotatedHeader";
import MeasurementsOptions from "./measurementsOptions";
import { RootState } from "../../store";

type Props = {
treeOn: boolean
mapOn: boolean
frequenciesOn: boolean
measurementsOn: boolean
mobileDisplay: boolean
}

function Controls({ treeOn, mapOn, frequenciesOn, measurementsOn, mobileDisplay }: Props) {
function Controls({ mobileDisplay }: Props) {
const { t } = useTranslation();

const panelsToDisplay = useSelector((state: RootState) => state.controls.panelsToDisplay);

const treeOn = panelsToDisplay.includes("tree");
const mapOn = panelsToDisplay.includes("map");
const frequenciesOn = panelsToDisplay.includes("frequencies");
const measurementsOn = panelsToDisplay.includes("measurements");

return (
<ControlsContainer>
<ChooseDataset />
Expand Down
1 change: 0 additions & 1 deletion src/components/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class Main extends React.Component {
width={sidebarWidth}
height={availableHeight}
displayNarrative={this.props.displayNarrative}
panelsToDisplay={this.props.panelsToDisplay}
narrativeTitle={this.props.narrativeTitle}
mobileDisplay={this.state.mobileDisplay}
navBarHandler={this.toggleSidebar}
Expand Down
10 changes: 2 additions & 8 deletions src/components/main/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { narrativeNavBarHeight } from "../../util/globals";


export const Sidebar = (
{sidebarOpen, width, height, displayNarrative, panelsToDisplay, narrativeTitle, mobileDisplay, navBarHandler}
{sidebarOpen, width, height, displayNarrative, narrativeTitle, mobileDisplay, navBarHandler}
) => {
return (
<ThemeProvider theme={sidebarTheme}>
Expand All @@ -23,13 +23,7 @@ export const Sidebar = (
{displayNarrative ? (
<Narrative height={height - narrativeNavBarHeight} width={width} />
) : (
<Controls
mobileDisplay={mobileDisplay}
treeOn={panelsToDisplay.includes("tree")}
mapOn={panelsToDisplay.includes("map")}
frequenciesOn={panelsToDisplay.includes("frequencies")}
measurementsOn={panelsToDisplay.includes("measurements")}
/>
<Controls mobileDisplay={mobileDisplay} />
)}
</SidebarContainer>
</ThemeProvider>
Expand Down

0 comments on commit 1880083

Please sign in to comment.