-
Notifications
You must be signed in to change notification settings - Fork 134
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
Happiness survey by Joyce & Helene #84
Open
HeleneWestrin
wants to merge
25
commits into
Technigo:main
Choose a base branch
from
HeleneWestrin:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f6958b9
Created basic flow for survey app.
HeleneWestrin 844e692
Updated ReadMe
HeleneWestrin ac078ad
Created color variables. Added custom font. Created button styling.
HeleneWestrin 560b282
Added controlled forms for each step
HeleneWestrin 2146c74
Added useful comments
HeleneWestrin c9db27b
Add progress indicator logic with circle classes and create progressI…
JoyceKuode e602c20
Add image, title, and paragraph to Home
JoyceKuode 1e3a604
Created SurveyHero. Updated layout and styling for steps. Styled inputs.
HeleneWestrin d103193
Fixed some styling
HeleneWestrin 25764fa
Created logic for button to be disabled if question is not answered.
HeleneWestrin 47ed1ea
Style home page and add image to results
JoyceKuode 5020241
Create logic to show error message if user tries to click disabled bu…
JoyceKuode 67ff909
Add function to clear answers when user clicks Start Over button
JoyceKuode 19dfd4c
Created styling for radio buttons. Updated the survey questions.
HeleneWestrin 039a488
Made radio buttons more accessible
HeleneWestrin 27e942e
Created RadioButtonGroup component to make code more DRY
HeleneWestrin 4dc3a40
Updated ReadMe
HeleneWestrin e70fee7
Updated font-face name for SemiBold font
HeleneWestrin 8df8824
Added some accessibilty features, like screen readers getting re-focu…
HeleneWestrin 9e237f6
Updated results sentece to be lowercase
HeleneWestrin 2fd5850
Added width and height on images to avoid layout shifts
HeleneWestrin 0fda74b
Add details to README
JoyceKuode 64efc11
Fixed bug with radio button not being properly checked when using the…
HeleneWestrin 75f4103
Merge branch 'main' of https://github.com/HeleneWestrin/project-surve…
HeleneWestrin cbdd1c2
Polished the error message and moved it closer to the form
HeleneWestrin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,22 @@ | ||
<h1 align="center"> | ||
<a href=""> | ||
<img src="/src/assets/survey.svg" alt="Project Banner Image"> | ||
</a> | ||
</h1> | ||
|
||
# Survey Project | ||
|
||
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. | ||
|
||
## Getting Started with the Project | ||
|
||
### Dependency Installation & Startup Development Server | ||
The project involved building a React survey with at least three questions, using different input types (radio buttons, dropdown). Upon submission, users are shown a summary of their answers. The focus was on practicing React state and controlled forms while ensuring accessibility, responsiveness, and clean code. | ||
|
||
Once cloned, navigate to the project's root directory and this project uses npm (Node Package Manager) to manage its dependencies. | ||
Collaboration was done via GitHub and we worked on separate branches and then merged the changes to main. | ||
|
||
The command below is a combination of installing dependencies, opening up the project on VS Code and it will run a development server on your terminal. | ||
### The Process | ||
|
||
```bash | ||
npm i && code . && npm run dev | ||
``` | ||
Prior to our first meeting, Helene set up the design on Figma and also created a flowchart to help us visualize the data flow and state management for our application. | ||
|
||
### The Problem | ||
We started with setting up the structure of the project by pair programming using LiveShare and a Slack huddle. When that was done, we had a semi-working flow with state manangement. We could then divide the tasks between us. | ||
|
||
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? | ||
One challenge was that our schedules rarely aligned, so after our first meeting we had to find a way to make progress in our own time while avoiding merge conflicts. We set up a Canvas in Slack with an organized to-do list and assigned ourselves various tasks throughout the week. We also included detailed comments in our code and this helped to promote clarity and communication. | ||
|
||
### 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. | ||
[View it live »](https://happiness-survey.netlify.app/) | ||
|
||
## Instructions | ||
### Collaborators | ||
|
||
<a href="instructions.md"> | ||
See instructions of this project | ||
</a> | ||
Helene Westrin | ||
Joyce Kuo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
import { useState } from "react"; | ||
import { Home } from "./components/Home"; | ||
import { Survey } from "./components/Survey"; | ||
import { Results } from "./components/Results"; | ||
|
||
export const App = () => { | ||
return <div>Find me in src/app.jsx!</div>; | ||
const [surveyStarted, setSurveyStarted] = useState(false); | ||
const [currentStep, setCurrentStep] = useState(1); | ||
const [userAnswers, setUserAnswers] = useState({ | ||
answer1: "", | ||
answer2: "", | ||
answer3: "", | ||
}); | ||
|
||
const handleSurveySubmit = (event) => { | ||
event.preventDefault(); | ||
setCurrentStep(-1); //Switch to results | ||
}; | ||
|
||
// Function to clear answers and start over | ||
const resetSurvey = () => { | ||
setSurveyStarted(false); | ||
setCurrentStep(1); | ||
setUserAnswers({ | ||
answer1: "", | ||
answer2: "", | ||
answer3: "", | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
{!surveyStarted ? ( | ||
<Home setSurveyStarted={setSurveyStarted} /> | ||
) : currentStep === -1 ? ( | ||
<Results | ||
setSurveyStarted={setSurveyStarted} | ||
setCurrentStep={setCurrentStep} | ||
userAnswers={userAnswers} | ||
resetSurvey={resetSurvey} // Pass reset function to Results | ||
/> | ||
) : ( | ||
<Survey | ||
currentStep={currentStep} | ||
setCurrentStep={setCurrentStep} | ||
userAnswers={userAnswers} | ||
setUserAnswers={setUserAnswers} | ||
onSubmit={handleSurveySubmit} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Button } from "./ui/Button"; | ||
import homeImage from "../assets/home.png"; | ||
|
||
export const Home = ({ setSurveyStarted }) => { | ||
return ( | ||
<main className="main-container"> | ||
<img | ||
width="400" | ||
height="400" | ||
src={homeImage} | ||
alt="Cartoon of a person relaxed and sleeping on the sofa with abstract shapes in the background" | ||
/> | ||
<h1>The Science of Happiness</h1> | ||
<p>Everyday Joy Boosters Survey</p> | ||
<Button onClick={() => setSurveyStarted(true)} text="Let's begin!" /> | ||
</main> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.progress-indicator { | ||
display: flex; | ||
justify-content: center; | ||
gap: 1.75rem; | ||
} | ||
|
||
.circle { | ||
width: 2.5rem; | ||
height: 2.5rem; | ||
border-radius: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
color: var(--pink-dark); | ||
border: 2px solid var(--pink-dark); | ||
font-size: 1.5rem; /* 24 (font-size you are aiming for) divided by 16 (default root font size) = 1.5 */ | ||
font-weight: 700; | ||
|
||
span { | ||
position: relative; | ||
top: -2px; | ||
} | ||
|
||
svg { | ||
fill: var(--blue-dark); | ||
position: relative; | ||
top: 5px; | ||
} | ||
} | ||
|
||
.circle.active, | ||
.circle.completed { | ||
background-color: var(--pink-dark); | ||
color: var(--blue-dark); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import "./ProgressIndicator.css"; | ||
import Checkmark from "../assets/checkmark.svg?react"; | ||
|
||
export const ProgressIndicator = ({ currentStep }) => { | ||
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. 🚀 |
||
// Function that determines which CSS class to apply to each circle based on current step | ||
const getCircleClass = (step) => { | ||
if (step < currentStep) return "completed"; | ||
if (step === currentStep) return "active"; | ||
return ""; | ||
}; | ||
|
||
const setAriaDisabled = (step) => { | ||
if (step < currentStep || step > currentStep) return "true"; | ||
if (step === currentStep) return "false"; | ||
}; | ||
|
||
return ( | ||
<div className="progress-indicator"> | ||
{/* Map iterates over steps 1, 2, 3 and for each step, it calls getCircleClass(step) to determine appropriate class */} | ||
{[1, 2, 3].map((step) => ( | ||
<div | ||
key={step} | ||
aria-disabled={setAriaDisabled(step)} | ||
className={`circle ${getCircleClass(step)}`} | ||
> | ||
{/* If step is less than current step, it displays a checkmark, otherwise it displays the step number */} | ||
<span> | ||
{step < currentStep ? ( | ||
<> | ||
<p className="sr-only">Step {step} (completed)</p> | ||
<Checkmark /> | ||
</> | ||
) : ( | ||
<> | ||
<p> | ||
<span className="sr-only">Step</span> {step} | ||
</p> | ||
</> | ||
)} | ||
</span> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Button } from "./ui/Button"; | ||
|
||
import resultsImage from "../assets/results.png"; | ||
|
||
export const Results = ({ | ||
setSurveyStarted, | ||
setCurrentStep, | ||
userAnswers, | ||
resetSurvey, | ||
}) => { | ||
return ( | ||
<main className="main-container"> | ||
<img | ||
width="400" | ||
height="400" | ||
src={resultsImage} | ||
alt="Cartoon of a person sitting on top of a stack of oversized books and reading a book" | ||
/> | ||
<h1>Your results</h1> | ||
<p> | ||
For you, <strong>{userAnswers.answer1.toLowerCase()}</strong> is a great | ||
way to feel happier, while{" "} | ||
<strong>{userAnswers.answer2.toLowerCase()}</strong> can also brighten | ||
your mood during the{" "} | ||
<strong>{userAnswers.answer3.toLowerCase()}</strong>. | ||
</p> | ||
<Button | ||
onClick={() => { | ||
setSurveyStarted(false); | ||
setCurrentStep(1); | ||
resetSurvey(); // Invoke resetSurvey function | ||
}} | ||
text="Start Over" | ||
/> | ||
</main> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
how come you put width and height here instead of a css file?
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.
Having width and height explicitly set on images (even if you control the size with CSS in some other way) prevents layout shifts when the page os loading because you preserve space for them. Especially noticeable on a slow 4G net for example. @JennieDalgren