-
Notifications
You must be signed in to change notification settings - Fork 430
Adopt a dog survey #436
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
base: master
Are you sure you want to change the base?
Adopt a dog survey #436
Changes from all commits
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,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. | ||
| So this is an unfinished project. I still need to style it and make it more accesible. i focused on getting the react code and components to work. | ||
|
|
||
| ## 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? | ||
|
|
||
| ## 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://willowy-paletas-c102cf.netlify.app/ | ||
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 |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| 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>Adopt a dog survey</title> | ||
|
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. Happy to see that you changed the title, many people miss this one :) |
||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,41 @@ | ||
| import React from 'react'; | ||
| import React, { useState } from 'react'; | ||
| import { Name } from './components/Name'; | ||
| import { Experience } from './components/Experience'; | ||
| import { Size } from './components/Size'; | ||
| import { Summary } from './components/Summary'; | ||
| import './index.css'; | ||
|
|
||
| export const App = () => { | ||
| const [step, setStep] = useState(1); | ||
| const [name, setName] = useState(''); | ||
| const [experience, setExperience] = useState(''); | ||
| const [size, setSize] = useState(''); | ||
|
|
||
| function handleStepIncrease() { | ||
| setStep(step + 1); | ||
| } | ||
| return ( | ||
| <div> | ||
| Find me in src/app.js! | ||
| <div className="content-container"> | ||
| {step === 1 && ( | ||
| <div className="name-container"> | ||
| <Name name={name} setName={setName} /> | ||
| </div> | ||
| )} | ||
| {step === 2 && ( | ||
| <Experience experience={experience} setExperience={setExperience} /> | ||
| )} | ||
| {step === 3 && ( | ||
| <> | ||
| <Size size={size} setSize={setSize} /> | ||
| <button type="button" onClick={handleStepIncrease}>Submit</button> | ||
| </> | ||
| )} | ||
| {step >= 4 && ( | ||
| <Summary name={name} experience={experience} size={size} /> | ||
| )} | ||
| {step < 3 && ( | ||
| <button type="button" onClick={handleStepIncrease}>Next</button> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| .dropdown { | ||
| display: flex; | ||
| margin-top: 5%; | ||
| align-items: center; | ||
| justify-content: center; | ||
| flex-direction: column; | ||
| width: 100%; | ||
| height: auto; | ||
| } | ||
|
|
||
| .dropdown form { | ||
| display: block; | ||
| background-color: antiquewhite; | ||
| } | ||
|
|
||
| .dropdown select { | ||
| border-top-style: hidden; | ||
| border-right-style: hidden; | ||
| border-left-style: hidden; | ||
| border-bottom-style: groove; | ||
| outline: none; | ||
| font-weight: 200; | ||
| font-size: 1.2em; | ||
| width: 100%; | ||
| padding: 0.5em 1em; | ||
| text-align: center; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react'; | ||
| import './Experience.css'; | ||
|
|
||
| export const Experience = ({ experience, setExperience }) => { | ||
| const handleExpChange = (event) => { | ||
| setExperience(event.target.value); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="dropdown"> | ||
| <span className="experience-title">Do you have previous dog owner experience?</span> | ||
| <form> | ||
| <select value={experience} onChange={handleExpChange}> | ||
| <option value="none" selected>Select an Option</option> | ||
| <option value="yes">Yes</option> | ||
| <option value="no">No</option> | ||
| </select> | ||
| </form> | ||
| </div> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| .name-text { | ||
| display: flex; | ||
| width:100%; | ||
| margin: 10% 5% 5% 5%; | ||
| align-items: center; | ||
| justify-content: center; | ||
| flex-direction: column; | ||
|
|
||
| } | ||
|
|
||
| #name { | ||
| border-top-style: hidden; | ||
| border-right-style: hidden; | ||
| border-left-style: hidden; | ||
| border-bottom-style: groove; | ||
| outline: none; | ||
| width: 100%; | ||
| height: auto; | ||
| font-weight: 200; | ||
| font-size: 1.2em; | ||
| text-align: center; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React from 'react'; | ||
| import './Name.css'; | ||
|
|
||
| export const Name = ({ name, setName }) => { | ||
| const handleNameChange = (event) => { | ||
| setName(event.target.value); | ||
| } | ||
| return ( | ||
| <div className="name-text"> | ||
| <h1>Welcome</h1> | ||
| <p>Please fill out this form to adopt a dog</p> | ||
| <input type="text" id="name" value={name} placeholder="What is your name?" onChange={handleNameChange} /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react' | ||
|
|
||
| const sizes = ['XS', 'S', 'M', 'L', 'XL'] | ||
|
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. Good job with adding the different sizes in an array. |
||
|
|
||
| export const Size = ({ size, setSize }) => { | ||
| const handleSizeChange = (event) => { | ||
| setSize(event.target.value) | ||
| } | ||
| return ( | ||
| <div className="size-container"> | ||
| <p>What dog size would you prefer to adopt?</p> | ||
| <form> | ||
| {sizes.map((singleSize) => ( | ||
| <label htmlFor="size" key={singleSize}> | ||
| <input type="radio" className="size-input" value={singleSize} checked={singleSize === size} onChange={handleSizeChange} />{singleSize} | ||
| </label> | ||
| ))} | ||
| </form> | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from 'react' | ||
|
|
||
| export const Summary = ({ name, experience, size }) => { | ||
| return ( | ||
| <div> | ||
| <p>Your name: {name}</p> | ||
| <p>Previous dog experience: {experience}</p> | ||
| <p>Prefered size to adopt: {size}</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.
I still think you made a good job by making it work in such a nice way!