Skip to content
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 week 6 #441

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
87e2ac8
started with components
SandraMadeleine Mar 14, 2023
3c81e11
fixing some ESlint-objections
SandraMadeleine Mar 14, 2023
3ac8e59
minor changes
SandraMadeleine Mar 14, 2023
20964d0
working on the survey in different components
SandraMadeleine Mar 15, 2023
ea81975
buildning the page
SandraMadeleine Mar 15, 2023
00a249c
working on the survey build
SandraMadeleine Mar 15, 2023
65733d5
adding to app.js
SandraMadeleine Mar 16, 2023
ecc1217
fixing components
SandraMadeleine Mar 16, 2023
b05160f
fixes
SandraMadeleine Mar 16, 2023
8e1c190
fixed imports
SandraMadeleine Mar 17, 2023
1d9c1e6
final fixes on survey steps
SandraMadeleine Mar 17, 2023
7b38d31
working on styling
SandraMadeleine Mar 17, 2023
dd16219
continued styling
SandraMadeleine Mar 17, 2023
3618a1f
continued styling
SandraMadeleine Mar 19, 2023
5527881
css and emojis
SandraMadeleine Mar 19, 2023
166c27b
media queries
SandraMadeleine Mar 19, 2023
142247f
finalizing layout
SandraMadeleine Mar 19, 2023
d870236
last touches
SandraMadeleine Mar 19, 2023
589c5c8
readme updated
SandraMadeleine Mar 19, 2023
f3c9ad3
switched places of imports in app.js
SandraMadeleine Mar 19, 2023
9b5e7a6
fixed typo
SandraMadeleine Mar 19, 2023
a893e34
disable eslint in app.js in hope of being able to deploy
SandraMadeleine Mar 21, 2023
2b14d3d
deleted App.js
SandraMadeleine Mar 21, 2023
3627cd4
Added App.js back again
SandraMadeleine Mar 21, 2023
c7021d5
trying to fix case sensitivity
SandraMadeleine Mar 21, 2023
dcada88
add netlify link
SandraMadeleine Mar 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# 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.
A survey made in React, using different types of forms and summarizing the answers in the final step.

## 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?
The major hurdle while constructing this survey was to place everything correctly on the page. If I had more time I would place the buttons better and would also add some sort of counter, so that the respondent can see how many steps they have completed and how many steps are left.

## View it live

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.
https://at-the-cafe-survey.netlify.app/
16 changes: 16 additions & 0 deletions bash.exe.stackdump
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Stack trace:
Frame Function Args
000FFFFCD30 00210062B0E (0021028A770, 00210275E51, 00000000001, 000FFFFB710)
000FFFFCD30 0021004846A (00210000000, 00200000000, 00000000000, 00000000001)
000FFFFCD30 002100484A2 (000006D0000, 000006D0101, 00000000001, CC19CA85FF21)
000FFFFCD30 0021006E496 (00210045323, 00210358BC0, 00000000000, 0000000000D)
000FFFFCD30 0021006E4A9 (00210045170, 0021023D7E0, 002100448F2, 000FFFFC910)
000FFFFCD30 00210070DE4 (00000000013, 00000000001, 000FFFFC910, 00210278640)
000FFFFCD30 0021005AB65 (000FFFFCA60, 00000000000, 000FFFFCA68, 000FFFFFFFF)
000FFFFCD30 0021005B335 (00210358550, 00000000000, 000FFFFCD30, 00000100201)
000FFFFCD30 0021005B847 (002100DF73E, 00000000000, 00000000000, 00000000000)
000FFFFCD30 0021005BB86 (00000000000, 000FFFFCD30, FFFFFFFFFFFFFFC6, 00000000000)
000FFFFCD30 00210048C0C (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 00210047716 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 002100477C4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace
49 changes: 0 additions & 49 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added code/public/icon-notepad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion code/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Technigo React App</title>
<title>Survey project</title>
<link rel="icon" type="image/png" sizes="32x32" href="./icon-notepad.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Mulish:wght@300&display=swap" rel="stylesheet">
</head>

<body>
Expand Down
107 changes: 102 additions & 5 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,106 @@
import React from 'react';
import React, { useState } from 'react';
import Start from './components/Start';
import Subscription from './components/Subscription';
import Purchase from './components/Purchase';
import FreeText from './components/FreeText';
import Conclusion from './components/Conclusion';
import Footer from './components/Footer';
import './index.css'

export const App = () => {
const [step, setStep] = useState(1)
const [purchase, setPurchase] = useState('')
const [subscriptionQ, setSubscriptionQ] = useState('')
const [often, setOften] = useState('')
const [missing, setMissing] = useState('')

const handleStepIncrease = () => {
setStep(step + 1)
}

const handleStepDecrease = () => {
setStep(step - 1)
}

const handleStepRestart = () => {
setStep(1)
}

return (
<div>
Find me in src/app.js!
</div>
<>
<div className="outer-part">
<div className="inner-part">
{step === 1 && (
<div>
<Start />
<button className="start-btn" type="button" onClick={handleStepIncrease}>Start here</button>
</div>
)}

{step === 2 && (
<Subscription subscriptionQ={subscriptionQ} setSubscriptionQ={setSubscriptionQ} />
)}

{step === 3 && (
<Purchase purchase={purchase} setPurchase={setPurchase} />
)}

{step === 4 && (
<div>
<FreeText
headline="Favorite purchases"
input={often}
setInput={setOften}
inputLabel="Which drink do you purchase most often when at a cafe? 💸"
id="favorite-purchase"
placeholder="My favorite purchase is..."
htmlFor="favorite-purchase" />
</div>
)}

{step === 5 && (
<div>
<FreeText
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the design of the FreeText-component, good reusability

headline="Something missing?"
input={missing}
setInput={setMissing}
inputLabel="Is there a drink you feel is missing at most cafes? 🤔"
id="missing-drink"
placeholder="I would love if all cafes offered..."
htmlFor="missing-drink" />
</div>
)}

{step === 6 && (
<div>
<Conclusion
subscriptionQ={subscriptionQ}
purchase={purchase}
often={often}
missing={missing} />
</div>
)}

{step > 1 && step < 6 && (
<div>
<button className="next-btn" type="button" onClick={handleStepIncrease}>Submit and go to next</button>
</div>
)}

{step > 2 && step < 6 && (
<div>
<button className="prev-btn" type="button" onClick={handleStepDecrease}>Previous question</button>
</div>
)}

{step > 1 && step <= 6 && (
<div>
<button className="restart-btn" type="button" onClick={handleStepRestart}>Restart the survey</button>
</div>
)}
</div>
</div>
<Footer />
</>
);
}
}
32 changes: 32 additions & 0 deletions code/src/components/Conclusion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import '../index.css'
import '../conclusion.css'

