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

Tess Aquilon - Project Survey #457

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
bb7c521
layed foundations for the project
Mar 18, 2023
14a1acf
added a dropdown menu
Mar 18, 2023
d2c7f34
added an animation to the start
Mar 18, 2023
2b458d5
changed theme to madlibs game
Mar 21, 2023
f78a9d6
added font
Mar 21, 2023
84210cc
added a Lottie animation + more
Mar 21, 2023
2ad0079
added more styling
Mar 21, 2023
d7129d5
added result animation
Mar 22, 2023
2e0e77e
did some more styling
Mar 22, 2023
5a4f340
started on the media queries
Mar 22, 2023
a731f9a
finished tablet view
Mar 22, 2023
05731f1
finishing touches
Mar 22, 2023
b4d7621
Update README.md
Apr 12, 2023
6c1d875
started re-doing styling
May 9, 2023
1b63075
Merge branch 'master' of https://github.com/TessAquilon/project-survey
May 9, 2023
021c4f3
styling changes and cleaning up code
May 9, 2023
c7b1f9d
the color picking section is not working, but the rest is
May 10, 2023
1ed9b07
started reworking the whole project
Aug 28, 2023
a2c0b31
made button component
Aug 28, 2023
cb1c280
blue level - started building form
Aug 29, 2023
04ddc83
blue level - some basic styling
Aug 29, 2023
665ac1f
added a header + some more styling
Aug 29, 2023
4a39dea
styling the submit btn
Aug 29, 2023
7d55b7e
imported some jazz music
Aug 29, 2023
50e4444
added a footer and a logo
Aug 29, 2023
0868a2a
changed title and edited survey form
Aug 29, 2023
0097cec
working on the questions in the form
Aug 29, 2023
7a777d8
added a submit button and a popup component
Aug 29, 2023
606c12e
submit button functionality
Aug 29, 2023
ec70682
working on the control flow
Aug 29, 2023
4830e51
fixed an error
Aug 29, 2023
98ef8c5
some styling of buttons
Aug 29, 2023
15066c9
fixed a bug
Aug 29, 2023
f7808b5
forgot to commit, ahh!
Aug 30, 2023
cf37d0d
created a summary file
Aug 30, 2023
ddded95
working on the summary/end of survey
Aug 30, 2023
3ff12cd
adjustments
Aug 30, 2023
55fc2bd
renaming
Aug 30, 2023
c6d1bb6
created a dropdown component
Aug 30, 2023
34fe2ed
more work on control flow
Aug 30, 2023
df680ca
some small changes
Aug 30, 2023
353975d
changes to the script mostly
Aug 30, 2023
94469e1
improvement in script
Aug 30, 2023
ff7a1b6
renaming of variables
Aug 30, 2023
7a73638
splitting the css into components
Aug 30, 2023
e12d91d
added a fun animated button
Aug 30, 2023
2d59eb4
styling
Aug 30, 2023
a1b4338
styling and naming of classes
Aug 30, 2023
af0ea38
styling
Aug 30, 2023
d9fc432
styyyyling
Aug 30, 2023
154e495
styling bits and pieces
Aug 31, 2023
596093a
styling
Aug 31, 2023
1940117
more styling
Aug 31, 2023
c57f1fb
trying to create custom css radio and checkbox
Aug 31, 2023
5ec1519
custom css text input
Sep 1, 2023
ee43a5d
custom accessible text input complete
Sep 1, 2023
b6053bf
custom accessible css radio buttons start
Sep 1, 2023
de4b12c
custom accessible css radio btns finished
Sep 1, 2023
85a2f95
custom css accessible checkbox done
Sep 1, 2023
750657b
custom select styles start
Sep 1, 2023
89d886e
custom accessible select finished
Sep 1, 2023
8548a70
adjusting class names etc
Sep 1, 2023
666897f
making accessible buttons
Sep 1, 2023
3ccb0a1
styling
Sep 1, 2023
294a574
accessible buttons complete
Sep 1, 2023
e6e0e2f
replacing icons
Sep 1, 2023
fe876a8
changed icon again
Sep 1, 2023
79dea02
trying to make icon only accessible buttons
Sep 1, 2023
85de56a
trying to get fontawesome to work
Sep 1, 2023
c0c6c6c
font awesome icon buttons done
Sep 2, 2023
e80b42f
accessible custom button colors
Sep 2, 2023
5262266
adjustments for accessibility
Sep 2, 2023
ef545cd
dropped range slider question
Sep 3, 2023
368d0b6
reworking control flow minus range slider
Sep 3, 2023
743cc72
progress bar
Sep 3, 2023
3e2945e
fixed error
Sep 3, 2023
425a3be
styling the progress bar
Sep 3, 2023
b127bf5
styling progress bar
Sep 3, 2023
e6af995
accessible alert message
Sep 4, 2023
44333f3
styling
Sep 4, 2023
b0dc484
slight change of order
Sep 4, 2023
ce4d255
grouping with legend and fieldset
Sep 4, 2023
358c363
accessibility
Sep 4, 2023
bf21696
flexing
Sep 4, 2023
a839317
styling the navigation
Sep 5, 2023
4ad705c
a lot of styling
Sep 5, 2023
26db624
so much styling
Sep 5, 2023
ad0824a
removing borders
Sep 5, 2023
10590d7
media queries
Sep 5, 2023
729a580
dividers
Sep 5, 2023
46c6b5b
trying to deploy
Sep 5, 2023
15898e8
trying again to deploy
Sep 5, 2023
21dae3c
third try to deploy
Sep 5, 2023
4793cdf
made links more accessible by adding a label
Sep 6, 2023
b83a760
added a landing page and adorable illustrations
Sep 6, 2023
764d311
added og tags
Sep 11, 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
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Survey form with React

