Skip to content

Commit 4d0badd

Browse files
authored
Remove theme-aware colors and prevent horizontal scroll on InterstitialModal (#14198)
### WHY are these changes introduced? Stars and text on interstitial modal used theme-aware CSS colors, resulting in incorrect rendering on dark mode. It was also possible to horizontal scroll on the modal ### WHAT is this pull request doing? Replaces theme-aware CSS colors with hardcoded colors for the interstitial modal only. Prevents horizontal scroll on interstitial modal.
1 parent 0a5f21f commit 4d0badd

File tree

3 files changed

+40
-34
lines changed

3 files changed

+40
-34
lines changed

.changeset/tender-flowers-shine.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

polaris.shopify.com/src/components/InterstitialModal/InterstitialModal.module.scss

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
z-index: 10000;
1212
padding: 2rem;
1313
animation: fadeIn 0.4s ease-in-out;
14-
overflow-y: auto;
14+
overflow: hidden;
1515

1616
@media (max-width: 768px) {
1717
padding: 1rem;
@@ -86,7 +86,7 @@
8686
left: var(--star-left);
8787
width: var(--star-size);
8888
height: var(--star-size);
89-
background: var(--surface);
89+
background: #ffffff;
9090
border-radius: 50%;
9191
pointer-events: none;
9292
animation: twinkle var(--star-duration) ease-in-out var(--star-delay) infinite;
@@ -124,6 +124,7 @@
124124
.Modal {
125125
max-width: 900px;
126126
width: 100%;
127+
max-height: 100vh;
127128
animation: slideUp 0.5s ease-out;
128129
position: relative;
129130
z-index: 3;
@@ -328,7 +329,7 @@
328329
.Title {
329330
font-size: var(--font-size-1000);
330331
font-weight: var(--font-weight-700);
331-
color: var(--surface);
332+
color: #ffffff;
332333
margin: 0 0 1.5rem 0;
333334
line-height: 1.3;
334335

@@ -345,7 +346,7 @@
345346

346347
.Description {
347348
font-size: var(--font-size-700);
348-
color: var(--surface);
349+
color: #ffffff;
349350
margin: 0 0 2.5rem 0;
350351
line-height: 1.6;
351352
opacity: 0.95;
@@ -379,51 +380,28 @@
379380
padding: 1rem 2rem !important;
380381
font-size: var(--font-size-600) !important;
381382
font-weight: var(--font-weight-600) !important;
382-
background: var(--p-color-bg-fill) !important;
383-
color: var(--p-color-text-on-color) !important;
383+
background: #ffffff !important;
384+
color: #303030 !important;
384385
border-radius: var(--p-border-radius-200) !important;
385-
box-shadow: none !important;
386-
box-sizing: border-box !important;
387-
border: none !important;
388-
transition: all var(--duration-200) var(--ease-in-out) !important;
389386

390387
@media (max-width: 480px) {
391388
padding: 0.875rem 1.5rem !important;
392389
font-size: var(--font-size-500) !important;
393390
}
394391

395392
&:hover {
396-
background: var(--p-color-bg-fill-hover) !important;
397-
transform: translateY(-1px);
398-
box-shadow: none !important;
399-
400-
@media (prefers-reduced-motion: reduce) {
401-
transform: none;
402-
}
393+
background: #f0f0f0 !important;
403394
}
404395

405396
&:active {
406-
background: var(--p-color-bg-fill-active) !important;
407-
transform: translateY(0);
408-
409-
@media (prefers-reduced-motion: reduce) {
410-
transform: none;
411-
}
412-
}
413-
414-
&:focus,
415-
&:focus-visible {
416-
outline: 2px solid var(--p-color-border-focus) !important;
417-
outline-offset: 2px !important;
418-
box-shadow: none !important;
419-
border: none !important;
397+
background: #e0e0e0 !important;
420398
}
421399
}
422400

423401
.SecondaryLink {
424402
background: none;
425403
border: none;
426-
color: var(--surface);
404+
color: #ffffff;
427405
cursor: pointer;
428406
font-size: var(--font-size-400);
429407
text-decoration: underline;
@@ -441,7 +419,7 @@
441419
}
442420

443421
&:focus-visible {
444-
outline: 2px solid var(--surface);
422+
outline: 2px solid #ffffff;
445423
outline-offset: 4px;
446424
border-radius: var(--border-radius-300);
447425
}

polaris.shopify.com/src/components/InterstitialModal/InterstitialModal.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Polaris12Icon.displayName = 'Polaris12Icon';
175175

176176
export default function InterstitialModal() {
177177
const [isOpen, setIsOpen] = useState(false);
178+
const modalRef = React.useRef<HTMLDivElement>(null);
178179

179180
// Generate stars once with useMemo
180181
const stars = React.useMemo(
@@ -240,6 +241,31 @@ export default function InterstitialModal() {
240241
return () => document.removeEventListener('keydown', handleKeyDown);
241242
}, [isOpen, handleDismiss]);
242243

244+
// Prevent body scrolling when modal is open
245+
useEffect(() => {
246+
if (!isOpen) return;
247+
248+
const originalOverflow = document.body.style.overflow;
249+
250+
document.body.style.overflow = 'hidden';
251+
252+
// Prevent iOS Safari bounce scrolling
253+
const preventScroll = (e: TouchEvent) => {
254+
if (e.target instanceof Element && modalRef.current) {
255+
if (!modalRef.current.contains(e.target)) {
256+
e.preventDefault();
257+
}
258+
}
259+
};
260+
261+
document.addEventListener('touchmove', preventScroll, {passive: false});
262+
263+
return () => {
264+
document.body.style.overflow = originalOverflow;
265+
document.removeEventListener('touchmove', preventScroll);
266+
};
267+
}, [isOpen]);
268+
243269
if (!isOpen) {
244270
return null;
245271
}
@@ -269,7 +295,7 @@ export default function InterstitialModal() {
269295
))}
270296
<ShootingStarsBackground />
271297
</div>
272-
<div className={styles.Modal}>
298+
<div ref={modalRef} className={styles.Modal}>
273299
<div className={styles.Content}>
274300
<div className={styles.StarIconContainer} aria-hidden="true">
275301
<div className={styles.BackgroundStarBottom}>

0 commit comments

Comments
 (0)