From 651c3c4a64f7a543e2d947b0ab8bc4e695575532 Mon Sep 17 00:00:00 2001 From: Christopher Ram Date: Wed, 25 Oct 2023 02:42:39 -0400 Subject: [PATCH] fixing legend overview --- .../components/footer-bar/footer-bar-style.ts | 2 +- .../legend-2/legend-overview/legend-layer.tsx | 191 ++++++++++-------- .../legend-overview/legend-overview-styles.ts | 54 ++--- .../legend-overview/legend-overview.tsx | 7 +- 4 files changed, 134 insertions(+), 120 deletions(-) diff --git a/packages/geoview-core/src/core/components/footer-bar/footer-bar-style.ts b/packages/geoview-core/src/core/components/footer-bar/footer-bar-style.ts index a487c27fe9b..74c7c8d7761 100644 --- a/packages/geoview-core/src/core/components/footer-bar/footer-bar-style.ts +++ b/packages/geoview-core/src/core/components/footer-bar/footer-bar-style.ts @@ -58,4 +58,4 @@ export const sxClassesRotationButton = { height: '1.5em', color: 'primary.light', }, -}; \ No newline at end of file +}; diff --git a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-layer.tsx b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-layer.tsx index 0fc7a0a6808..2a5712afb33 100644 --- a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-layer.tsx +++ b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-layer.tsx @@ -1,89 +1,102 @@ - -import { useTranslation } from 'react-i18next'; -import { TypeDisplayLanguage, sxClasses } from '@/app'; -import { Box, ListItem, Tooltip, ListItemText, ListItemIcon, IconButton, KeyboardArrowDownIcon, Collapse, List, KeyboardArrowUpIcon } from '@/ui'; -import { TypeLegendLayer } from '../types'; -import { useState } from 'react'; -import { getSxClasses } from './legend-overview-styles'; -import { useTheme } from '@mui/material'; - -interface LegendLayerProps { - layer: TypeLegendLayer -} - -export function LegendLayer(props: LegendLayerProps): JSX.Element { - const { layer } = props; - const { t, i18n } = useTranslation(); - const layerName = layer.layerName[i18n.language as TypeDisplayLanguage]; - const theme = useTheme(); - const sxClasses = getSxClasses(theme); - const [isGroupOpen, setGroupOpen] = useState(true); - - - /** - * Handle expand/shrink of layer groups. - */ - const handleExpandGroupClick = () => { - setGroupOpen(!isGroupOpen); - }; - - - //renders the layers children, if any - function renderChildren() { - if(!layer.children?.length) { return null; } - - return ( - - {layer.children.map((item) => )} - - ); - } - - //renders the layers items if any - function renderItems() { - if(!layer.children?.length) { return null; } - return ( - - {layer.children.map((item) => )} - - ); - } - - function renderArrowButtons() { - if(layer.children?.length || layer.items?.length) { - return ( - - - {isGroupOpen ? : } - - - ) - } else { - return null; - } - } - - function renderCollapsible() { - if(!(layer.children?.length || layer.items?.length)) { - return null; - } - - return ( - - {renderChildren()} - - ) - } - - return ( - - - - - - {renderArrowButtons()} - - {renderCollapsible()} - - ); -} \ No newline at end of file +import { useTranslation } from 'react-i18next'; +import { useState } from 'react'; +import { useTheme } from '@mui/material'; +import { TypeDisplayLanguage } from '@/app'; +import { + Box, + ListItem, + Tooltip, + ListItemText, + ListItemIcon, + IconButton, + KeyboardArrowDownIcon, + Collapse, + List, + KeyboardArrowUpIcon, +} from '@/ui'; +import { TypeLegendLayer } from '../types'; +import { getSxClasses } from './legend-overview-styles'; + +interface LegendLayerProps { + layer: TypeLegendLayer; +} + +export function LegendLayer(props: LegendLayerProps): JSX.Element { + const { layer } = props; + const { i18n } = useTranslation(); + const layerName = layer.layerName[i18n.language as TypeDisplayLanguage]; + const theme = useTheme(); + const sxClasses = getSxClasses(theme); + const [isGroupOpen, setGroupOpen] = useState(true); + + /** + * Handle expand/shrink of layer groups. + */ + const handleExpandGroupClick = () => { + setGroupOpen(!isGroupOpen); + }; + + // renders the layers children, if any + function renderChildren() { + if (!layer.children?.length) { + return null; + } + + return ( + + {layer.children.map((item) => ( + + ))} + + ); + } + + // renders the layers items if any + /* function renderItems() { + if (!layer.children?.length) { + return null; + } + return ( + + {layer.children.map((item) => ( + + ))} + + ); + } */ + + function renderArrowButtons() { + if (layer.children?.length || layer.items?.length) { + return ( + + {isGroupOpen ? : } + + ); + } + return null; + } + + function renderCollapsible() { + if (!(layer.children?.length || layer.items?.length)) { + return null; + } + + return ( + + {renderChildren()} + + ); + } + + return ( + + + + + + {renderArrowButtons()} + + {renderCollapsible()} + + ); +} diff --git a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview-styles.ts b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview-styles.ts index dc8b52b99f9..1cfefcc97b8 100644 --- a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview-styles.ts +++ b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview-styles.ts @@ -1,27 +1,27 @@ -import { Theme } from '@mui/material/styles'; - -export const getSxClasses = (theme: Theme) => ({ - container: { - padding: '10px 0px 20px 0px', - }, - title: { - textAlign: 'left', - font: theme.footerPanel.titleFont, - fontSize: '20px', - }, - subtitle: { - font: theme.footerPanel.titleFont, - fontWeight: 'normal', - fontSize: '0.9em', - textAlign: 'left', - marginBottom: '15px' - }, - legendLayerListItem: { - padding: "6px 4px" - }, - collapsibleContainer: { - width: '100%', - padding: '10px 0', - margin: '0px 10px' - } -}); +import { Theme } from '@mui/material/styles'; + +export const getSxClasses = (theme: Theme) => ({ + container: { + padding: '10px 0px 20px 0px', + }, + title: { + textAlign: 'left', + font: theme.footerPanel.titleFont, + fontSize: '20px', + }, + subtitle: { + font: theme.footerPanel.titleFont, + fontWeight: 'normal', + fontSize: '0.9em', + textAlign: 'left', + marginBottom: '15px', + }, + legendLayerListItem: { + padding: '6px 4px', + }, + collapsibleContainer: { + width: '100%', + padding: '10px 0', + margin: '0px 10px', + }, +}); diff --git a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview.tsx b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview.tsx index bea7c2e1811..ff0d8a92f77 100644 --- a/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview.tsx +++ b/packages/geoview-core/src/core/components/legend-2/legend-overview/legend-overview.tsx @@ -14,18 +14,19 @@ export function LegendOverview(props: LegendOverviewProps): JSX.Element { const { mapId } = props; const theme = useTheme(); const sxClasses = getSxClasses(theme); - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); const store = getGeoViewStore(mapId); const legendLayers = useStore(store, (state) => state.legendState.legendLayers); const numItems = 33; /* START fake store data here */ - function renderLegendLayersList() { return ( - {legendLayers.map((item) => )} + {legendLayers.map((item) => ( + + ))} ); }