Skip to content

Commit

Permalink
Fix an issue that was causing the current selected themes to become d…
Browse files Browse the repository at this point in the history
…esynced after the navigator was used. (#149)

Co-authored-by: Benjamin Clark <clarkben@meta.com>
  • Loading branch information
Bonkles and Benjamin Clark authored Aug 20, 2024
1 parent e373d3f commit 829d28c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions site/src/ThemeSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,39 @@ import ExpandLessIcon from "@mui/icons-material/ExpandLess";

import { ThemeProvider, createTheme } from "@mui/material/styles";

// Should convert this logic to be dynamic once manifests are a thing!
function themeFromType (type) {
switch (type) {
case "boundary":
case "division":
case "division_area":
case "division_boundary":
return 'divisions';

case "land":
case "land_cover":
case "land_use":
case "water":
case "infrastructure":
return "base";

case "segment":
case "connector":
return "transportation";

case "building":
case "building_part":
return "buildings"

case "place":
return "places";

case "address":
return "addresses"
}
return '';
}

const muiTheme = createTheme({
typography: {
allVariants: {
Expand Down Expand Up @@ -74,10 +107,15 @@ const ThemeSelector = ({

useEffect(() => {
const newSelectedTypes = {};
const newSelectedThemes = {};

visibleTypes.forEach((type) => {
newSelectedTypes[type] = true;
newSelectedThemes[themeFromType(type)] = true;
});

setSelectedTypesState(newSelectedTypes);
setSelectedThemes(newSelectedThemes);
}, [visibleTypes]);

const handleThemeChange = (theme) => {
Expand Down

0 comments on commit 829d28c

Please sign in to comment.