-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASA Map Legend #3141
Closed
Closed
ASA Map Legend #3141
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b751be7
initial legend commit
brettedw 59715ff
adds state mgmt and subItems
brettedw 5d6ecd4
adds symbols to legend
brettedw 24fb783
adds legend title
brettedw 3bebf98
adjust alignment
brettedw 8c8485e
bold title
brettedw d947a9b
manage state better, FBAMap -> Legend
brettedw 633cfae
css cleanup
brettedw 8a8288e
disable flaky morecast 1 test
brettedw 5ad0511
bring back hfi dependency
brettedw 0ab7741
dedupe some code
brettedw d0bacc8
Remove unused hfi layer defs, replaced by pmtiles
brettedw c76bde9
fixes fire zone not selectable if not color filled
brettedw 6549c64
adds functioning summary panel close button
brettedw 807f1de
add props to fbaMap.test
brettedw bed6255
adds map panning changes on click
brettedw a9da430
Makes scroll bar permanent
brettedw d64c50e
legend font/margin changes
brettedw 70e51b1
legend item padding changes
brettedw d73b13b
change legend title
brettedw 19d54d4
adds legend tests
brettedw f3ba526
better testid names
brettedw 6e60332
Merge branch 'main' into task/asa-map-legend
brettedw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import React from 'react' | ||
import { styled } from '@mui/material/styles' | ||
import CombustibleAreaViz from 'features/fba/components/viz/CombustibleAreaViz' | ||
import { Grid, Typography } from '@mui/material' | ||
import { Grid, IconButton, Typography } from '@mui/material' | ||
import { isUndefined } from 'lodash' | ||
import { ElevationInfoByThreshold, FireZone, FireZoneArea, FireZoneThresholdFuelTypeArea } from 'api/fbaAPI' | ||
import ElevationInfoViz from 'features/fba/components/viz/ElevationInfoViz' | ||
import FuelTypesBreakdown from 'features/fba/components/viz/FuelTypesBreakdown' | ||
import CloseIcon from '@mui/icons-material/Close' | ||
|
||
const SidePanelGrid = styled(Grid)({ | ||
minWidth: 400, | ||
overflowY: 'auto', | ||
overflowY: 'scroll', | ||
maxHeight: '100%', | ||
padding: 0 | ||
}) | ||
|
@@ -32,16 +33,29 @@ interface Props { | |
fuelTypeInfo: Record<number, FireZoneThresholdFuelTypeArea[]> | ||
hfiElevationInfo: ElevationInfoByThreshold[] | ||
fireZoneAreas: FireZoneArea[] | ||
showSummaryPanel: boolean | ||
setShowSummaryPanel: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
const ZoneSummaryPanel = React.forwardRef((props: Props, ref: React.ForwardedRef<HTMLDivElement>) => { | ||
ZoneSummaryPanel.displayName = 'ZoneSummaryPanel' | ||
|
||
if (isUndefined(props.selectedFireZone)) { | ||
const handleClose = () => { | ||
props.setShowSummaryPanel(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 |
||
} | ||
|
||
if (isUndefined(props.selectedFireZone) || !props.showSummaryPanel) { | ||
return <div></div> | ||
} else { | ||
return ( | ||
<SidePanelGrid ref={ref}> | ||
<Grid container justifyContent="flex-end"> | ||
<Grid item> | ||
<IconButton aria-label="Close" onClick={handleClose}> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Grid> | ||
</Grid> | ||
<Grid container alignItems={'center'} direction={'column'}> | ||
<Grid item> | ||
<ZoneName>{props.selectedFireZone.mof_fire_zone_name}</ZoneName> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from 'react' | ||
import { Grid, Typography, Checkbox, List, ListItem, ListItemText, ListItemIcon, Icon } from '@mui/material' | ||
import { styled } from '@mui/material/styles' | ||
import { | ||
ADVISORY_ORANGE_FILL, | ||
ADVISORY_RED_FILL, | ||
HFI_ADVISORY, | ||
HFI_WARNING | ||
} from 'features/fba/components/map/featureStylers' | ||
|
||
const LegendGrid = styled(Grid)({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
width: 'fit-content', | ||
backgroundColor: '#fffafa', | ||
paddingRight: '0.5rem', | ||
paddingLeft: '0.5rem', | ||
marginLeft: '0.5rem', | ||
border: '2px solid black' | ||
}) | ||
|
||
const LegendSymbol = styled(Icon)({ | ||
width: '2.5rem', | ||
height: '1rem' | ||
}) | ||
|
||
interface SubItem { | ||
label: string | ||
symbol: string | ||
} | ||
interface LegendItemProps { | ||
label: string | ||
checked: boolean | ||
onChange: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void | ||
subItems?: SubItem[] | ||
} | ||
|
||
const LegendItem: React.FC<LegendItemProps> = ({ label, checked, onChange, subItems }) => ( | ||
<div> | ||
<Grid container alignItems={'center'}> | ||
<Grid item> | ||
<Checkbox checked={checked} onChange={onChange} /> | ||
</Grid> | ||
<Grid item> | ||
<Typography variant="body2">{label}</Typography> | ||
</Grid> | ||
</Grid> | ||
{subItems && ( | ||
<List dense={true} sx={{ marginLeft: '2.5rem', marginTop: '-1rem' }}> | ||
{subItems.map(subItem => ( | ||
<ListItem disablePadding key={subItem.label}> | ||
<ListItemIcon> | ||
<LegendSymbol sx={{ backgroundColor: subItem.symbol }} /> | ||
</ListItemIcon> | ||
<ListItemText>{subItem.label}</ListItemText> | ||
</ListItem> | ||
))} | ||
</List> | ||
)} | ||
</div> | ||
) | ||
|
||
interface LegendProps { | ||
onToggleLayer: (layerName: string, isVisible: boolean) => void | ||
showZoneStatus: boolean | ||
setShowZoneStatus: React.Dispatch<React.SetStateAction<boolean>> | ||
showHFI: boolean | ||
setShowHFI: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
const Legend = ({ onToggleLayer, showZoneStatus, setShowZoneStatus, showHFI, setShowHFI }: LegendProps) => { | ||
const handleLayerChange = ( | ||
layerName: string, | ||
isVisible: boolean, | ||
setShowLayer: React.Dispatch<React.SetStateAction<boolean>> | ||
) => { | ||
setShowLayer(!isVisible) | ||
onToggleLayer(layerName, !isVisible) | ||
} | ||
|
||
const zoneStatusSubItems: SubItem[] = [ | ||
{ label: 'Advisory', symbol: ADVISORY_ORANGE_FILL }, | ||
{ label: 'Warning', symbol: ADVISORY_RED_FILL } | ||
] | ||
const hfiSubItems: SubItem[] = [ | ||
{ label: '4,000 to 9,999', symbol: HFI_ADVISORY }, | ||
{ label: '≥10,000', symbol: HFI_WARNING } | ||
] | ||
|
||
return ( | ||
<LegendGrid> | ||
<Typography align="center" variant="body2" gutterBottom sx={{ fontWeight: 'bold' }}> | ||
BC Fire Advisory Legend | ||
</Typography> | ||
<LegendItem | ||
label="Zone Status" | ||
checked={showZoneStatus} | ||
onChange={() => handleLayerChange('fireZoneVector', showZoneStatus, setShowZoneStatus)} | ||
subItems={zoneStatusSubItems} | ||
/> | ||
<LegendItem | ||
label="HFI Potential (kW/h)" | ||
checked={showHFI} | ||
onChange={() => handleLayerChange('hfiVector', showHFI, setShowHFI)} | ||
subItems={hfiSubItems} | ||
/> | ||
</LegendGrid> | ||
) | ||
} | ||
|
||
export default Legend |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed because I believe with those stats the scroll will always be there anyway and it removes a little UI stutter when selecting a different fire zone