|
1 | 1 | import React from 'react';
|
2 | 2 | import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
|
| 3 | +/** @jsx jsx */ |
| 4 | +import { jsx, css } from '@emotion/core'; |
3 | 5 |
|
4 | 6 | import AccordionScreen from './components/accordion';
|
5 | 7 | import FormLibraryScreen from './components/form-library';
|
6 | 8 | import WindowWidthScreen from './components/window-width';
|
7 | 9 | import TodoList from './components/todo-list';
|
8 | 10 | import SortableScreen from "./components/sortable";
|
| 11 | +import Concurrent1 from "./components/concurrent/Concurrent1"; |
| 12 | +import Concurrent2 from "./components/concurrent/Concurrent2"; |
| 13 | +import Concurrent3 from "./components/concurrent/Concurrent3"; |
| 14 | +import Concurrent3After from "./components/concurrent/Concurrent3_after"; |
| 15 | + |
| 16 | +const Homepage = () => { |
| 17 | + return <div>use navigation on the left</div>; |
| 18 | +}; |
9 | 19 |
|
10 | 20 | function App() {
|
11 |
| - return ( |
12 |
| - <Router> |
13 |
| - <div className="main"> |
14 |
| - <nav className="sidebar"> |
15 |
| - <div className="item"> |
16 |
| - <Link className="link" to="/accordion"> |
17 |
| - Accordion |
18 |
| - </Link> |
19 |
| - <span> |
20 |
| - Panels scroll into view if not fully visible when toggled. |
| 21 | + const mode = window.localStorage.getItem('mode'); |
| 22 | + |
| 23 | + return <Router> |
| 24 | + <div className="main"> |
| 25 | + <div className="sync-async"> |
| 26 | + <a |
| 27 | + css={css`font-weight: ${(!mode || mode === 'sync') && 'bold'};`} |
| 28 | + onClick={() => { |
| 29 | + window.localStorage.setItem('mode', 'sync'); |
| 30 | + window.location.reload(); |
| 31 | + }} |
| 32 | + >sync</a> |
| 33 | + {' / '} |
| 34 | + <a |
| 35 | + css={css`font-weight: ${mode === 'concurrent' && 'bold'};`} |
| 36 | + onClick={() => { |
| 37 | + window.localStorage.setItem('mode', 'concurrent'); |
| 38 | + window.location.reload(); |
| 39 | + }} |
| 40 | + >concurrent</a> |
| 41 | + </div> |
| 42 | + <nav className="sidebar"> |
| 43 | + <div className="item"> |
| 44 | + <Link className="link" to="/accordion"> |
| 45 | + Accordion |
| 46 | + </Link> |
| 47 | + <span> |
| 48 | + Panels scroll into view if not fully visible when toggled. |
21 | 49 | Using <pre>useEffect</pre>, <pre>useRef</pre>.
|
22 | 50 | </span>
|
23 |
| - </div> |
24 |
| - <div className="item"> |
25 |
| - <Link className="link" to="/form-library"> |
26 |
| - Extremely basic form validation library |
27 |
| - </Link> |
28 |
| - <span>Pass state deeper using context, then read it using <pre>useContext</pre>. Heavily inspired by <pre>formik</pre>.</span> |
29 |
| - </div> |
30 |
| - <div className="item"> |
31 |
| - <Link className="link" to="/window-width"> |
32 |
| - Window width |
33 |
| - </Link> |
34 |
| - <span>Multiple <pre>useEffects</pre> are allowed.</span> |
35 |
| - </div> |
36 |
| - <div className="item"> |
37 |
| - <Link className="link" to="/todo-list"> |
38 |
| - Todo-list |
39 |
| - </Link> |
40 |
| - <span>Look mum, <pre>useReducer</pre> is almost Redux!</span> |
41 |
| - </div> |
42 |
| - <div className="item"> |
43 |
| - <Link className="link" to="/sortable"> |
44 |
| - Sortable |
45 |
| - </Link> |
46 |
| - </div> |
47 |
| - </nav> |
48 |
| - |
49 |
| - <div className="content"> |
50 |
| - <Route path="/" exact component={() => <div>use navigation on the left</div>}/> |
51 |
| - <Route path="/accordion" component={AccordionScreen}/> |
52 |
| - <Route path="/form-library" component={FormLibraryScreen}/> |
53 |
| - <Route path="/window-width" component={WindowWidthScreen}/> |
54 |
| - <Route path="/todo-list" component={TodoList}/> |
55 |
| - <Route path="/sortable" component={SortableScreen}/> |
56 | 51 | </div>
|
| 52 | + <div className="item"> |
| 53 | + <Link className="link" to="/form-library"> |
| 54 | + Extremely basic form validation library |
| 55 | + </Link> |
| 56 | + <span>Pass state deeper using context, then read it using <pre>useContext</pre>. Heavily inspired by <pre>formik</pre>.</span> |
| 57 | + </div> |
| 58 | + <div className="item"> |
| 59 | + <Link className="link" to="/window-width"> |
| 60 | + Window width |
| 61 | + </Link> |
| 62 | + <span>Multiple <pre>useEffects</pre> are allowed.</span> |
| 63 | + </div> |
| 64 | + <div className="item"> |
| 65 | + <Link className="link" to="/todo-list"> |
| 66 | + Todo-list |
| 67 | + </Link> |
| 68 | + <span>Look mum, <pre>useReducer</pre> is almost Redux!</span> |
| 69 | + </div> |
| 70 | + <div className="item"> |
| 71 | + <Link className="link" to="/sortable"> |
| 72 | + Sortable |
| 73 | + </Link> |
| 74 | + </div> |
| 75 | + <div className="item"> |
| 76 | + Concurrent React experiments |
| 77 | + <span css={{ display: 'flex' }}> |
| 78 | + <Link className="link" to="/concurrent1">One</Link>,{' '} |
| 79 | + <Link className="link" to="/concurrent2">Two</Link>,{' '} |
| 80 | + <Link className="link" to="/concurrent3">Three</Link> |
| 81 | + </span> |
| 82 | + </div> |
| 83 | + </nav> |
| 84 | + |
| 85 | + <div className="content"> |
| 86 | + <Route path="/" exact component={Homepage} /> |
| 87 | + <Route path="/accordion" component={AccordionScreen} /> |
| 88 | + <Route path="/form-library" component={FormLibraryScreen} /> |
| 89 | + <Route path="/window-width" component={WindowWidthScreen} /> |
| 90 | + <Route path="/todo-list" component={TodoList} /> |
| 91 | + <Route path="/sortable" component={SortableScreen} /> |
| 92 | + <Route path="/concurrent1" component={Concurrent1} /> |
| 93 | + <Route path="/concurrent2" component={Concurrent2} /> |
| 94 | + <Route path="/concurrent3" component={Concurrent3} /> |
| 95 | + <Route path="/concurrent3-after" component={Concurrent3After} /> |
57 | 96 | </div>
|
58 |
| - </Router> |
59 |
| - ) |
| 97 | + </div> |
| 98 | + </Router>; |
60 | 99 | }
|
61 | 100 |
|
62 | 101 | export default App;
|
0 commit comments