const conclusion = ({ purchase, subscriptionQ, often, missing }) => {
return (
<>
<h2>Thank you for completing this short survey! 💕</h2>
<h3>You answered:</h3>
<section className="list">
<ul>
<li><span className="summary">Weekly purchases:</span> {purchase}</li>
<li><span className="summary">Active subscription:</span> {subscriptionQ}</li>
<li><span className="summary">Mostly purchased:</span> {often}</li>
<li><span className="summary">Missing on menu:</span> {missing}</li>
</ul>
</section>

<section className="related-link">
<a
href="https://www.hsph.harvard.edu/nutritionsource/healthy-drinks/other-healthy-beverage-options/"
rel="noopener noreferrer"
target="_blank"
title="Learn more about the health benefits of coffee and tea">
-Health benefits of drinking coffee and tea-
</a>
</section>
</>
)
}

export default conclusion
13 changes: 13 additions & 0 deletions code/src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import Drink from './coffee-shop.png'
import '../index.css'

const footer = () => {
return (
<footer>
<img src={Drink} alt="Cup with warm beverage" />
</footer>
);
}

export default footer
30 changes: 30 additions & 0 deletions code/src/components/FreeText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import '../index.css'
import '../freetext.css'

const freeText = ({ headline, input, setInput, inputLabel, id, placeholder, htmlFor }) => {
const handleInputChange = (event) => {
setInput(event.target.value)
}

return (
<>
<h2>{headline}</h2>
<form>
<label htmlFor={htmlFor}>
<p>{inputLabel}</p>
</label>
<textarea
type="text"
id={id}
className="text-input"
placeholder={placeholder}
aria-live="polite"
onChange={handleInputChange}
value={input} />
</form>
</>
)
}

export default freeText
34 changes: 34 additions & 0 deletions code/src/components/Purchase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React from 'react'
import '../index.css'
import '../purchase.css'

const purchases = ['1-2 times', '3-5 times', '6-10 times', '10+ times']
console.log(purchases)

const purchaseQuestion = ({ purchase, setPurchase }) => {
const handleNumberPurchases = (event) => {
setPurchase(event.target.value)
}

return (
<>
<h2>How often per week do you purchase something to drink in a cafe?</h2>
<form className="radio-buttons" id="radio-buttons">
{purchases.map((group) => (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, will be easier to add more options later and the radio buttons will still work

<label key={group} className="times-purchase">
<input
type="radio"
className="radio-button"
value={group}
onChange={handleNumberPurchases}
checked={purchase === group} />
{group}
</label>
))}
</form>
</>
)
}

export default purchaseQuestion
21 changes: 21 additions & 0 deletions code/src/components/Start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import '../start.css'
import '../index.css'

const start = () => {
return (
<section>
<h1>A survey on what people choose to drink when in a cafe</h1>

<p>Coffee, tea, or maybe something else? This short survey aims to find
out just what cafe visitors want to drink, and how often.
</p>
<p>
We would be immensely happy if you would like to answer a few
questions, the survey only takes about 2 minutes to complete. Thanks! ✨
</p>
</section>
);
}

export default start
Loading