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 18, 2023
1 parent 640fa4f commit 302ce86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 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
8 changes: 1 addition & 7 deletions src/components/main/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 302ce86

Please sign in to comment.