-
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
MultiStepForm - Nella and Cholpon #85
Open
nella-x
wants to merge
15
commits into
Technigo:main
Choose a base branch
from
nella-x: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
15 commits
Select commit
Hold shift + click to select a range
45f43af
starting the project
nella-x 9249b9f
nellas branch hello
nella-x 80b67be
cholpons branch hello
nella-x d2049ae
Merge branch 'dev' of https://github.com/nella-x/project-survey-vite …
nella-x 130c910
files connected
nella-x 444b19c
update birthday.jsx
nella-x 5ed7d8b
make both day and month required
nella-x c45f367
trying to merge
nella-x f89662d
added zodiac signs, predictions, updated buttons
nella-x 1032f7c
css styling
nella-x ea32aca
design for mobile version
nella-x 8f098f8
worked on css and responsive design
nella-x bebedae
added padding for p
nella-x bc260fc
name input label and id
nella-x eb94dc2
updated readme
cholpoun 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
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,13 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Survey - Project - Week 6</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Survey - Project - Week 6</title> | ||
|
||
<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=Afacad+Flux:wght@100..1000&family=Cinzel:wght@400..900&family=Josefin+Sans:ital,wght@0,100..700;1,100..700&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" | ||
rel="stylesheet"> | ||
|
||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
|
||
</html> |
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,3 +1,10 @@ | ||
import { MultiStepForm } from "./components/MultiStepForm.jsx"; | ||
|
||
export const App = () => { | ||
return <div>Find me in src/app.jsx!</div>; | ||
return ( | ||
<> | ||
<MultiStepForm /> | ||
</> | ||
); | ||
}; | ||
|
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,91 @@ | ||
import { useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
const daysInMonth = (month) => { | ||
return new Date(2024, month + 1, 0).getDate(); // Fix month index | ||
}; | ||
|
||
const months = [ | ||
'January', | ||
'February', | ||
'March', | ||
'April', | ||
'May', | ||
'June', | ||
'July', | ||
'August', | ||
'September', | ||
'October', | ||
'November', | ||
'December', | ||
]; | ||
|
||
export const DayDropdown = ({ onChange, selectedMonth, selectedDay }) => { | ||
const maxDays = selectedMonth ? daysInMonth(selectedMonth - 1) : 31; | ||
|
||
return ( | ||
<select onChange={(e) => onChange(parseInt(e.target.value, 10) || null)} value={selectedDay || ""}> | ||
<option value="">Day</option> | ||
{Array.from({ length: maxDays }, (_, i) => i + 1).map(day => ( | ||
<option key={day} value={day}> | ||
{day} | ||
</option> | ||
))} | ||
</select> | ||
); | ||
}; | ||
|
||
DayDropdown.propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
selectedMonth: PropTypes.number, | ||
selectedDay: PropTypes.number, | ||
}; | ||
|
||
export const MonthDropdown = ({ onChange, selectedMonth }) => { | ||
return ( | ||
<select onChange={(e) => onChange(parseInt(e.target.value, 10) || null)} value={selectedMonth || ""}> | ||
<option value="">Month</option> | ||
{months.map((month, index) => ( | ||
<option key={month} value={index + 1}> | ||
{month} | ||
</option> | ||
))} | ||
</select> | ||
); | ||
}; | ||
|
||
MonthDropdown.propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
selectedMonth: PropTypes.number, | ||
}; | ||
|
||
export const Form = () => { | ||
const [selectedDay, setSelectedDay] = useState(null); | ||
const [selectedMonth, setSelectedMonth] = useState(null); | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
console.log("Selected Day:", selectedDay); | ||
console.log("Selected Month:", selectedMonth); | ||
}; | ||
|
||
// Kontrollera att både dag och månad är giltiga | ||
const isFormValid = selectedDay !== null && selectedMonth !== null; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<MonthDropdown | ||
onChange={(month) => setSelectedMonth(month)} | ||
selectedMonth={selectedMonth} | ||
/> | ||
<DayDropdown | ||
onChange={(day) => setSelectedDay(day)} | ||
selectedMonth={selectedMonth} | ||
selectedDay={selectedDay} | ||
/> | ||
<button type="submit" disabled={!isFormValid}> | ||
Submit | ||
</button> | ||
</form> | ||
); | ||
}; |
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,30 @@ | ||
import PropTypes from "prop-types"; | ||
|
||
export const Categories = ({ updateFormData, value }) => { | ||
const handleRadioChange = (event) => { | ||
updateFormData(event.target.value); // Correctly updating formData.categories | ||
}; | ||
|
||
return ( | ||
<div className="radio-box"> | ||
<label>Choose an option:</label> | ||
{["Career", "Love life", "Personal life"].map((option) => ( | ||
<label key={option} className={`custom-radio ${value === option ? "selected" : ""}`}> | ||
<input | ||
type="radio" | ||
value={option} | ||
checked={value === option} | ||
onChange={handleRadioChange} | ||
/> | ||
<span>{option}</span> | ||
</label> | ||
))} | ||
</div> | ||
); | ||
|
||
// PropTypes validation | ||
Categories.propTypes = { | ||
updateFormData: PropTypes.func.isRequired, | ||
value: PropTypes.string.isRequired, | ||
}; | ||
} |
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.
nice to do a check for disable the button