Skip to content
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

Mwpw 157587 | [Geo-Routing][Page Performance] Removing the georouting modal background image #2891

Merged
merged 9 commits into from
Sep 18, 2024
23 changes: 0 additions & 23 deletions libs/features/georoutingv2/georoutingv2.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
z-index: -1;
}

.dialog-modal.locale-modal-v2 .georouting-bg svg {
width: 100%;
}

.dialog-modal.locale-modal-v2 .picker {
position: fixed;
margin-top: 2px;
Expand Down Expand Up @@ -140,19 +136,6 @@
padding: initial;
}

@media (min-width: 480px) {
.dialog-modal.locale-modal-v2 {
background-image: url('/libs/features/georoutingv2/img/GeoModal_BG_Map_Tablet.png');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to remove the image from assets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@narcis-radu I have removed this image from repo

background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

.dialog-modal.locale-modal-v2 .georouting-bg {
display: none;
}
}

@media (min-width: 600px) {
.dialog-modal.locale-modal-v2 .georouting-wrapper {
padding: 56px 56px 40px;
Expand All @@ -168,9 +151,3 @@
max-width: 720px;
}
}

@media (min-width: 1200px) {
.dialog-modal.locale-modal-v2 {
background-image: url('/libs/features/georoutingv2/img/GeoModal_BG_Map_Desktop.png');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to remove the image from assets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@narcis-radu I have removed this image from repo

}
}
8 changes: 1 addition & 7 deletions libs/features/georoutingv2/georoutingv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,7 @@ function buildContent(currentPage, locale, geoData, locales) {
async function getDetails(currentPage, localeMatches, geoData) {
const availableLocales = await getAvailableLocales(localeMatches);
if (!availableLocales.length) return null;
const { innerWidth } = window;
let svgDiv = null;
if (innerWidth < 480) {
const { default: getMobileBg } = await import('./getMobileBg.js');
svgDiv = createTag('div', { class: 'georouting-bg' }, getMobileBg());
}
const georoutingWrapper = createTag('div', { class: 'georouting-wrapper fragment', style: 'display:none;' }, svgDiv);
const georoutingWrapper = createTag('div', { class: 'georouting-wrapper fragment', style: 'display:none;' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but I see the display declaration is being kept and overridden by CSS with !important. Does this need to stay like this? Could we use a modifier class instead of adding the style via JS? Could we remove the style attribute at a later point? It's just a bit confusing to see
Screenshot 2024-09-17 at 16 36 05

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@overmyheadandbody This would currently be required as the getDetails function that fetches and adds the modal to the DOM is called before showModal that fetches the georoutingv2.css and till that time the modal needs to be hidden. We would either need to add this as class to a different css file that gets loaded before and then apply this class here.
We can probably explore this as a part of a different PR? Could you share your thoughts on the same?

@narcis-radu @mokimo @robert-bogos Could you share your inputs on the same?

currentPage.url = window.location.hash ? document.location.href : '#';
if (availableLocales.length === 1) {
const content = buildContent(currentPage, availableLocales[0], geoData);
Expand Down
13 changes: 0 additions & 13 deletions libs/features/georoutingv2/getMobileBg.js

This file was deleted.

11 changes: 0 additions & 11 deletions test/features/georoutingv2/georoutingv2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,6 @@ describe('GeoRouting', () => {
expect(modal).to.not.be.null;
});

it('Has inline svg for mobile background', async () => {
const ogWidth = window.innerWidth;
window.innerWidth = 400;

await init(mockConfig, createTag, getMetadata, loadBlock, loadStyle);
const svg = document.querySelector('.dialog-modal .georouting-bg svg');
expect(svg).to.exist;

window.innerWidth = ogWidth;
});

it('Does not create a modal if the user IP matches session storage.', async () => {
// prepare
setUserCountryFromIP('US');
Expand Down
Loading