Replace this readme with your own information about your project.
This week we worked individually to create a survey using React. I chose to make mine a Madlibs game.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
## The Brief

## The problem
This week we will be practicing React state and controlled forms by making a Typeform-like product. Your completed project should consist of at least 3 questions that need to be answered by users. When the user presses submit, they should see a summary of their answers.

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?
**What you need to do**

✓ Your survey should consist of at least 3 questions.

✓ At least one question should use radio buttons.

✓ At least one question should use a select dropdown.

✓ There should be a submit button. When pressed your app should hide the input form and show a summary of the user's submissions.

✓ Your site should follow accessibility guidelines

## 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://fanciful-capybara-de9924.netlify.app/
568 changes: 504 additions & 64 deletions code/package-lock.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
"private": true,
"dependencies": {
"@babel/eslint-parser": "^7.18.9",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@lottiefiles/lottie-player": "^1.7.1",
"@lottiefiles/react-lottie-player": "^3.5.3",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"styled-components": "^5.3.10",
"swatchy.js": "^1.3.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
20 changes: 10 additions & 10 deletions code/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
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>
<meta name="title" content="Nino's Music Survey">
<meta name="description" content="Made with love in React.">
<meta property="og:url" content="" />
<meta property="og:type" content="website" />
<meta property="og:image" content="" />
<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=Audiowide&display=swap" rel="stylesheet">
<link href="https://api.fontshare.com/v2/css?f[]=nippo@200,300&display=swap" rel="stylesheet">
<title>Music Survey</title>
</head>

<body>
Expand Down
15 changes: 12 additions & 3 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
import React from 'react';
import { SurveyForm } from 'components/SurveyForm';
import { Header } from 'components/Header';
import { Footer } from 'components/Footer';

export const App = () => {
return (
<div>
Find me in src/app.js!
</div>
<section className="outer-wrapper">
<section className="inner-wrapper">
<Header />
<SurveyForm />
<Footer />
</section>
</section>
);
}
Binary file added code/src/assets/images/music file2-03 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/src/assets/images/music file2-07.png
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.
18 changes: 18 additions & 0 deletions code/src/components/Alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

// icon
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';

const Alert = ({ message }) => {
return (
<div role="alert" id="form__alert" className="alert enabled">
<FontAwesomeIcon icon={faTriangleExclamation} id="alert-icon" />
<div id="form-error">
{message}
</div>
</div>
)
}

export default Alert;
25 changes: 25 additions & 0 deletions code/src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';

// styling
import 'styles/footer.css'

// icons
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faGithub, faLinkedin } from '@fortawesome/free-brands-svg-icons';

export const Footer = () => {
return (
<footer role="contentinfo">
<hr className="divider" />
<p>A website created by Nino Aquilon @Technigo &apos;23.</p>
<section className="contact">
<a href="https://www.github.com" className="button icon-button" aria-label="Go to my Github">
<FontAwesomeIcon icon={faGithub} />
</a>
<a href="https://www.github.com" className="button icon-button" aria-label="Go to my LinkedIn">
<FontAwesomeIcon icon={faLinkedin} />
</a>
</section>
</footer>
)
}
41 changes: 41 additions & 0 deletions code/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useState, useRef } from 'react';
import backgroundMusic from 'assets/music/Jazz Night - Golden Age Radio.mp3';

// icon
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faMusic } from '@fortawesome/free-solid-svg-icons';

// styling
import 'styles/header.css'

