File tree 3 files changed +92
-15
lines changed
3 files changed +92
-15
lines changed Original file line number Diff line number Diff line change 1
- import expect from 'expect'
2
- import { createChaos } from '../src/utils/createChaos'
1
+ import expect from 'expect' ;
2
+ import { createChaos } from '../src/utils/createChaos' ;
3
3
4
4
const mockMath = ( val ) => {
5
5
let mr = Math . random ;
Original file line number Diff line number Diff line change
1
+ .button {
2
+ position : absolute;
3
+ top : 2rem ;
4
+ left : 1rem ;
5
+ width : 180px ;
6
+ padding : 1rem ;
7
+ background-color : palevioletred;
8
+ color : white;
9
+ font-size : 1rem ;
10
+ font-weight : 700 ;
11
+ font-family : Arial;
12
+ }
13
+
14
+ .button : hover {
15
+ cursor : pointer;
16
+ background-color : goldenrod;
17
+ }
18
+
19
+ .header {
20
+ color : # 333 ;
21
+ font-family : monospace;
22
+ font-size : 2rem ;
23
+ text-transform : uppercase;
24
+ text-align : center;
25
+ }
26
+
27
+ .wrapper {
28
+ display : flex;
29
+ justify-content : center;
30
+ align-items : center;
31
+ height : calc (100vh - 8rem );
32
+ width : 100vw ;
33
+ }
34
+
35
+ .container {
36
+ display : flex;
37
+ flex-direction : column;
38
+ justify-content : center;
39
+ align-items : center;
40
+ margin : 1rem ;
41
+ padding : 0.25rem ;
42
+ }
43
+
44
+ .child {
45
+ display : flex;
46
+ flex-direction : column;
47
+ justify-content : center;
48
+ align-items : center;
49
+ width : 480px ;
50
+ height : 480px ;
51
+ margin : 1rem ;
52
+ padding : 0.5rem ;
53
+ font-size : 1.5rem ;
54
+ }
55
+
56
+ .one {
57
+ background-color : peru;
58
+ }
59
+
60
+ .two {
61
+ background-color : papayawhip;
62
+ }
63
+
64
+ .three {
65
+ background-color : peachpuff;
66
+ }
Original file line number Diff line number Diff line change @@ -2,36 +2,47 @@ import React from 'react'
2
2
import withChaos from '../../src/index'
3
3
import { render } from 'react-dom'
4
4
import ErrorBoundary from '../../src/components/ErrorBoundary' ;
5
+ import './index.css' ;
5
6
6
7
function Demo ( ) {
7
8
return (
8
9
< React . Fragment >
9
- < button onClick = { ( ) => {
10
- // eslint-disable-next-line
11
- location . reload ( )
12
- } } > Reload</ button >
13
- < ComponentOne />
14
- < ErrorBoundary fallback = { < Fallback /> } >
15
- < ComponentWithChaos />
16
- </ ErrorBoundary >
17
- < ComponentTwo />
18
- < ComponentThree />
10
+ < div className = "header" >
11
+ < h1 > 🔥🐒💥 React Chaos</ h1 >
12
+ </ div >
13
+ < button className = "button" onClick = { ( ) => {
14
+ // eslint-disable-next-line
15
+ location . reload ( )
16
+ } } > Reload</ button >
17
+ < div className = "wrapper" >
18
+ < div className = "container child one" >
19
+ < ComponentOne />
20
+ < ErrorBoundary fallback = { < Fallback /> } >
21
+ < ComponentWithChaos />
22
+ </ ErrorBoundary >
23
+ </ div >
24
+ < div className = "container child two" >
25
+ < ComponentTwo />
26
+ </ div >
27
+ < div className = "container child three" >
28
+ < ComponentThree />
29
+ </ div >
30
+ </ div >
19
31
</ React . Fragment >
20
32
) ;
21
33
}
22
34
23
35
const Fallback = ( ) => < div style = { {
24
- height : '4rem' ,
25
36
backgroundColor : 'yellow' ,
26
37
color : '#333' ,
27
- fontSize : '3rem ' ,
38
+ fontSize : '2rem ' ,
28
39
fontWeight : 700
29
40
} }
30
41
>
31
42
< span > I'm handling the error gracefully. 💅 </ span >
32
43
</ div >
33
44
34
- const GenericComponent = ( { text } ) => < h1 > Component { text } </ h1 >
45
+ const GenericComponent = ( { text } ) => < pre > Component { text } </ pre >
35
46
36
47
const NestedComponent = ( { children } ) => children ;
37
48
You can’t perform that action at this time.
0 commit comments