-
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
Survey - v6 #438
base: master
Are you sure you want to change the base?
Survey - v6 #438
Changes from 13 commits
ae6d6a7
df94ca5
2b2e7b9
0c9be43
955ea6c
2c776be
6ab8a91
ca1d102
b58e3f0
c5013b3
bd3e1d8
e0b9f84
49ed5d5
8b6c1de
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,85 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { Name } from './components/Name' | ||
import { Start } from './components/Start' | ||
import { Activity } from './components/Activity' | ||
import { Colour } from './components/Colour' | ||
import { Place } from './components/Place' | ||
import { Temp } from './components/Temp' | ||
import { Who } from './components/Who' | ||
import { Summary } from './components/Summary' | ||
import { Breathe } from './components/Breathe' | ||
import hug from './img/hug.svg'; | ||
|
||
export const App = () => { | ||
const [step, setStep] = useState(0); | ||
const [name, setName] = useState(''); | ||
const [activity, setActivity] = useState(''); | ||
const [colour, setColour] = useState(''); | ||
const [place, setPlace] = useState(''); | ||
const [temp, setTemp] = useState(''); | ||
const [who, setWho] = useState(''); | ||
|
||
const handleStepIncrease = () => { | ||
setStep(step + 1); | ||
}; | ||
const handleStepReset = () => { | ||
setStep(0); | ||
setName(''); | ||
}; | ||
return ( | ||
<div> | ||
Find me in src/app.js! | ||
<div className="main-container"> | ||
<img src={hug} alt="A hug" className="hugImg" /> | ||
{step === 0 && ( | ||
<Start onButtonClick={() => handleStepIncrease(0)} /> | ||
)} | ||
{step === 1 && ( | ||
<Name name={name} setName={setName} step={step} /> | ||
)} | ||
{step === 2 && ( | ||
<Activity activity={activity} setActivity={setActivity} step={step} /> | ||
)} | ||
{step === 3 && ( | ||
<Colour colour={colour} setColour={setColour} step={step} /> | ||
)} | ||
{step === 4 && ( | ||
<Place place={place} setPlace={setPlace} step={step} /> | ||
)} | ||
{step === 5 && ( | ||
<Temp temp={temp} setTemp={setTemp} step={step} /> | ||
)} | ||
{step === 6 && ( | ||
<Who who={who} setWho={setWho} step={step} /> | ||
)} | ||
{step === 7 && ( | ||
<> | ||
<Summary | ||
name={name} | ||
activity={activity} | ||
colour={colour} | ||
place={place} | ||
temp={temp} | ||
who={who} /> | ||
<div className="button-container"> | ||
<button type="button" onClick={handleStepIncrease} className="submitBtn">Yes please</button> | ||
<button type="button" onClick={handleStepReset} className="restartBtn">No, restart</button> | ||
</div> | ||
</> | ||
)} | ||
{step === 8 && ( | ||
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 loved this part! It was like a surprise bonus at the end. |
||
<> | ||
<Breathe | ||
name={name} | ||
activity={activity} | ||
colour={colour} | ||
place={place} | ||
temp={temp} | ||
who={who} /> | ||
<button type="button" onClick={handleStepReset} className="restartBtn"> I need a new scenario</button> | ||
</> | ||
)} | ||
{step < 7 && step !== 0 && ( | ||
<button type="button" onClick={handleStepIncrease} className="submitBtn"> Next question </button> | ||
)} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
|
||
const activechoice = ['running 🏃🏻', 'breathing 🌬', 'stretching 🧘🏽', 'walking 🚶🏽', 'biking 🚵🏽']; | ||
|
||
export const Activity = ({ activity, setActivity, step }) => { | ||
return ( | ||
<> | ||
<div className="content-container"> | ||
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 notice some of the classnames aren't in camel case. Not a biggie, but maybe for future reference? |
||
<div> | ||
<p className="p-step">Current step: {step} / 7</p> | ||
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. Nice job displaying current step! |
||
</div> | ||
<h4> Ok, what activity sparks your joy and makes your ears wiggle? | ||
</h4> | ||
</div> | ||
<div> | ||
<form className="radio-activity"> | ||
{activechoice.map((item) => ( | ||
<label key={item} htmlFor="activeradio"> | ||
<div | ||
className="radioBtn" | ||
role="button" | ||
onClick={(event) => setActivity(event.target.value)} | ||
onKeyDown={(event) => { | ||
if (event.key === 'Enter' || event.key === ' ') { | ||
setActivity(item); | ||
} | ||
}} | ||
tabIndex={0}> | ||
<input | ||
type="radio" | ||
className="radioActiveBtn" | ||
onChange={(event) => setActivity(event.target.value)} | ||
value={item} | ||
checked={activity === item} /> | ||
<span>{item}</span> | ||
</div> | ||
</label> | ||
))} | ||
</form> | ||
</div> | ||
</> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
|
||
export const Breathe = ({ name, activity, colour, place, temp, who }) => { | ||
return ( | ||
<div className="content-container"> | ||
<svg width="180" height="180"> | ||
<rect | ||
x="20" | ||
y="20" | ||
width="170" | ||
height="170" | ||
fill="none" | ||
strokeDasharray="20 20" /> | ||
<circle cx="10" cy="10" r="8" fill={colour} className="blurryCircle"> | ||
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. This was really the icing on the cake! Managing to implement a moving image that is also relevant to the excercise, amazing! |
||
<animateMotion | ||
dur="9s" | ||
repeatCount="indefinite" | ||
path="M 10,10 L 160,10 L 160,160 L 10,160 Z" /> | ||
</circle> | ||
</svg> | ||
<h4 className="sumh4">Keep your happy scenario in your mind and let's slow down...</h4> | ||
<p> | ||
Remember, you are by the {place} and you're going to start {activity} soon. <br /> | ||
It's around {temp} degrees, {who} is next to you and already looking at | ||
the {colour} light. Let's do this, focus {name}! | ||
<br /><br /> | ||
One breath is illustated by the dot.<br /> | ||
Each step is one side of the square.<br /> | ||
Start by breathing out slowly, releasing the air from your lungs. <br /><br /> | ||
1. Breathe in through your nose<br /> | ||
2. Hold your breath <br /> | ||
3. Exhale slowly <br /> | ||
4. Hold your breath again <br /><br /> | ||
Repeat as many times as you need. | ||
</p> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
export const Colour = ({ colour, setColour, step }) => { | ||
return ( | ||
<div className="content-container"> | ||
<p className="p-step">Current step: {step} / 7</p> | ||
<h4> What's your favourite color?</h4> | ||
<form className="colourForm"> | ||
<select | ||
onChange={(event) => setColour(event.target.value)} | ||
value={colour} | ||
aria-label="dropdown for your favourite colours"> | ||
<option value="" disabled>Choose colour</option> | ||
<option value="white">White</option> | ||
<option value="pink">Pink</option> | ||
<option value="yellow">Yellow</option> | ||
<option value="green">Green</option> | ||
<option value="purple">Purple</option> | ||
<option value="orange">Blue</option> | ||
</select> | ||
</form> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
|
||
export const Name = ({ name, setName, step }) => { | ||
const handleNameChange = (event) => { | ||
setName(event.target.value); | ||
} | ||
return ( | ||
<div className="content-container"> | ||
<p className="p-step">Current step: {step} / 7</p> | ||
<h4>Let's start of by introducing ourselves! | ||
What's your name? | ||
</h4> | ||
<input | ||
aria-label="name-input" | ||
type="text" | ||
value={name} | ||
className="name-input" | ||
placeholder="Type name here" | ||
onChange={handleNameChange} /> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import ocean from '../img/ocean.png'; | ||
import forest from '../img/forest.png'; | ||
import home from '../img/home.png'; | ||
|
||
export const Place = ({ place, setPlace, step }) => { | ||
const handlePlaceChange = (event) => { | ||
setPlace(event.target.value); | ||
} | ||
return ( | ||
<div className="place-container"> | ||
<div> | ||
<p className="p-step">Current step: {step} / 7</p> | ||
</div> | ||
<h4> Where do you feel the most at ease?</h4> | ||
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. Really nice with the images above the choices. Elevates the whole thing! I would recommend making the files a bit smaller though. As it is now it takes a while for the images to load, which takes away a bit from the experience. |
||
<div className="place-img-container"> | ||
<img src={ocean} alt="The ocean" /> | ||
<img src={forest} alt="The Forest" /> | ||
<img src={home} alt="In my home" /> | ||
</div> | ||
<form className="radio-container"> | ||
<label htmlFor="ocean"> | ||
The ocean | ||
<input | ||
type="radio" | ||
value="ocean" | ||
onChange={handlePlaceChange} | ||
checked={place === 'ocean'} /> | ||
</label> | ||
<label htmlFor="forest"> | ||
In the forest | ||
<input | ||
type="radio" | ||
value="forest" | ||
onChange={handlePlaceChange} | ||
checked={place === 'forest'} /> | ||
</label> | ||
<label htmlFor="home"> | ||
At home | ||
<input | ||
type="radio" | ||
value="home" | ||
onChange={handlePlaceChange} | ||
checked={place === 'home'} /> | ||
</label> | ||
</form> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
|
||
export const Start = (begin) => { | ||
const handleClick = () => { | ||
begin.onButtonClick(); | ||
} | ||
return ( | ||
<div className="content-container"> | ||
<div> | ||
<h3>Hello!</h3> | ||
</div> | ||
<div> | ||
<p className="start-p">Have you been feeling a little bit stressed lately? <br /> | ||
I would like to help you feel better, | ||
let's take our first steps together... | ||
</p> | ||
</div> | ||
<button className="startBtn" type="button" onClick={handleClick}>Start</button> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
|
||
export const Summary = ({ name, activity, colour, place, temp, who }) => { | ||
return ( | ||
<div className="content-container"> | ||
<p className="p-step">Complete 7 / 7</p> | ||
<h4 className="sumh4">So...</h4> | ||
<p> | ||
{name}, picture yourself by the {place} where you are about to start your {activity}. <br /> | ||
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 way of showing the results. They look so much better in a story than in a list. |
||
You feel the atmosphere beeing just the way you want, it is around {temp} degrees. <br /> | ||
By your side you have {who} looking at you with a smile. <br /> | ||
In the distance you see a beautiful {colour} light. | ||
</p> | ||
<p> | ||
{who} want you to move on now. | ||
Are you ready to take the next step {name}? | ||
</p> | ||
</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.
Didn't know you could import images as well as components. Interesting!