export const Header = () => {
// A variable importing the music file outside of the App function
// because the toggling didn't work inside it for some reason:
const bgMusic = new Audio(backgroundMusic);
bgMusic.loop = true;

const audioRef = useRef(bgMusic);

const [isPlaying, setIsPlaying] = useState(false);
// This little function plays the music when pressing the music button,
// and turns it off when pressing again.
const togglePlay = () => {
if (isPlaying) {
audioRef.current.pause();
setIsPlaying(false);
} else {
audioRef.current.play();
setIsPlaying(true);
}
}
return (
<header role="banner">
<section className="header__top">
<h1>Music Survey</h1>
<button type="submit" className="button" onClick={togglePlay}><FontAwesomeIcon icon={faMusic} className="button__icon" />Play some Jazz
</button>
</section>
<hr className="divider" />
</header>
)
}
35 changes: 35 additions & 0 deletions code/src/components/LandingPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

// image
import musicIllustration1 from 'assets/images/music file2-07.png';

// components
import ProgressBar from './ProgressBar';
import NextButton from './NextButton';

const LandingPage = ({ step, setStep, section, setSection }) => {
return (
<>
<h2>Welcome to this survey!</h2>
<ul>
<li>You will get to answer five questions related to music.</li>
<li>It will take you a maximum of five minutes to fill out.</li>
<li>All questions that are required are marked as required.</li>
</ul>
<NextButton
whatQuestionNext="firstQuestion"
section={section}
setSection={setSection}
currentState="Whatever"
defaultState=""
message=""
step={step}
setStep={setStep}
whatStepNext="1" />
<img src={musicIllustration1} alt="illustration" className="illustration" aria-hidden="true" />
<ProgressBar step={step} />
</>
)
}

export default LandingPage;
31 changes: 31 additions & 0 deletions code/src/components/NextButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable max-len */
import React, { useState } from 'react';
import Alert from './Alert';

const NextButton = ({ setStep, whatStepNext, setSection, currentState, defaultState, whatQuestionNext, message }) => {
const handleNextStep = () => {
setStep(whatStepNext)
};
const [alert, setAlert] = useState(false);
const handleNextButton = () => {
if (currentState !== defaultState) {
setSection(whatQuestionNext);
handleNextStep();
} else {
setAlert(true)
}
};
return (
<div className="form__alertAndButton">
{alert && <Alert message={message} />}
<button
type="button"
className="button"
onClick={handleNextButton}>Next question
</button>
</div>

)
}

export default NextButton;
18 changes: 18 additions & 0 deletions code/src/components/PreviousButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable max-len */
import React from 'react';

const PreviousButton = ({ setStep, whatStepBefore, setSection, whatQuestionPrevious }) => {
const handlePreviousButton = () => {
setSection(whatQuestionPrevious);
setStep(whatStepBefore)
};
return (
<button
type="button"
className="button"
onClick={handlePreviousButton}>Go back
</button>
)
}

export default PreviousButton;
12 changes: 12 additions & 0 deletions code/src/components/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable jsx-a11y/no-redundant-roles */
import React from 'react';

const ProgressBar = ({ step }) => {
return (
<section className="form__progressBar">
<progress id="progress" className="progress" aria-hidden="true" value={step} aria-valuemin="0" aria-valuenow={step} aria-valuemax="5" max="5" />
</section>
)
}

export default ProgressBar;
60 changes: 60 additions & 0 deletions code/src/components/QuestionCheckboxes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';

// components
import NextButton from './NextButton';
import PreviousButton from './PreviousButton';
import ProgressBar from './ProgressBar';

import 'styles/form.css'

const QuestionCheckboxes = ({ step, setStep, section, setSection, devices, setDevices }) => {
const devicesGroup = ['Mobile phone', 'Computer', 'Record player', 'CD player', 'MP3-Player', 'Casette player', 'Other'];
const handleDevicesChange = (deviceValue) => {
if (devices.includes(deviceValue)) {
setDevices(devices.filter((item) => item !== deviceValue))
} else {
setDevices([...devices, deviceValue])
}
}
return (
<>
<h2>Music devices (Step 3 of 5)</h2>
<fieldset>
<legend>What device(s) do you use to listen to music?<span>Required</span></legend>
{devicesGroup.map((device) => (
<label key={device} htmlFor={device} className="form-control">
<input
type="checkbox"
autoComplete="off"
checked={devices.includes(device)}
onChange={() => handleDevicesChange(device)}
name="platform"
id={device} />{device}
</label>
))}
</fieldset>
<section className="form__navigation">
<PreviousButton
whatQuestionPrevious="secondQuestion"
section={section}
setSection={setSection}
setStep={setStep}
whatStepBefore="2" />
<NextButton
whatQuestionNext="fourthQuestion"
section={section}
setSection={setSection}
currentState={devices.length}
defaultState={0}
message="Please select a device"
step={step}
setStep={setStep}
whatStepNext="4" />
</section>
<ProgressBar
step={step} />
</>
)
}

export default QuestionCheckboxes;
Loading