-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using a component rather than a page
- Loading branch information
1 parent
4cae6b8
commit 5381724
Showing
13 changed files
with
190 additions
and
179 deletions.
There are no files selected for viewing
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
14 changes: 8 additions & 6 deletions
14
components/quests/quizzes/endScreen.tsx → components/quizzes/endScreen.tsx
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
2 changes: 1 addition & 1 deletion
2
components/quests/quizzes/menu.tsx → components/quizzes/menu.tsx
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
4 changes: 2 additions & 2 deletions
4
components/quests/quizzes/progressBar.tsx → components/quizzes/progressBar.tsx
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "next"; | ||
import HomeScreen from "./homeScreen"; | ||
import styles from "../../styles/components/quests/quizzes.module.css"; | ||
import { FunctionComponent, ReactNode, useEffect, useState } from "react"; | ||
import Step from "./step"; | ||
import EndScreen from "./endScreen"; | ||
|
||
type QuizProps = { | ||
setMenu: (menu: ReactNode) => void; | ||
name: string; | ||
}; | ||
|
||
const Quiz: FunctionComponent<QuizProps> = ({ setMenu, name }) => { | ||
const [step, setStep] = useState<number>(-1); | ||
|
||
// TODO: Load data dynamically using quiz name | ||
const steps: Array<QuizStep> = [{}, {}, {}, {}]; | ||
|
||
useEffect(() => { | ||
if (step === -2) setMenu(null); | ||
}, [step]); | ||
|
||
return ( | ||
<div className={styles.mainContainer}> | ||
{step === -1 ? ( | ||
<HomeScreen setStep={setStep} /> | ||
) : step === steps.length ? ( | ||
<EndScreen setStep={setStep} /> | ||
) : ( | ||
<Step setStep={setStep} step={step} steps={steps} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Quiz; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { Dispatch, FunctionComponent, SetStateAction } from "react"; | ||
import QuizControls from "./quizControls"; | ||
import styles from "../../styles/components/quests/quizzes.module.css"; | ||
import ProgressBar from "./progressBar"; | ||
|
||
type StepProps = { | ||
setStep: Dispatch<SetStateAction<number>>; | ||
step: number; | ||
steps: Array<QuizStep>; | ||
}; | ||
|
||
const Step: FunctionComponent<StepProps> = ({ setStep, step, steps }) => { | ||
return ( | ||
<> | ||
<ProgressBar currentStep={step} totalSteps={steps.length} /> | ||
<div className={styles.content}> | ||
<button onClick={() => setStep((step) => step + 1)}>Ok</button> | ||
</div> | ||
<QuizControls setStep={setStep} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Step; |
Oops, something went wrong.