Skip to content

Commit acdc222

Browse files
author
J.C. Hiatt
committed
add basic styles to demo
1 parent 641c7e9 commit acdc222

File tree

3 files changed

+92
-15
lines changed

3 files changed

+92
-15
lines changed

__tests__/createChaos.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import expect from 'expect'
2-
import { createChaos } from '../src/utils/createChaos'
1+
import expect from 'expect';
2+
import { createChaos } from '../src/utils/createChaos';
33

44
const mockMath = (val) => {
55
let mr = Math.random;

demo/src/index.css

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
}

demo/src/index.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,47 @@ import React from 'react'
22
import withChaos from '../../src/index'
33
import { render } from 'react-dom'
44
import ErrorBoundary from '../../src/components/ErrorBoundary';
5+
import './index.css';
56

67
function Demo() {
78
return (
89
<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>
1931
</React.Fragment>
2032
);
2133
}
2234

2335
const Fallback = () => <div style={{
24-
height: '4rem',
2536
backgroundColor: 'yellow',
2637
color: '#333',
27-
fontSize: '3rem',
38+
fontSize: '2rem',
2839
fontWeight: 700
2940
}}
3041
>
3142
<span> I'm handling the error gracefully. 💅 </span>
3243
</div>
3344

34-
const GenericComponent = ({ text }) => <h1>Component {text}</h1>
45+
const GenericComponent = ({ text }) => <pre>Component {text}</pre>
3546

3647
const NestedComponent = ({ children }) => children;
3748

0 commit comments

Comments
 (0)