├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js ├── App.test.js ├── Group 3.svg ├── components ├── Contact.js ├── Main.js └── Thanks.js ├── hero.svg ├── index.css ├── index.js ├── logo.svg ├── routes.js ├── serviceWorker.js └── setupTests.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "new-react-router", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.4.1", 8 | "@testing-library/user-event": "^7.2.1", 9 | "react": "^16.13.0", 10 | "react-dom": "^16.13.0", 11 | "react-router-dom": "^5.1.2", 12 | "react-scripts": "3.4.0" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": "react-app" 22 | }, 23 | "browserslist": { 24 | "production": [ 25 | ">0.2%", 26 | "not dead", 27 | "not op_mini all" 28 | ], 29 | "development": [ 30 | "last 1 chrome version", 31 | "last 1 firefox version", 32 | "last 1 safari version" 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AldoHub/React-Router-Hooks/d22ad028b781a52f6f2896fef783124448576e34/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AldoHub/React-Router-Hooks/d22ad028b781a52f6f2896fef783124448576e34/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AldoHub/React-Router-Hooks/d22ad028b781a52f6f2896fef783124448576e34/public/logo512.png -------------------------------------------------------------------------------- /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 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import Routes from "./routes"; 3 | import { Link, useHistory } from "react-router-dom"; 4 | 5 | function App() { 6 | 7 | const history = useHistory(); 8 | const [path, setPath] = useState(""); 9 | 10 | window.addEventListener("load", () => { 11 | 12 | if(window.location.pathname === "/contact"){ 13 | setPath(window.location.pathname); 14 | } 15 | }); 16 | 17 | 18 | const checkPath = () => { 19 | history.listen((location) => { 20 | setPath(location.pathname); 21 | }); 22 | } 23 | 24 | 25 | useEffect(() => { 26 | checkPath(); 27 | }, []); 28 | 29 | 30 | const showContact = path; 31 | let _contact; 32 | if(showContact !== "/contact"){ 33 | _contact = (
  • Contact Me
  • ) 34 | } 35 | 36 | 37 | return ( 38 |
    39 |
    40 | 48 | 49 |
    50 |
    51 | ); 52 | } 53 | 54 | export default App; 55 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/Group 3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/components/Contact.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from "react"; 2 | import { useHistory } from "react-router-dom"; 3 | 4 | const Contact = () => { 5 | 6 | const history = useHistory(); 7 | const goBack = () => { 8 | history.goBack(); 9 | } 10 | 11 | const [title, setTitle] = useState(""); 12 | const [content, setContent] = useState(""); 13 | const [contactEmail, setContactEmail] = useState(""); 14 | 15 | const sendEmail = async(e) =>{ 16 | e.preventDefault(); 17 | 18 | let email = { 19 | title, 20 | content, 21 | contactEmail 22 | } 23 | 24 | console.log("sending email", email); 25 | } 26 | 27 | 28 | return( 29 | 30 | 31 | 32 |
    33 |

    Send me a message so we can start a new project

    34 | 35 | 36 | setTitle(e.target.value)} /> 37 | 38 | 39 | 40 | 41 | 42 | setContactEmail(e.target.value)} /> 43 | 44 | 45 |
    46 | 47 |
    48 | ) 49 | 50 | } 51 | 52 | 53 | export default Contact; -------------------------------------------------------------------------------- /src/components/Main.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from "react"; 2 | import hero from "../hero.svg"; 3 | import { Link, useHistory } from "react-router-dom"; 4 | 5 | const Main = () => { 6 | 7 | const [joined, setJoined] = useState(""); 8 | const history = useHistory(); 9 | 10 | 11 | const join = (e) =>{ 12 | e.preventDefault(); 13 | if(joined !== ""){ 14 | let today = new Date(); 15 | let date = today.getFullYear()+ '-' +(today.getMonth()+1) + '-' + today.getDate(); 16 | history.push(`/thanks/${joined}`, date ); 17 | } 18 | 19 | } 20 | 21 | 22 | 23 | return( 24 | 25 |
    26 | 27 |
    28 |

    We build & design
    web applications.

    29 |

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin luctus congue dignissim. Vestibulum et ex nisl. Vestibulum eu luctus nisi. Fusce sit amet vehicula nisl.

    30 | Get in touch 31 |
    32 | 33 |
    34 | 35 | 36 |
    37 |
    38 |

    Why we should work together?

    39 | 40 |
    41 |
    42 |
    43 | 44 |

    SEO Friendly Apps.

    45 |
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tincidunt massa sem. Vestibulum quis augue ac orci bibendum pellentesque ut nec dolor. Quisque metus ipsum, pulvinar quis ipsum quis, consequat cursus leo. Suspendisse fermentum, nisl et ultricies blandit, mauris metus accumsan mauris, sit amet vulputate elit nunc id libero. Vivamus porta lacus libero, et ullamcorper est volutpat ac. Maecenas eros urna, interdum in lectus nec, tristique semper mauris. Duis finibus nunc sed nulla bibendum, ut ornare tellus finibus. Donec id magna risus.
    46 | 47 |
    48 |
    49 | 50 | 51 | 52 |
    53 | 54 |
    55 |
    56 |

    Clear & Optimized Code.

    57 |
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tincidunt massa sem. Vestibulum quis augue ac orci bibendum pellentesque ut nec dolor. Quisque metus ipsum, pulvinar quis ipsum quis, consequat cursus leo. Suspendisse fermentum, nisl et ultricies blandit, mauris metus accumsan mauris, sit amet vulputate elit nunc id libero. Vivamus porta lacus libero, et ullamcorper est volutpat ac. Maecenas eros urna, interdum in lectus nec, tristique semper mauris. Duis finibus nunc sed nulla bibendum, ut ornare tellus finibus. Donec id magna risus.
    58 |
    59 |
    60 | 61 | 62 | 63 |
    64 |
    65 |
    66 |

    Support 24 hours.

    67 |
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tincidunt massa sem. Vestibulum quis augue ac orci bibendum pellentesque ut nec dolor. Quisque metus ipsum, pulvinar quis ipsum quis, consequat cursus leo. Suspendisse fermentum, nisl et ultricies blandit, mauris metus accumsan mauris, sit amet vulputate elit nunc id libero. Vivamus porta lacus libero, et ullamcorper est volutpat ac. Maecenas eros urna, interdum in lectus nec, tristique semper mauris. Duis finibus nunc sed nulla bibendum, ut ornare tellus finibus. Donec id magna risus.
    68 |
    69 | 70 |
    71 |
    72 | 73 |
    74 |

    Join our newsletter to get the latest trends.

    75 | 76 |
    77 | setJoined(e.target.value)} /> 78 | 79 |
    80 | 81 |
    82 |
    83 | 84 | 85 |
    86 | ) 87 | } 88 | 89 | 90 | export default Main; -------------------------------------------------------------------------------- /src/components/Thanks.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from "react"; 2 | import { useParams, useHistory } from "react-router-dom"; 3 | 4 | const Thanks = () => { 5 | 6 | const history = useHistory(); 7 | const { name } = useParams(); 8 | 9 | console.log(history); 10 | 11 | 12 | return( 13 | 14 |
    15 |

    Thanks {name}!!

    16 |

    You joined {history.location.state}

    17 | 18 |
    19 |

    Disclaimer : Duis ullamcorper erat nisl, vel blandit sem mollis eu. Sed ac fringilla mi. Maecenas a mi nibh. Vestibulum ut sapien magna. Vivamus vitae nunc eu odio suscipit pulvinar. Duis tortor quam, lacinia eget justo in, vulputate vulputate mi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae

    20 | 21 |
    22 |
    23 | ) 24 | 25 | } 26 | 27 | 28 | export default Thanks; -------------------------------------------------------------------------------- /src/hero.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Lato&display=swap'); 2 | 3 | html { 4 | background: rgb(236, 244, 255) ; 5 | } 6 | 7 | body { 8 | margin: 0; 9 | padding: 0px; 10 | font-family: Lato, sans-serif; 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | overflow-x: hidden; 14 | padding-bottom: 320px; 15 | background-image: url("./Group 3.svg"); 16 | background-position: bottom; 17 | background-repeat: no-repeat; 18 | } 19 | 20 | body * { 21 | transition: all 500ms ease-in-out; 22 | } 23 | 24 | 25 | .container { 26 | width: 80%; 27 | margin: 0 auto; 28 | 29 | } 30 | 31 | 32 | 33 | nav { 34 | display: flex; 35 | align-items: center; 36 | width: 100%; 37 | padding-top: 10px; 38 | margin: 0 auto; 39 | justify-content: space-between; 40 | color: #111; 41 | } 42 | 43 | nav ul { 44 | list-style: none; 45 | padding: 0px; 46 | margin: 10px 0px; 47 | } 48 | 49 | nav ul li a { 50 | text-decoration: none; 51 | color: #111; 52 | } 53 | 54 | nav ul li { 55 | display: inline-block; 56 | margin-left: 10px; 57 | } 58 | 59 | nav ul:first-of-type li:first-of-type{ 60 | font-weight: bold; 61 | font-size: 1.1rem; 62 | } 63 | 64 | 65 | 66 | header { 67 | position: relative; 68 | } 69 | 70 | 71 | header div { 72 | padding-top: 150px; 73 | 74 | } 75 | 76 | header div h1 { 77 | font-size: 75px; 78 | } 79 | 80 | header div p { 81 | width: 550px; 82 | font-size: 20px; 83 | line-height: 28px; 84 | } 85 | 86 | header img { 87 | position: absolute; 88 | z-index: -1; 89 | width: 1630px; 90 | right: -50%; 91 | top: -20px; 92 | } 93 | 94 | header div a { 95 | padding: 20px; 96 | display: block; 97 | margin-top: 70px; 98 | width: 170px; 99 | border-radius: 40px; 100 | color: #eee; 101 | font-size: 20px; 102 | text-align: center; 103 | text-decoration: none; 104 | } 105 | 106 | header div a, .newsletter input[type="submit"] { 107 | border: 1px solid blue; 108 | color: blue; 109 | } 110 | 111 | header div a:hover, .newsletter input[type="submit"]:hover { 112 | background: blue; 113 | color: #eee; 114 | } 115 | 116 | main { 117 | padding-top: 100px; 118 | } 119 | 120 | h2 { 121 | font-size: 45px; 122 | margin-bottom: 120px; 123 | 124 | } 125 | 126 | h3 { 127 | font-size: 30px; 128 | color: rgb(12, 0, 116); 129 | } 130 | 131 | 132 | 133 | .services { 134 | margin-top: 300px; 135 | } 136 | 137 | .service-container { 138 | display: flex; 139 | flex-wrap: wrap; 140 | justify-content: space-around; 141 | align-items: center; 142 | margin: 40px 0px 180px 0px; 143 | position: relative; 144 | } 145 | 146 | 147 | .services-card { 148 | width: 40%; 149 | height: 400px; 150 | background: #222; 151 | display: inline-block; 152 | border-radius: 10px; 153 | -webkit-box-shadow: 0px 0px 52px -19px rgba(0,0,0,0.75); 154 | -moz-box-shadow: 0px 0px 52px -19px rgba(0,0,0,0.75); 155 | box-shadow: 0px 0px 52px -19px rgba(0,0,0,0.75); 156 | } 157 | 158 | .service-description{ 159 | width: 40%; 160 | 161 | } 162 | 163 | .service-one { 164 | background: url("https://images.unsplash.com/photo-1581094648468-20624f9c771a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80")center; 165 | } 166 | 167 | .service-two { 168 | background: url("https://images.unsplash.com/photo-1581091870619-835cee86e759?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80")center; 169 | } 170 | 171 | .service-three { 172 | background: url("https://images.unsplash.com/photo-1427751840561-9852520f8ce8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=755&q=80")center; 173 | } 174 | 175 | 176 | .newsletter { 177 | width: 80%; 178 | margin: 0 auto; 179 | text-align: center; 180 | } 181 | 182 | .newsletter * { 183 | padding: 20px; 184 | border-radius: 40px; 185 | border: none; 186 | margin: 0px; 187 | background: none; 188 | font-size: 20px; 189 | 190 | } 191 | 192 | .newsletter input[type="email"] { 193 | width: 60%; 194 | display: inline-block; 195 | border: 1px solid #222; 196 | 197 | margin-right: 20px; 198 | 199 | } 200 | 201 | .newsletter input[type="submit"]{ 202 | width: 170px; 203 | color: blue; 204 | 205 | cursor: pointer; 206 | } 207 | 208 | .thanks { 209 | font-size: 30px; 210 | width:70%; 211 | margin: 120px auto; 212 | text-align: center; 213 | } 214 | 215 | .contact { 216 | width: 60%; 217 | margin: 0 auto; 218 | max-width: 900px; 219 | 220 | } 221 | 222 | .contact * { 223 | width: 100%; 224 | padding: 20px 0px; 225 | display: block; 226 | border-radius: 10px; 227 | } 228 | .contact input, .contact textarea { 229 | text-indent: 30px; 230 | border: 1px solid #eee; 231 | } 232 | 233 | .contact input[type="submit"] { 234 | background: blue; 235 | width: 30%; 236 | text-indent: 0px; 237 | color: #eee; 238 | font-size: 20px; 239 | border-radius: 40px; 240 | margin: 40px 0px 0px auto; 241 | } 242 | 243 | .back { 244 | background: none; 245 | padding: 10px; 246 | border: none; 247 | border-bottom: 3px solid blue; 248 | font-size: 14px; 249 | margin-top: 50px; 250 | cursor: pointer; 251 | color: blue; 252 | } 253 | 254 | @media screen and (max-width: 1600px){ 255 | header img { 256 | width: 1230px; 257 | right: -50%; 258 | top: -20px; 259 | } 260 | } 261 | 262 | 263 | @media screen and (max-width: 1380px){ 264 | header img { 265 | right: -66%; 266 | top: -20px; 267 | } 268 | 269 | header div { 270 | padding-top: 100px; 271 | } 272 | header div h1 { 273 | font-size: 55px; 274 | } 275 | 276 | header div p { 277 | width: 400px; 278 | } 279 | 280 | } 281 | 282 | @media screen and (max-width: 1150px){ 283 | header img { 284 | width: 900px; 285 | right: -50%; 286 | top: 320px; 287 | } 288 | 289 | 290 | header div h1 { 291 | font-size: 55px; 292 | } 293 | 294 | header div p { 295 | width: 400px; 296 | } 297 | 298 | .service-container { 299 | display: block; 300 | } 301 | 302 | .services-card { 303 | width: 100%; 304 | height: 400px; 305 | } 306 | 307 | .service-description{ 308 | width: 100%; 309 | 310 | } 311 | 312 | .service-one, .service-two, .service-three{ 313 | background-size: 120% !important; 314 | } 315 | 316 | .contact input[type="submit"] { 317 | width: 40%; 318 | } 319 | 320 | } 321 | 322 | @media screen and (max-width: 950px) { 323 | 324 | header img { 325 | width: 730px; 326 | right: -50%; 327 | top: 520px; 328 | } 329 | 330 | .newsletter { 331 | width: 100%; 332 | } 333 | .newsletter input[type="email"] { 334 | width: 100%; 335 | margin-right: 0px; 336 | 337 | } 338 | 339 | .newsletter input[type="submit"]{ 340 | margin-top: 40px; 341 | 342 | } 343 | 344 | .contact { 345 | width: 90%; 346 | } 347 | 348 | .contact input[type="submit"] { 349 | 350 | width: 100%; 351 | margin: 40px 0px; 352 | } 353 | 354 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | import { BrowserRouter } from "react-router-dom"; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , document.getElementById('root')); 12 | 13 | // If you want your app to work offline and load faster, you can change 14 | // unregister() to register() below. Note this comes with some pitfalls. 15 | // Learn more about service workers: https://bit.ly/CRA-PWA 16 | serviceWorker.unregister(); 17 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/routes.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Switch, Route } from "react-router-dom"; 3 | 4 | //components 5 | import Main from "./components/Main"; 6 | import Contact from "./components/Contact"; 7 | import Thanks from "./components/Thanks"; 8 | 9 | 10 | const Routes = () => ( 11 | 12 | 13 | 14 | 15 | 16 | ); 17 | 18 | export default Routes; 19 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' } 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | --------------------------------------------------------------------------------