-
Notifications
You must be signed in to change notification settings - Fork 430
survey #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
survey #450
Changes from all commits
dc16c84
a2980d5
ed5d754
cd88f1b
60e8312
ac0e9a3
bac98ee
f6ba655
9caf8e7
7022f5e
0e40f45
aa6010a
b6ca087
5f2fec1
caf70bb
3f3e531
9cd2419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,92 @@ | ||
| import React from 'react'; | ||
| /* eslint-disable max-len */ | ||
| import React, { useState } from 'react'; | ||
| import { Name } from './components/Name'; | ||
| import { Prefer } from './components/Prefer'; | ||
| import { Color } from './components/Color'; | ||
| import { Thing } from './components/Thing'; | ||
| import { QuizResult } from './components/QuizResult' | ||
| import './index.css'; | ||
| import './reset.css'; | ||
|
|
||
| export const App = () => { | ||
| const [counter, setCounter] = useState(0); | ||
| const [name, setName] = useState('') | ||
| const [prefers, setPrefers] = useState('') | ||
| const [color, setColor] = useState('') | ||
| const [things, setThing] = useState('') | ||
| const [results, setResults] = useState('') | ||
| const [started, setStarted] = useState(false); | ||
|
|
||
| const handleNextStep = () => { | ||
| console.log('counter before', counter); | ||
| setCounter(counter + 1); | ||
| console.log('after', counter) | ||
| }; | ||
| const handleStartQuiz = () => { | ||
| setStarted(true); | ||
| handleNextStep(); | ||
| /* if (counter >= 5) { | ||
| setQuizEnded(true); | ||
| } */ | ||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to remove code that is commented out if it's not needed |
||
| }; | ||
| const showResult = ( | ||
| <QuizResult name={name} results={results} /> | ||
| ) | ||
| return ( | ||
| <div> | ||
| Find me in src/app.js! | ||
| </div> | ||
| <main className="StartPage"> | ||
| {!started && ( | ||
| <header className="start-container"> | ||
| <h1>Answer these questions and we will tell you your favourite animal</h1> | ||
| <button type="button" onClick={handleStartQuiz} className="startBtn" aria-label="press button to start the quiz"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great use of Aria labels |
||
| Start quiz | ||
| </button> | ||
| </header> | ||
| )} | ||
|
|
||
| {counter === 1 && ( | ||
| <div> | ||
| <Name name={name} setName={setName} counterFromApp={counter} setCounter={setCounter} /> | ||
|
|
||
| </div>)} | ||
|
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look into if a div is needed here |
||
|
|
||
| {counter === 2 && ( | ||
| <Prefer prefers={prefers} setPrefers={setPrefers} counterFromApp={counter} setCounter={setCounter} /> | ||
| )} | ||
| {counter === 3 && ( | ||
| <Color color={color} setColor={setColor} counterFromApp={counter} setCounter={setCounter} /> | ||
| )} | ||
| {counter === 4 && ( | ||
| <Thing thing={things} setThing={setThing} counterFromApp={counter} setCounter={setCounter} /> | ||
| )} | ||
| {counter >= 5 && ( | ||
| <QuizResult name={name} color={color} prefer={prefers} thing={things} results={results} setResults={setResults} QuizResult={QuizResult} /> | ||
| )} | ||
|
|
||
| {(counter === 1 && !name) | ||
| || (counter === 2 && !prefers) | ||
| || (counter === 3 && !color) | ||
| || (counter === 4 && !things) ? ( | ||
| <p className="answer">Please answer the current question before proceeding.</p> | ||
|
Comment on lines
+65
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe there could be either just a comment here or it could be turned into a function that explains it's purpose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome job having a reminder here to answer the question before even showing the next-button. Really impressed! |
||
| ) | ||
| || (counter === 5 && !showResult) | ||
| : ( | ||
| started && counter < 5 && ( | ||
| <button type="button" onClick={handleNextStep} className="nextQuestion" aria-label="press next question button after inserting your name"> | ||
| Next question | ||
| </button> | ||
| ) | ||
| )} | ||
| </main> | ||
| ); | ||
| } | ||
| // start button hur ska jag sätta button nr 2 vart? | ||
| // what should i put in result to show my results | ||
| // where should I put my if statement | ||
| // how do I make next question just show from name... | ||
| // what is exactly happening in line 30 & 55 | ||
| /* {started && counter < 5 && ( | ||
| <button type="button" onClick={handleNextStep} className="nextQuestion"> | ||
| Next question | ||
| </button> */ | ||
| // why like this in nr 59 what does it mean? | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import React from 'react' | ||
|
|
||
| export const Color = ({ color, setColor, counterFromApp, setCounter }) => { | ||
| const handleColorChange = (event) => { | ||
| setColor(event.target.value); | ||
| setCounter(counterFromApp + 1); | ||
| console.log('Color picked: ', event.target.value); | ||
| } | ||
| console.log(color) | ||
| return ( | ||
| <div className="color"> | ||
| <h2>What´s your favourite color ?</h2> | ||
| <form className="favouriteColor" id="color-selector"> | ||
| <button | ||
| className="pink" | ||
| type="button" | ||
| onClick={handleColorChange} | ||
| value="pink" | ||
| aria-label="Select Pink color" | ||
| title="Select Pink color" /> | ||
|
|
||
| <button | ||
| className="black" | ||
| type="button" | ||
| onClick={handleColorChange} | ||
| value="black" | ||
| aria-label="Select Black color" | ||
| title="Select Black color" /> | ||
|
|
||
| </form> | ||
|
|
||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // what should I have as a value to get the if statements right? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import React from 'react'; | ||
|
|
||
| export const Name = ({ name, setName, counter }) => { | ||
| const handleNameChange = (event) => { | ||
| setName(event.target.value); | ||
|
|
||
| console.log('Name:', event.target.value); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="name-container"> | ||
| <p>What is your name?</p> | ||
| <form> | ||
| <section className="inputName"> | ||
| <input className="inputClass" type="text" onChange={handleNameChange} value={name} counter={counter} aria-labelledby="name-label" arial-label="Write your name here and then press button further down" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great use of aria-labels. Think about the className for this input, and if it could be re-named to something more unique to this specific input/component |
||
| </section> | ||
| </form> | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import React from 'react' | ||
|
|
||
| export const Prefer = ({ prefers, setPrefers, counterFromApp, setCounter }) => { | ||
| const handlePreferChange = (event) => { | ||
| setPrefers(event.target.value); | ||
| setCounter(counterFromApp + 1); | ||
| console.log('prefers: ', event.target.value); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="whatDoYou"> | ||
| <h2>Select your preferred activity</h2> | ||
| <section className="dropDown"> | ||
|
|
||
| <select className="dropMenu" onChange={handlePreferChange} value={prefers} aria-label="Select your preferred activity"> | ||
| <option value="" className="choose"> Choose an option</option> | ||
| <option value="books" className="books">Books & plants 🪴📚</option> | ||
| <option value="surf" className="surf">Surf &palmtrees 🏄🏿♀️ 🏝️</option> | ||
| <option value="people" className="people">People, fika & walks 👨🏻🦽🚶🏾♀️</option> | ||
|
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very cute addition with the emojis |
||
| </select> | ||
| </section> | ||
| </div> | ||
| ) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice using a starter function!