1
1
import React from 'react'
2
2
import ansiHTML from 'ansi-html'
3
- import Head from 'next/head'
4
- import style from 'next/css'
5
3
6
4
export default class ErrorDebug extends React . Component {
7
5
static getInitialProps ( { err } ) {
@@ -12,21 +10,47 @@ export default class ErrorDebug extends React.Component {
12
10
render ( ) {
13
11
const { name, message, stack, path } = this . props
14
12
15
- return < div className = { styles . errorDebug } >
16
- < Head >
17
- < style dangerouslySetInnerHTML = { { __html : `
18
- body {
19
- background: #a6004c;
20
- margin: 0;
21
- }
22
- ` } } />
23
- </ Head >
24
- { path ? < div className = { styles . heading } > Error in { path } </ div > : null }
13
+ return < div className = 'errorDebug' >
14
+ { path ? < div className = 'heading' > Error in { path } </ div > : null }
25
15
{
26
16
name === 'ModuleBuildError'
27
- ? < pre className = { styles . message } dangerouslySetInnerHTML = { { __html : ansiHTML ( encodeHtml ( message ) ) } } />
28
- : < pre className = { styles . message } > { stack } </ pre >
17
+ ? < pre className = ' message' dangerouslySetInnerHTML = { { __html : ansiHTML ( encodeHtml ( message ) ) } } />
18
+ : < pre className = ' message' > { stack } </ pre >
29
19
}
20
+ < style jsx global > { `
21
+ body {
22
+ background: #a6004c;
23
+ margin: 0;
24
+ }
25
+ ` } </ style >
26
+ < style jsx > { `
27
+ .errorDebug {
28
+ height: 100vh;
29
+ padding: 16px;
30
+ box-sizing: border-box;
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ justify-content: center;
35
+ }
36
+
37
+ .message {
38
+ font-family: "SF Mono", "Roboto Mono", "Fira Mono", menlo-regular, monospace;
39
+ font-size: 10px;
40
+ color: #fbe7f1;
41
+ margin: 0;
42
+ white-space: pre-wrap;
43
+ word-wrap: break-word;
44
+ }
45
+
46
+ .heading {
47
+ font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif;
48
+ font-size: 13px;
49
+ font-weight: bold;
50
+ color: #ff84bf;
51
+ margin-bottom: 20pxl
52
+ }
53
+ ` } </ style >
30
54
</ div >
31
55
}
32
56
}
@@ -35,40 +59,6 @@ const encodeHtml = str => {
35
59
return str . replace ( / < / g, '<' ) . replace ( / > / g, '>' )
36
60
}
37
61
38
- const styles = {
39
- body : style ( {
40
- background : '#a6004c' ,
41
- margin : 0
42
- } ) ,
43
-
44
- errorDebug : style ( {
45
- height : '100vh' ,
46
- padding : '16px' ,
47
- boxSizing : 'border-box' ,
48
- display : 'flex' ,
49
- flexDirection : 'column' ,
50
- alignItems : 'center' ,
51
- justifyContent : 'center'
52
- } ) ,
53
-
54
- message : style ( {
55
- fontFamily : '"SF Mono", "Roboto Mono", "Fira Mono", menlo-regular, monospace' ,
56
- fontSize : '10px' ,
57
- color : '#fbe7f1' ,
58
- margin : 0 ,
59
- whiteSpace : 'pre-wrap' ,
60
- wordWrap : 'break-word'
61
- } ) ,
62
-
63
- heading : style ( {
64
- fontFamily : '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif' ,
65
- fontSize : '13px' ,
66
- fontWeight : 'bold' ,
67
- color : '#ff84bf' ,
68
- marginBottom : '20px'
69
- } )
70
- }
71
-
72
62
// see color definitions of babel-code-frame:
73
63
// https://github.com/babel/babel/blob/master/packages/babel-code-frame/src/index.js
74
64
0 commit comments