-
Notifications
You must be signed in to change notification settings - Fork 435
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
Project Survey - Andrea Hedström #458
base: master
Are you sure you want to change the base?
Changes from all commits
8e3da56
27621ca
3e991f8
76768a8
7e6fae3
1e7fb2b
969ea29
2cd6fea
ba5ca04
2819f55
4ed1984
c48c8d4
20eca21
695c747
9df6ec8
03f8d60
0091b11
0a1f9b3
dcd399f
a761f84
dfef96f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Survey form with React | ||
|
||
Replace this readme with your own information about your project. | ||
|
||
Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
This weeks project was to make a survey with react. I chose to do a imaginary party planning survey. | ||
|
||
## The problem | ||
|
||
Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
I started with technigos react-starter project and played around in that just to try to understand more about how react works. Then I started to plan what my servey would be about and did the basic structure for it in VSCode. | ||
After that I tried out some different designs and I have changed that a lot of times during the week. I might have to plan the design more before I start next time but I also think I learn a lot by trying out different designs during the process. | ||
I also found the JSConfetti that felt like I fun effect to add and it was much easier to add then I thouht. | ||
|
||
## View it live | ||
My problem this week was that I didn't had so much time as I needed so I need to go back to this project and work on the acceccibility for example. Also, React is completely new to me so it will take time to learn and understand. | ||
|
||
Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
## View it live |
This file was deleted.
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,51 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
|
||
import { Name } from 'components/Name'; | ||
import { Place } from 'components/Place'; | ||
import { Food } from 'components/Food'; | ||
import { Drink } from 'components/Drink'; | ||
import { Party } from 'components/Party'; | ||
|
||
export const App = () => { | ||
const [step, setStep] = useState(1); | ||
const [name, setName] = useState(''); | ||
const [place, setPlace] = useState(''); | ||
const [food, setFood] = useState(''); | ||
const [drink, setDrink] = useState(''); | ||
|
||
const handleStepIncrease = () => { | ||
setStep(step + 1); | ||
} | ||
return ( | ||
<div> | ||
Find me in src/app.js! | ||
<div className="survey-container"> | ||
{step === 1 && ( | ||
<Name name={name} setName={setName} /> | ||
)} | ||
{step === 2 && ( | ||
<Place place={place} setPlace={setPlace} /> | ||
)} | ||
{step === 3 && ( | ||
<Food food={food} setFood={setFood} /> | ||
)} | ||
{step === 4 && ( | ||
<Drink drink={drink} setDrink={setDrink} /> | ||
|
||
)} | ||
{step >= 5 && ( | ||
|
||
<Party name={name} place={place} food={food} drink={drink} /> | ||
)} | ||
{step < 5 && ( | ||
<> | ||
<div className="step-btn"> | ||
<button type="button" onClick={handleStepIncrease}>NEXT</button> | ||
</div> | ||
<div className="step"> | ||
<p>PARTYSTEP {step}/5</p> | ||
</div> | ||
|
||
</> | ||
)} | ||
</div> | ||
); | ||
} | ||
}; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
export const Drink = ({ drink, setDrink }) => { | ||
const handleDrinkChange = (event) => { | ||
setDrink(event.target.value); | ||
} | ||
return ( | ||
<> | ||
<div className="question"> | ||
<h2>Sounds delicious! | ||
And drink? | ||
</h2> | ||
</div> | ||
<div className="select-container"> | ||
<select | ||
className="select" | ||
id="drink" | ||
value={drink} | ||
onChange={handleDrinkChange}> | ||
<option value="">Menu</option> | ||
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. I think you can add "disable" either before or after "value" for the MENU line and that will stop being an acceptable value. Then the user would have to pick something else from the dropdown. |
||
<option value="a great cup of coffee">Coffee</option> | ||
<option value="one rainbow colored drink">Tropical drinks</option> | ||
<option value="sparkling ice cold soda">Sparkling soda</option> | ||
<option value="a fruity and fluffy smoothie">Smoothie</option> | ||
<option value="ice cold water">Water</option> | ||
</select> | ||
</div> | ||
</> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
|
||
const foodOption = [ | ||
'the biggest cake you ever seen', | ||
'a buffé with your favourite food', | ||
'fruits in piles', | ||
'ice cream that never melts' | ||
]; | ||
|
||
export const Food = ({ food, setFood }) => { | ||
const handleFoodChange = (event) => { | ||
setFood(event.target.value); | ||
} | ||
return ( | ||
<> | ||
<div className="question"> | ||
<h2>What do you dream about to eat on your imaginary party?</h2> | ||
</div> | ||
<div className="foodBtn"> | ||
{foodOption.map((group) => ( | ||
<label key={group} htmlFor="group"> | ||
<input | ||
type="radio" | ||
className="radioBtn" | ||
value={group} | ||
onChange={handleFoodChange} | ||
checked={food === group} /> | ||
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. I think an easy way to add a bit of accessibility is to add an aria-label here. Something like: |
||
{group} | ||
</label> | ||
))} | ||
</div> | ||
|
||
</> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
|
||
export const Name = ({ name, setName }) => { | ||
const handleNameChange = (event) => { | ||
setName(event.target.value); | ||
} | ||
return ( | ||
<> | ||
<div className="header"> | ||
<h1>Are you a day dreamer?</h1> | ||
<h1>Let's throw a <span>party</span> !</h1> | ||
</div> | ||
<div className="question"> | ||
<p><span>What's your name?</span></p> | ||
</div> | ||
<div className="answer-input"> | ||
<input type="text" value={name} onChange={handleNameChange} /> | ||
</div> | ||
</> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable max-len */ | ||
import React from 'react'; | ||
import JSConfetti from 'js-confetti'; | ||
|
||
const jsConfetti = new JSConfetti(); | ||
|
||
export const Party = ({ name, place, food, drink }) => { | ||
return ( | ||
<> | ||
<div className="party-name"> | ||
<h1>{name}</h1> | ||
</div> | ||
<div className="party-text"> | ||
<p>🌪! Wow you've just arrived at your dream place {place}! And look, a table with {food} and {drink}! All your favourite people is here, the weather is dreamy and we're having a party just for you! Add some more partyfeeling? </p> | ||
<h3>↓</h3> | ||
</div> | ||
|
||
<div className="party-btn"> | ||
<button | ||
type="submit" | ||
className="partyBtn" | ||
onClick={() => { | ||
(jsConfetti.addConfetti({ | ||
confettiRadius: 8, | ||
confettiNumber: 500, | ||
confettiColors: [ | ||
'#d44e62', '#fcfee1', '#eebed9', '#b4c8b7', '#fb91c6', '#a0bbd0' | ||
] | ||
})) | ||
}}>MAGIC PARTYBUTTON | ||
</button> | ||
|
||
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. The party button is such a cute addition! And I like that the confetti colors match your design scheme. |
||
</div> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
export const Place = ({ place, setPlace }) => { | ||
const handlePlaceChange = (event) => { | ||
setPlace(event.target.value); | ||
} | ||
return ( | ||
<> | ||
<div className="question"> | ||
<h2>Where in the world would you like to be in your dream?</h2> | ||
</div> | ||
<div className="answer-input"> | ||
<input type="text" value={place} onChange={handlePlaceChange} /> | ||
</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.
I like that your App.js is very tidy and organized. It's very easy to see how everything is related.