From e594f0d088f9ffc9fe44a615940388f496f84410 Mon Sep 17 00:00:00 2001 From: Jareth <110929259+jareth-whitney@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:31:37 -0700 Subject: [PATCH] feature/deseng693: Updated map widget. (#2594) --- CHANGELOG.MD | 6 + .../form/EngagementWidgets/Map/Form.tsx | 17 +- .../old-view/widgets/Map/ExpandModal.tsx | 7 +- .../old-view/widgets/Map/MapWidget.tsx | 146 ++++++++++-------- met-web/src/components/map/index.tsx | 6 +- 5 files changed, 112 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index a90179b23..f956050be 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,9 @@ +## September 25, 2024 + +- **Feature** New Map Widget front end [🎟️ DESENG-693](https://citz-gdx.atlassian.net/browse/DESENG-693) + - Implemented Figma design + - Fixed issue with map labels that were making them inaccessible + ## September 23, 2024 - **Feature** New Hero Banner page in authoring section [🎟️ DESENG-670](https://citz-gdx.atlassian.net/browse/DESENG-670) diff --git a/met-web/src/components/engagement/form/EngagementWidgets/Map/Form.tsx b/met-web/src/components/engagement/form/EngagementWidgets/Map/Form.tsx index eff6221ce..ddd4497c4 100644 --- a/met-web/src/components/engagement/form/EngagementWidgets/Map/Form.tsx +++ b/met-web/src/components/engagement/form/EngagementWidgets/Map/Form.tsx @@ -31,7 +31,7 @@ import { WidgetLocation } from 'models/widget'; const schema = yup .object({ - markerLabel: yup.string().max(30, 'Markel label cannot exceed 30 characters'), + markerLabel: yup.string().max(30, 'Marker label cannot exceed 30 characters'), shapefile: yup.mixed(), geojson: yup.mixed(), latitude: yup @@ -191,8 +191,10 @@ const Form = () => { handleAddFile={handleAddFile} savedFileName={uploadName} savedFile={methods.getValues('shapefile')} + aria-label={'Upload a shape file.'} /> + File Uploaded @@ -228,7 +230,7 @@ const Form = () => { - Latitude + Latitude (Required) Latitude in British Columbia is between 48.30 and 60.00 { }} fullWidth size="small" + aria-label={ + 'Latitude: Latitude in British Columbia is between 48.30 and 60.00. Required field, numeric value with up to two decimal places.' + } /> - Longitude + Longitude (Required) Longitude in British Columbia is between  -139.06 and -114.03 @@ -255,10 +260,13 @@ const Form = () => { }} fullWidth size="small" + aria-label={ + 'Longitude: Longitude in British Columbia is between -139.06 and -114.03. Required field, numeric value with up to two decimal places.' + } /> - Marker Label + Marker Label (Optional) This text will appear next to your marker on the map { }} fullWidth size="small" + aria-label="Marker label: This text will appear next to your marker on the map. Optional field, maximum 30 characters." /> diff --git a/met-web/src/components/engagement/old-view/widgets/Map/ExpandModal.tsx b/met-web/src/components/engagement/old-view/widgets/Map/ExpandModal.tsx index d2885556f..8f314e902 100644 --- a/met-web/src/components/engagement/old-view/widgets/Map/ExpandModal.tsx +++ b/met-web/src/components/engagement/old-view/widgets/Map/ExpandModal.tsx @@ -41,7 +41,12 @@ export const ExpandModal = ({ open, setOpen, map }: ExpandModalProps) => { }} keepMounted={false} > - + { const [mapWidth, setMapWidth] = useState(250); const [mapHeight, setMapHeight] = useState(250); + const theme = useTheme(); + const isDarkMode = 'dark' === theme.palette.mode; + const fetchMap = async () => { try { const map = await fetchMaps(widget.id); @@ -56,21 +60,19 @@ const MapWidget = ({ widget }: MapWidgetProps) => { if (isLoading) { return ( - - - - - - - - - - - - - + + + + + + + + - + + + + ); } @@ -78,54 +80,72 @@ const MapWidget = ({ widget }: MapWidgetProps) => { return null; } + // Define the styles + const metHeader3Styles = { + fontWeight: 'lighter', + fontSize: '1.5rem', + marginBottom: '2.5rem', + marginTop: '4rem', + color: isDarkMode ? colors.surface.white : Palette.text.primary, + }; + const outerContainerStyles = { + position: 'relative', + width: '100%', + paddingTop: '66.67%' /* 3:2 aspect ratio (height / width * 100) */, + }; + const innerContainerStyles = { + position: 'absolute', + top: 0, + left: 0, + width: '100%', + height: '100%', + borderRadius: '16px', + overflow: 'hidden', + }; + const linkStyles = { + color: isDarkMode ? colors.surface.white : Palette.text.primary, + textDecorationColor: isDarkMode ? colors.surface.white : Palette.text.primary, + cursor: 'pointer', + }; + return ( - <> - - - - {widget.title} - - - - - - - - - - - setOpen(true)} backgroundColor="none" /> - - - setOpen(true)} tabIndex={0} onKeyPress={() => setOpen(true)}> - View Expanded Map - - - - - + + + {widget.title} + + + + + + + + + + + setOpen(true)} sx={linkStyles} tabIndex={0} onKeyDown={() => setOpen(true)}> + + View Expanded Map + - - + + + ); }; diff --git a/met-web/src/components/map/index.tsx b/met-web/src/components/map/index.tsx index 2d2e7c286..ac94e1b2b 100644 --- a/met-web/src/components/map/index.tsx +++ b/met-web/src/components/map/index.tsx @@ -9,7 +9,8 @@ import { MetSmallTextOld } from 'components/common'; import { Stack } from '@mui/material'; import { When } from 'react-if'; import { AnyLayer } from 'mapbox-gl'; -import { Palette } from 'styles/Theme'; +import { colors, Palette } from 'styles/Theme'; + interface MapProps { latitude: number; longitude: number; @@ -74,7 +75,8 @@ const MetMap = ({ geojson, latitude, longitude, markerLabel, zoom }: MapProps) =