@@ -26,8 +26,6 @@ var Entities = require('html-entities').AllHtmlEntities;
26
26
var ansiHTML = require ( './ansiHTML' ) ;
27
27
var entities = new Entities ( ) ;
28
28
29
- var red = '#E36049' ;
30
-
31
29
function createOverlayIframe ( onIframeLoad ) {
32
30
var iframe = document . createElement ( 'iframe' ) ;
33
31
iframe . id = 'react-dev-utils-webpack-hot-dev-client-overlay' ;
@@ -46,28 +44,53 @@ function createOverlayIframe(onIframeLoad) {
46
44
}
47
45
48
46
function addOverlayDivTo ( iframe ) {
47
+ // TODO: unify these styles with react-error-overlay
48
+ iframe . contentDocument . body . style . margin = 0 ;
49
+ iframe . contentDocument . body . style . maxWidth = '100vw' ;
50
+
51
+ var outerDiv = iframe . contentDocument . createElement ( 'div' ) ;
52
+ outerDiv . id = 'react-dev-utils-webpack-hot-dev-client-overlay-div' ;
53
+ outerDiv . style . width = '100%' ;
54
+ outerDiv . style . height = '100%' ;
55
+ outerDiv . style . boxSizing = 'border-box' ;
56
+ outerDiv . style . textAlign = 'center' ;
57
+ outerDiv . style . backgroundColor = 'rgb(255, 255, 255)' ;
58
+
49
59
var div = iframe . contentDocument . createElement ( 'div' ) ;
50
- div . id = 'react-dev-utils-webpack-hot-dev-client-overlay-div' ;
51
- div . style . position = 'fixed' ;
60
+ div . style . position = 'relative' ;
61
+ div . style . display = 'inline-flex' ;
62
+ div . style . flexDirection = 'column' ;
63
+ div . style . height = '100%' ;
64
+ div . style . width = '1024px' ;
65
+ div . style . maxWidth = '100%' ;
66
+ div . style . overflowX = 'hidden' ;
67
+ div . style . overflowY = 'auto' ;
68
+ div . style . padding = '0.5rem' ;
52
69
div . style . boxSizing = 'border-box' ;
53
- div . style . left = 0 ;
54
- div . style . top = 0 ;
55
- div . style . right = 0 ;
56
- div . style . bottom = 0 ;
57
- div . style . width = '100vw' ;
58
- div . style . height = '100vh' ;
59
- div . style . backgroundColor = '#fafafa' ;
60
- div . style . color = '#333' ;
61
- div . style . fontFamily = 'Menlo, Consolas, monospace' ;
62
- div . style . fontSize = 'large' ;
63
- div . style . padding = '2rem' ;
64
- div . style . lineHeight = '1.2' ;
70
+ div . style . textAlign = 'start' ;
71
+ div . style . fontFamily = 'Consolas, Menlo, monospace' ;
72
+ div . style . fontSize = '11px' ;
65
73
div . style . whiteSpace = 'pre-wrap' ;
66
- div . style . overflow = 'auto' ;
67
- iframe . contentDocument . body . appendChild ( div ) ;
74
+ div . style . wordBreak = 'break-word' ;
75
+ div . style . lineHeight = '1.5' ;
76
+ div . style . color = 'rgb(41, 50, 56)' ;
77
+
78
+ outerDiv . appendChild ( div ) ;
79
+ iframe . contentDocument . body . appendChild ( outerDiv ) ;
68
80
return div ;
69
81
}
70
82
83
+ function overlayHeaderStyle ( ) {
84
+ return 'font-size: 2em;' +
85
+ 'font-family: sans-serif;' +
86
+ 'color: rgb(206, 17, 38);' +
87
+ 'white-space: pre-wrap;' +
88
+ 'margin: 0.75rem 2rem 0px 0px;' +
89
+ 'flex: 0 0 auto;' +
90
+ 'max-height: 35%;' +
91
+ 'overflow: auto;' ;
92
+ }
93
+
71
94
var overlayIframe = null ;
72
95
var overlayDiv = null ;
73
96
var lastOnOverlayDivReady = null ;
@@ -103,11 +126,21 @@ function ensureOverlayDivExists(onOverlayDivReady) {
103
126
104
127
function showErrorOverlay ( message ) {
105
128
ensureOverlayDivExists ( function onOverlayDivReady ( overlayDiv ) {
106
- // Make it look similar to our terminal.
107
- overlayDiv . innerHTML = '<span style="color: ' +
108
- red +
109
- '">Failed to compile.</span><br><br>' +
110
- ansiHTML ( entities . encode ( message ) ) ;
129
+ // TODO: unify this with our runtime overlay
130
+ overlayDiv . innerHTML = '<div style="' +
131
+ overlayHeaderStyle ( ) +
132
+ '">Failed to compile</div><br><br>' +
133
+ '<pre style="' +
134
+ 'display: block; padding: 0.5em; margin-top: 0.5em; ' +
135
+ 'margin-bottom: 0.5em; overflow-x: auto; white-space: pre-wrap; ' +
136
+ 'border-radius: 0.25rem; background-color: rgba(206, 17, 38, 0.05)">' +
137
+ '<code style="font-family: Consolas, Menlo, monospace;">' +
138
+ ansiHTML ( entities . encode ( message ) ) +
139
+ '</code></pre>' +
140
+ '<div style="' +
141
+ 'font-family: sans-serif; color: rgb(135, 142, 145); margin-top: 0.5rem; ' +
142
+ 'flex: 0 0 auto">' +
143
+ 'This error occurred during the build time and cannot be dismissed.</div>' ;
111
144
} ) ;
112
145
}
113
146
0 commit comments