@@ -26,8 +26,6 @@ var Entities = require('html-entities').AllHtmlEntities;
2626var ansiHTML = require ( './ansiHTML' ) ;
2727var entities = new Entities ( ) ;
2828
29- var red = '#E36049' ;
30-
3129function createOverlayIframe ( onIframeLoad ) {
3230 var iframe = document . createElement ( 'iframe' ) ;
3331 iframe . id = 'react-dev-utils-webpack-hot-dev-client-overlay' ;
@@ -46,28 +44,53 @@ function createOverlayIframe(onIframeLoad) {
4644}
4745
4846function 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+
4959 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' ;
5269 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' ;
6573 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 ) ;
6880 return div ;
6981}
7082
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+
7194var overlayIframe = null ;
7295var overlayDiv = null ;
7396var lastOnOverlayDivReady = null ;
@@ -103,11 +126,21 @@ function ensureOverlayDivExists(onOverlayDivReady) {
103126
104127function showErrorOverlay ( message ) {
105128 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>' ;
111144 } ) ;
112145}
113146
0 commit comments