Skip to content

Commit da46853

Browse files
committed
Improve maps on mobile
- reduce spacing on mobile for popups, prevent collision with headings and close icons - set maximum width of popups to prevent overlap on mobile - set maximum height of map on mobile to not be more than screen height, to help with scrolling - remove in-house leaflet CSS and use one from package instead, move overrides into main stylesheet
1 parent d1c485b commit da46853

File tree

5 files changed

+39
-756
lines changed

5 files changed

+39
-756
lines changed

app/assets/javascripts/modules/landing-page-map.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
206206

207207
const popupHeading = document.createElement('h3')
208208
popupHeading.classList.add('govuk-heading-m')
209+
popupHeading.classList.add('map-popup__heading')
209210
popupHeading.setAttribute('data-ga4-text', '')
210211
const popupBody = document.createElement('div')
211212

@@ -250,7 +251,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
250251
popupContainer.appendChild(popupHeading)
251252
popupContainer.appendChild(popupBody)
252253

253-
const popup = layer.bindPopup(popupContainer)
254+
const popup = layer.bindPopup(popupContainer, { maxWidth: 250 })
254255
popup.on('popupopen', (e) => {
255256
if (ftGeomType === 'Point') e.target.setIcon(this.context.icons[lyrPane].active)
256257
else e.target.setStyle({ fillOpacity: 0.3 })

app/assets/stylesheets/views/_landing_page/map.scss

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "govuk_publishing_components/individual_component_support";
2+
@import "leaflet/dist/leaflet";
23

34
.map {
45
display: none;
@@ -20,6 +21,10 @@
2021
padding: 0;
2122
height: 800px;
2223
background-color: #d7e0e5;
24+
25+
@include govuk-media-query($until: tablet) {
26+
max-height: 80vh;
27+
}
2328
}
2429

2530
.map__key {
@@ -56,3 +61,35 @@
5661
.map__key-item--ics::before {
5762
background-image: url("landing_page/map/IC-symbol-key.svg");
5863
}
64+
65+
.map-popup__heading {
66+
@include govuk-media-query($until: tablet) {
67+
padding-right: govuk-spacing(4);
68+
}
69+
}
70+
71+
// leaflet plugin default style overrides
72+
73+
.leaflet-container img.leaflet-tile { // stylelint-disable-line selector-no-qualifying-type
74+
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120
75+
mix-blend-mode: normal;
76+
width: 256px !important; // stylelint-disable-line declaration-no-important
77+
height: 256px !important; // stylelint-disable-line declaration-no-important
78+
}
79+
80+
.leaflet-popup-content {
81+
@include govuk-media-query($until: tablet) {
82+
margin: govuk-spacing(2);
83+
}
84+
85+
p {
86+
margin: 0 0 govuk-spacing(1);
87+
}
88+
}
89+
90+
.leaflet-container a.leaflet-popup-close-button { // stylelint-disable-line selector-no-qualifying-type
91+
width: 35px;
92+
height: 35px;
93+
font: 24px/35px Tahoma, Verdana, sans-serif;
94+
font-weight: bold;
95+
}

0 commit comments

Comments
 (0)