Skip to content

Commit 540c8c8

Browse files
author
Brian Vaughn
committed
Tidied up styles tobe more mobile Safari friendly
1 parent 9e453da commit 540c8c8

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

packages/react-error-overlay/src/components/overlay.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22
import { applyStyles } from '../utils/dom/css';
33
import {
4-
craContainer,
4+
containerStyle,
55
overlayStyle,
66
headerStyle,
77
additionalStyle,
@@ -32,19 +32,13 @@ function createOverlay(
3232
const frameSettings: FrameSetting[] = frames.map(() => ({ compiled: false }));
3333
// Create overlay
3434
const overlay = document.createElement('div');
35-
overlay.addEventListener('click', function(event: Event) {
36-
// Clicks to background layer dismiss the popup
37-
// Prevent clicks within the panel from accidentally dismissing
38-
event.stopPropagation();
39-
});
4035
applyStyles(overlay, overlayStyle);
41-
overlay.appendChild(createClose(document, closeCallback));
4236

4337
// Create container
4438
const container = document.createElement('div');
45-
applyStyles(container, craContainer);
46-
container.className = 'cra-container';
39+
applyStyles(container, containerStyle);
4740
overlay.appendChild(container);
41+
container.appendChild(createClose(document, closeCallback));
4842

4943
// Create additional
5044
const additional = document.createElement('div');
@@ -90,6 +84,14 @@ function createOverlay(
9084
// Show message
9185
container.appendChild(createFooter(document));
9286

87+
// Clicks to background overlay should dismiss error popup.
88+
overlay.addEventListener('click', closeCallback);
89+
90+
// Clicks within the popup should not dismiss it.
91+
container.addEventListener('click', function(event: Event) {
92+
event.stopPropagation();
93+
});
94+
9395
return {
9496
overlay,
9597
additional,

packages/react-error-overlay/src/overlay.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ function render(name: ?string, message: string, resolvedFrames: StackFrame[]) {
8080
}
8181
if (document.body != null) {
8282
document.body.style.margin = '0';
83-
document.body.appendChild(overlay);
84-
// Clicks to background overlay should dismiss error popup
85-
(document.body: any).addEventListener('click', unmount);
83+
// Keep popup within body boundaries for iOS Safari
84+
// $FlowFixMe
85+
document.body.style['max-width'] = '100vw';
86+
87+
(document.body: any).appendChild(overlay);
8688
}
8789
additionalReference = additional;
8890
};

packages/react-error-overlay/src/styles.js

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,46 @@ const black = '#293238',
77
white = '#ffffff';
88

99
const iframeStyle = {
10-
'background-color': 'rgba(0,0,0,.5)',
1110
position: 'fixed',
12-
top: '1em',
13-
left: '1em',
14-
bottom: '1em',
15-
right: '1em',
16-
width: 'calc(100% - 2em)',
17-
height: 'calc(100% - 2em)',
11+
top: '0',
12+
left: '0',
13+
width: '100%',
14+
height: '100%',
1815
border: 'none',
19-
'border-radius': '3px',
20-
'box-shadow': '0 0 6px 0 rgba(0, 0, 0, 0.5)',
2116
'z-index': 1337,
2217
};
2318

2419
const overlayStyle = {
25-
position: 'absolute',
26-
top: '0.5rem',
27-
left: '50%',
28-
'margin-left': '0',
29-
'margin-right': '-50%',
30-
transform: 'translate(-50%, 0)',
31-
display: 'inline-block',
32-
margin: '0.5rem',
33-
'max-height': 'calc(100% - 1rem)',
34-
'max-width': 'calc(100% - 1rem)',
20+
width: '100%',
21+
height: '100%',
22+
'box-sizing': 'border-box',
23+
'background-color': 'rgba(0,0,0,.5)',
24+
padding: '0.5rem',
25+
'text-align': 'center',
26+
};
27+
28+
const containerStyle = {
29+
position: 'relative',
30+
display: 'inline-flex',
31+
'flex-direction': 'column',
32+
'max-height': '100%',
33+
'max-width': '100%',
34+
'overflow-x': 'hidden',
35+
'overflow-y': 'auto',
36+
padding: '0.5rem',
3537
'box-sizing': 'border-box',
36-
padding: '0 1rem',
38+
'text-align': 'start',
3739
'font-family': 'Consolas, Menlo, monospace',
3840
'font-size': '10px',
39-
color: black,
4041
'white-space': 'pre-wrap',
41-
overflow: 'auto',
42-
'overflow-x': 'hidden',
4342
'word-break': 'break-word',
4443
'line-height': 1.5,
4544
'background-color': white,
45+
color: black,
4646
'border-radius': '0.25rem',
4747
'box-shadow': '0 0 10px 0 rgba(0, 0, 0, 0.15)',
4848
};
4949

50-
const craContainer = {
51-
display: 'flex',
52-
'flex-direction': 'column',
53-
'max-height': '100%',
54-
};
55-
5650
const hintsStyle = {
5751
color: darkGray,
5852
};
@@ -83,8 +77,8 @@ const headerStyle = {
8377
'font-family': 'sans-serif',
8478
color: red,
8579
'white-space': 'pre-wrap',
80+
margin: '0.75rem 2rem 0 0', // Prevent overlap with close button
8681
flex: '0 0 auto',
87-
margin: '0.75rem 0 0',
8882
};
8983

9084
const functionNameStyle = {
@@ -102,8 +96,9 @@ const anchorStyle = {
10296

10397
const traceStyle = {
10498
'font-size': '1em',
99+
flex: '0 1 auto',
100+
'min-height': '0px',
105101
overflow: 'auto',
106-
flex: '1 1 auto',
107102
};
108103

109104
const depStyle = {};
@@ -175,13 +170,13 @@ const groupElemRight = Object.assign({}, _groupElemStyle, {
175170
const footerStyle = {
176171
'font-family': 'sans-serif',
177172
color: darkGray,
178-
flex: '0 0 auto',
179173
'margin-top': '0.5rem',
180174
'margin-bottom': '1rem',
175+
flex: '0 0 auto',
181176
};
182177

183178
export {
184-
craContainer,
179+
containerStyle,
185180
iframeStyle,
186181
overlayStyle,
187182
hintsStyle,

0 commit comments

Comments
 (0)