├── README.md └── react-router ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── src ├── App.js ├── components │ ├── About.js │ ├── Card.js │ ├── Contact.js │ ├── Home.js │ ├── Modal.css │ ├── Modal.js │ └── Navbar.js └── index.js └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | # react-router 2 | 3 | Make sure you have node.js install. 4 | * Open up a command line terminal. 5 | * Navigate to the directory containing the source code. 6 | * Execute `yarn install` to install node.js modules. 7 | * Execute `yarn start` to start a local web server. 8 | -------------------------------------------------------------------------------- /react-router/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /react-router/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-router", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^16.8.6", 7 | "react-dom": "^16.8.6", 8 | "react-router-dom": "^5.0.1", 9 | "react-scripts": "3.0.1" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test", 15 | "eject": "react-scripts eject" 16 | }, 17 | "eslintConfig": { 18 | "extends": "react-app" 19 | }, 20 | "browserslist": { 21 | "production": [ 22 | ">0.2%", 23 | "not dead", 24 | "not op_mini all" 25 | ], 26 | "development": [ 27 | "last 1 chrome version", 28 | "last 1 firefox version", 29 | "last 1 safari version" 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /react-router/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OakAcademy/react-router/299a74460e0e1f8fd0fdf752aa588993abf03988/react-router/public/favicon.ico -------------------------------------------------------------------------------- /react-router/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 23 | React App 24 | 25 | 26 | 27 |
28 | 29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /react-router/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /react-router/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { BrowserRouter, Route, Switch } from 'react-router-dom'; 3 | import Navbar from './components/Navbar'; 4 | import Home from './components/Home'; 5 | import About from './components/About'; 6 | import Contact from './components/Contact'; 7 | import Card from './components/Card'; 8 | 9 | function App() { 10 | return ( 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | ); 23 | } 24 | 25 | export default App; 26 | -------------------------------------------------------------------------------- /react-router/src/components/About.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Modal.css'; 3 | 4 | const About = () => { 5 | return( 6 |
7 |
8 |
9 |

I am a modal

10 |
11 |
12 |
16 |

About

17 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

18 |
19 |
20 | ) 21 | } 22 | 23 | export default About; -------------------------------------------------------------------------------- /react-router/src/components/Card.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | class Card extends React.Component { 4 | 5 | state = { user: '' } 6 | 7 | componentDidMount() { 8 | let user = this.props.match.params.user 9 | this.setState({ user }) 10 | } 11 | 12 | render() { 13 | const { user } = this.state 14 | return( 15 |
19 |

{ user }

20 |
21 | ) 22 | } 23 | } 24 | 25 | export default Card; -------------------------------------------------------------------------------- /react-router/src/components/Contact.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | import Modal from './Modal'; 4 | 5 | const Contact = () => { 6 | return( 7 |
8 | 9 |
13 | Alex 14 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

15 |
16 |
20 | Willma 21 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

22 |
23 |
24 | ) 25 | } 26 | 27 | 28 | export default Contact; -------------------------------------------------------------------------------- /react-router/src/components/Home.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Home = () => { 4 | return( 5 |
9 |

Home

10 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

11 |
12 | ) 13 | } 14 | 15 | export default Home; -------------------------------------------------------------------------------- /react-router/src/components/Modal.css: -------------------------------------------------------------------------------- 1 | .modal { 2 | height: 100%; 3 | width: 100%; 4 | position: fixed; 5 | background-color: grey; 6 | top: 0; 7 | left: 0; 8 | opacity: .9; 9 | z-index: 10; 10 | } 11 | 12 | .modal-content { 13 | background-color: white; 14 | margin: 300px auto; 15 | height: 40%; 16 | width: 40%; 17 | text-align: center; 18 | } 19 | 20 | .wrapper { 21 | position: relative; 22 | z-index: 0; 23 | } -------------------------------------------------------------------------------- /react-router/src/components/Modal.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | 4 | const Modal = (props) => { 5 | 6 | return ReactDOM.createPortal( 7 |
8 |
9 |

I am a modal

10 |
11 |
, 12 | document.querySelector('#modal') 13 | ) 14 | 15 | } 16 | 17 | export default Modal; -------------------------------------------------------------------------------- /react-router/src/components/Navbar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, NavLink, withRouter } from 'react-router-dom'; 3 | 4 | const Navbar = (props) => { 5 | return( 6 | 14 | ) 15 | } 16 | 17 | export default withRouter(Navbar); -------------------------------------------------------------------------------- /react-router/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | --------------------------------------------------------------------------------