Showing
24 changed files
with
374 additions
and
0 deletions
final/README.md
0 → 100644
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 | +### `yarn start` | ||
8 | + | ||
9 | +Runs the app in the development mode.<br /> | ||
10 | +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
11 | + | ||
12 | +The page will reload if you make edits.<br /> | ||
13 | +You will also see any lint errors in the console. | ||
14 | + | ||
15 | +### `yarn test` | ||
16 | + | ||
17 | +Launches the test runner in the interactive watch mode.<br /> | ||
18 | +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
19 | + | ||
20 | +### `yarn build` | ||
21 | + | ||
22 | +Builds the app for production to the `build` folder.<br /> | ||
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.<br /> | ||
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 | +### `yarn 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 | +### `yarn 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 |
File moved
No preview for this file type
File moved
File moved
final/src/App.js
0 → 100644
1 | +import React, { useState } from 'react'; | ||
2 | + | ||
3 | +export default function App() { | ||
4 | + const questions = [ | ||
5 | + { | ||
6 | + questionText: 'What is the capital of France?', | ||
7 | + answerOptions: [ | ||
8 | + { answerText: 'New York', isCorrect: false }, | ||
9 | + { answerText: 'London', isCorrect: false }, | ||
10 | + { answerText: 'Paris', isCorrect: true }, | ||
11 | + { answerText: 'Dublin', isCorrect: false }, | ||
12 | + ], | ||
13 | + }, | ||
14 | + { | ||
15 | + questionText: 'Who is CEO of Tesla?', | ||
16 | + answerOptions: [ | ||
17 | + { answerText: 'Jeff Bezos', isCorrect: false }, | ||
18 | + { answerText: 'Elon Musk', isCorrect: true }, | ||
19 | + { answerText: 'Bill Gates', isCorrect: false }, | ||
20 | + { answerText: 'Tony Stark', isCorrect: false }, | ||
21 | + ], | ||
22 | + }, | ||
23 | + { | ||
24 | + questionText: 'The iPhone was created by which company?', | ||
25 | + answerOptions: [ | ||
26 | + { answerText: 'Apple', isCorrect: true }, | ||
27 | + { answerText: 'Intel', isCorrect: false }, | ||
28 | + { answerText: 'Amazon', isCorrect: false }, | ||
29 | + { answerText: 'Microsoft', isCorrect: false }, | ||
30 | + ], | ||
31 | + }, | ||
32 | + { | ||
33 | + questionText: 'How many Harry Potter books are there?', | ||
34 | + answerOptions: [ | ||
35 | + { answerText: '1', isCorrect: false }, | ||
36 | + { answerText: '4', isCorrect: false }, | ||
37 | + { answerText: '6', isCorrect: false }, | ||
38 | + { answerText: '7', isCorrect: true }, | ||
39 | + ], | ||
40 | + }, | ||
41 | + ]; | ||
42 | + | ||
43 | + const [currentQuestion, setCurrentQuestion] = useState(0); | ||
44 | + const [showScore, setShowScore] = useState(false); | ||
45 | + const [score, setScore] = useState(0); | ||
46 | + | ||
47 | + const handleAnswerOptionClick = (isCorrect) => { | ||
48 | + if (isCorrect) { | ||
49 | + setScore(score + 1); | ||
50 | + } | ||
51 | + | ||
52 | + const nextQuestion = currentQuestion + 1; | ||
53 | + if (nextQuestion < questions.length) { | ||
54 | + setCurrentQuestion(nextQuestion); | ||
55 | + } else { | ||
56 | + setShowScore(true); | ||
57 | + } | ||
58 | + }; | ||
59 | + return ( | ||
60 | + <div className='app'> | ||
61 | + {showScore ? ( | ||
62 | + <div className='score-section'> | ||
63 | + You scored {score} out of {questions.length} | ||
64 | + </div> | ||
65 | + ) : ( | ||
66 | + <> | ||
67 | + <div className='question-section'> | ||
68 | + <div className='question-count'> | ||
69 | + <span>Question {currentQuestion + 1}</span>/{questions.length} | ||
70 | + </div> | ||
71 | + <div className='question-text'>{questions[currentQuestion].questionText}</div> | ||
72 | + </div> | ||
73 | + <div className='answer-section'> | ||
74 | + {questions[currentQuestion].answerOptions.map((answerOption) => ( | ||
75 | + <button onClick={() => handleAnswerOptionClick(answerOption.isCorrect)}>{answerOption.answerText}</button> | ||
76 | + ))} | ||
77 | + </div> | ||
78 | + </> | ||
79 | + )} | ||
80 | + </div> | ||
81 | + ); | ||
82 | +} |
File moved
File moved
final/yarn.lock
0 → 100644
This diff could not be displayed because it is too large.
File moved
starter/package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
starter/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "quiz-app-starter", | ||
3 | + "version": "0.1.0", | ||
4 | + "private": true, | ||
5 | + "dependencies": { | ||
6 | + "@testing-library/jest-dom": "^4.2.4", | ||
7 | + "@testing-library/react": "^9.3.2", | ||
8 | + "@testing-library/user-event": "^7.1.2", | ||
9 | + "react": "^16.13.1", | ||
10 | + "react-dom": "^16.13.1", | ||
11 | + "react-scripts": "3.4.3" | ||
12 | + }, | ||
13 | + "scripts": { | ||
14 | + "start": "react-scripts start", | ||
15 | + "build": "react-scripts build", | ||
16 | + "test": "react-scripts test", | ||
17 | + "eject": "react-scripts eject" | ||
18 | + }, | ||
19 | + "eslintConfig": { | ||
20 | + "extends": "react-app" | ||
21 | + }, | ||
22 | + "browserslist": { | ||
23 | + "production": [ | ||
24 | + ">0.2%", | ||
25 | + "not dead", | ||
26 | + "not op_mini all" | ||
27 | + ], | ||
28 | + "development": [ | ||
29 | + "last 1 chrome version", | ||
30 | + "last 1 firefox version", | ||
31 | + "last 1 safari version" | ||
32 | + ] | ||
33 | + } | ||
34 | +} |
starter/public/favicon.ico
0 → 100644
No preview for this file type
starter/public/index.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html lang="en"> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8" /> | ||
5 | + <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
6 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
7 | + <meta name="theme-color" content="#000000" /> | ||
8 | + <meta | ||
9 | + name="description" | ||
10 | + content="Web site created using create-react-app" | ||
11 | + /> | ||
12 | + <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
13 | + <!-- | ||
14 | + manifest.json provides metadata used when your web app is installed on a | ||
15 | + user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
16 | + --> | ||
17 | + <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
18 | + <!-- | ||
19 | + Notice the use of %PUBLIC_URL% in the tags above. | ||
20 | + It will be replaced with the URL of the `public` folder during the build. | ||
21 | + Only files inside the `public` folder can be referenced from the HTML. | ||
22 | + | ||
23 | + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
24 | + work correctly both with client-side routing and a non-root public URL. | ||
25 | + Learn how to configure a non-root public URL by running `npm run build`. | ||
26 | + --> | ||
27 | + <title>React App</title> | ||
28 | + </head> | ||
29 | + <body> | ||
30 | + <noscript>You need to enable JavaScript to run this app.</noscript> | ||
31 | + <div id="root"></div> | ||
32 | + <!-- | ||
33 | + This HTML file is a template. | ||
34 | + If you open it directly in the browser, you will see an empty page. | ||
35 | + | ||
36 | + You can add webfonts, meta tags, or analytics to this file. | ||
37 | + The build step will place the bundled scripts into the <body> tag. | ||
38 | + | ||
39 | + To begin the development, run `npm start` or `yarn start`. | ||
40 | + To create a production bundle, use `npm run build` or `yarn build`. | ||
41 | + --> | ||
42 | + </body> | ||
43 | +</html> |
starter/public/logo192.png
0 → 100644
5.22 KB
starter/public/logo512.png
0 → 100644
9.44 KB
starter/public/manifest.json
0 → 100644
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 | +} |
starter/public/robots.txt
0 → 100644
File moved
starter/src/index.css
0 → 100644
1 | +body { | ||
2 | + margin: 0; | ||
3 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
4 | + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
5 | + sans-serif; | ||
6 | + -webkit-font-smoothing: antialiased; | ||
7 | + -moz-osx-font-smoothing: grayscale; | ||
8 | +} | ||
9 | +* { | ||
10 | + font-family: "Verdana", cursive, sans-serif; | ||
11 | + color: #ffffff; | ||
12 | +} | ||
13 | + | ||
14 | +body { | ||
15 | + background-color: #7cc6fe; | ||
16 | + display: flex; | ||
17 | + justify-content: center; | ||
18 | + align-items: center; | ||
19 | + min-height: 100vh; | ||
20 | +} | ||
21 | + | ||
22 | +.app { | ||
23 | + background-color: #252d4a; | ||
24 | + width: 450px; | ||
25 | + min-height: 200px; | ||
26 | + height: min-content; | ||
27 | + border-radius: 15px; | ||
28 | + padding: 20px; | ||
29 | + box-shadow: 10px 10px 42px 0px rgba(0, 0, 0, 0.75); | ||
30 | + display: flex; | ||
31 | + justify-content: space-evenly; | ||
32 | +} | ||
33 | + | ||
34 | +.score-section { | ||
35 | + display: flex; | ||
36 | + font-size: 24px; | ||
37 | + align-items: center; | ||
38 | +} | ||
39 | + | ||
40 | +/* QUESTION/TIMER/LEFT SECTION */ | ||
41 | +.question-section { | ||
42 | + width: 100%; | ||
43 | + position: relative; | ||
44 | +} | ||
45 | + | ||
46 | +.question-count { | ||
47 | + margin-bottom: 20px; | ||
48 | +} | ||
49 | + | ||
50 | +.question-count span { | ||
51 | + font-size: 28px; | ||
52 | +} | ||
53 | + | ||
54 | +.question-text { | ||
55 | + margin-bottom: 12px; | ||
56 | +} | ||
57 | + | ||
58 | +.timer-text { | ||
59 | + background: rgb(230, 153, 12); | ||
60 | + padding: 15px; | ||
61 | + margin-top: 20px; | ||
62 | + margin-right: 20px; | ||
63 | + border: 5px solid rgb(255, 189, 67); | ||
64 | + border-radius: 15px; | ||
65 | + text-align: center; | ||
66 | +} | ||
67 | + | ||
68 | +/* ANSWERS/RIGHT SECTION */ | ||
69 | +.answer-section { | ||
70 | + width: 100%; | ||
71 | + display: flex; | ||
72 | + flex-direction: column; | ||
73 | + justify-content: space-between; | ||
74 | +} | ||
75 | + | ||
76 | +button { | ||
77 | + width: 100%; | ||
78 | + font-size: 16px; | ||
79 | + color: #ffffff; | ||
80 | + background-color: #252d4a; | ||
81 | + border-radius: 15px; | ||
82 | + display: flex; | ||
83 | + padding: 5px; | ||
84 | + justify-content: flex-start; | ||
85 | + align-items: center; | ||
86 | + border: 5px solid #234668; | ||
87 | + cursor: pointer; | ||
88 | +} | ||
89 | + | ||
90 | +.correct { | ||
91 | + background-color: #2f922f; | ||
92 | +} | ||
93 | + | ||
94 | +.incorrect { | ||
95 | + background-color: #ff3333; | ||
96 | +} | ||
97 | + | ||
98 | +button:hover { | ||
99 | + background-color: #555e7d; | ||
100 | +} | ||
101 | + | ||
102 | +button:focus { | ||
103 | + outline: none; | ||
104 | +} | ||
105 | + | ||
106 | +button svg { | ||
107 | + margin-right: 5px; | ||
108 | +} |
-
Please register or login to post a comment