Create a Trivia Game using ReactJS
Quizzical
is a Trivia game implemented in ReactJS
by Harmeet Matharoo and Habib ur rehman Bhatti. While creating this project I learned about Event Listeners in React
, React State
, Conditional Rendering in React
, React Hooks(useEffect)
, etc. A player is given 5 random questions with 4 choices each. Trivia questions are retrieved from Open Trivia Database API. A participant can validate their answers and can play as many times as they want. Have Fun 😄. After creating the project, it was deployed to GitHub Pages
🐦 Feel free to reach me onTwitter 👾
- Open Trivia Database API
- ReactJS
- create-react-app
- Figma Design Template
- Event Listeners in React
- React State
- Conditional Rendering in React
- React Hooks(useEffect)
- github-pages
### Clone the repository using GitHub CLI
gh repo clone hmjatt/Quizzical
### Go to the quizzical folder
cd quizzical
### Install Dependencies
npm install
### Starts the Development Server(App will open in a new window)
npm start
- Initialize the project using
npx create-react-app quizzical
which will create a complete React App pre-configured and pre-installed with all the dependencies. - Import
Work Sans
font from google fonts and apply it to theApp
component.
- Create a
components
folder for custom components inside thesrc
directory. - Create a
styles
folder inside thesrc
directory and move.css
files inside it.
- Delete unnecessary files.
- Create a
tests
folder inside thesrc
directory and move.test.js
files inside it. - Delete unnecessary code.
-
Create an
App
component and basic JSX elements for it. -
Add appropriate
className
s to elements in theApp
component. -
Import
App
component insideindex.js
. -
Add styles to
body
insideindex.css
. -
Style
App
component by editingApp.css
. And also addblob
elements toApp
component
- Create a
Quiz
component, basic JSX elements for it and import it inApp
component.
- Create
Footer
component and basic JSX elements for it. - Import
Footer
component insideApp
component. - Style
Footer
component.
- When
Start Quiz
button is clicked, conditionally renderQuiz
component.
- Add elements to
Quiz
component. - Style elements in
Quiz
component. - Make it responsive.
-
Change code inside
Quiz
component, so that multiple options can be selected for a playthrough but only one option to be selected per question. Can be easily done by convertingbuttons
toradio inputs
and applying some styles.
- Add link to
Habib ur rehman Bhatti
's GitHub in footer as he finished points#11
and#12
. Thanks friend 😄 and looking forward to colaborate with you in future projects, learned a lot while doing this project.
- Fetch data from
Trivia API
. - Replace psuedo questions with the fetched questions.
- Replace psuedo answers with the fetched answers.
- Add loading animation while fetching data.
- Randomize the order of answers.
-
Add logic to check if answer is correct or not.
-
Save the score in a variable.
-
Display the score in when the
Submit
button is clicked. -
Replace the
Submit
button withPlay Again
button when theSubmit
button is clicked. -
Change background color if the answer is correct or wrong.
-
Render the score component.
-
Add logic to reset the score when the
Play Again
button is clicked.
- Change Absolute units to Relative.
- Make App responsive for mobile by adding
media query
. 😃
- Delete unnecessary files from directory and format code with
Prettier
. - Test for Responsiveness and make changes if need be.
- Add links to
Live Preview
and screenshots.
- Use Official Documentation(link) to push the project to GitHub Pages 🎆🎆🎆
- Allow players to select category of trivia questions.
- Allow players to select difficulty of trivia questions.
- Divide Quiz Component into smaller components.
- Use Styled Components and CSS Modules to tidy up CSS.
-
The Odin Project
-
Figma Design
-
Scrimba
-
React Official Documentation
-
Trivia API
“All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use a hammer."
— IBM Manual, 1925
💭✅🍂