Skip to content

Commit

Permalink
Merge branch 'main' into mm-307-question-iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-amy authored Aug 1, 2024
2 parents 2030554 + 0e8e65c commit 1ad6cd9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
19 changes: 19 additions & 0 deletions src/Home/Home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,23 @@
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

.form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

label {
margin: 10pix
}

input {
margin: 10px;
}

button {
margin: 10px;
}
20 changes: 0 additions & 20 deletions src/Home/Home.test.tsx

This file was deleted.

11 changes: 3 additions & 8 deletions src/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { useNavigate } from "react-router-dom";
import DisplayBackgroundImage from '../images/DisplayBackgroundImage';
import './Home.scss'

interface getUserProp{
interface HomeProps{
username:string;
setUsername:(uname:string)=>void;
}

function Home(props:getUserProp) {
function Home(props:HomeProps) {

//const [username, setUsername] = useState("");
const [submitStatus, setSubmitStatus] = useState(false);

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
Expand All @@ -29,24 +28,20 @@ function Home(props:getUserProp) {
return (
<>
<main className="home-content" style={{ backgroundImage: `url(${homeBackgroundImage})` }}>

{/* Other components and content */}
<form onSubmit={handleSubmit}>
<form className="form" onSubmit={handleSubmit}>
<label>Enter name:
<input type="text"
value={props.username}
//onChange={username => setUsername(username.target.value)}
onChange={(username) => {props.setUsername(username.target.value)}}
/>
</label>
<button type="submit">Submit</button>
{submitStatus ? <p>Welcome {props.username}!</p> : null}
</form>

<button className="startQuizButton" onClick={routeChange}>
Start quiz
</button>

</main>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/Menu/MenuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// list of the menu options that will be displayed when clicking on hamburger button
export const menuItems = [
{ label: 'Home', link: '/' },
{ label: 'Quiz', link: '' },
{ label: 'Quiz', link: '/quiz' },
];
4 changes: 2 additions & 2 deletions src/Quiz/Quiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { QuestionDisplay } from "../QuestionDisplay/QuestionDisplay"
import { getQuizQuestions } from "../getQuizQuestions/getQuizQuestions"
import { useState, useEffect } from "react";

interface getUserProp{
interface QuizProps{
username:string;
}

Expand All @@ -25,7 +25,7 @@ export function Quiz (props:getUserProp) {
setCurrentIndex(currentIndex + 1);
}
}

return (
<div>
User : {props.username}
Expand Down

0 comments on commit 1ad6cd9

Please sign in to comment.