Parcourir la source

created quiz component countdown timer

develop
Ajay_S il y a 3 ans
Parent
révision
db865c86f4
7 fichiers modifiés avec 44 ajouts et 44 suppressions
  1. +1
    -1
      src/pages/Quiz/Options.module.scss
  2. +1
    -1
      src/pages/Quiz/Options.tsx
  3. +27
    -2
      src/pages/Quiz/Question.tsx
  4. +5
    -38
      src/pages/Quiz/Quiz.module.scss
  5. +3
    -1
      src/pages/Quiz/Quiz.tsx
  6. +3
    -0
      src/pages/preliminaryRound/PreliminaryRound.module.scss
  7. +4
    -1
      src/pages/preliminaryRound/PreliminaryRound.tsx

+ 1
- 1
src/pages/Quiz/Options.module.scss Voir le fichier

@@ -7,7 +7,7 @@
justify-content: space-around;
height: 40vh;

.options {
ion-item {
width: 99%;
margin: 0 auto;
--background: white;


+ 1
- 1
src/pages/Quiz/Options.tsx Voir le fichier

@@ -15,7 +15,7 @@ const Options: React.FC<OwnProps> = (props) => {

const options = props.options.map((option, key) => {
return (
<IonItem lines='none' key={key} className={styles.options + " " + (option === selected) ? styles.highlighted : ""}>
<IonItem lines='none' key={key} className={(option === selected) ? styles.highlighted : ""}>
<IonLabel>{option}</IonLabel>
<IonRadio mode='md' slot="start" value={option} />
</IonItem>


+ 27
- 2
src/pages/Quiz/Question.tsx Voir le fichier

@@ -1,4 +1,4 @@
import { useState } from "react";
import { createRef, useEffect, useRef, useState } from "react";
import styles from "./Question.module.scss";


@@ -8,8 +8,31 @@ interface OwnProp {
timeLimit: number;
}


let timeout: NodeJS.Timeout;

const Question: React.FC<OwnProp> = (props) => {

const COUNTDOWN_AMOUNT_TOTAL = props.timeLimit * 60;

const [seconds, setSeconds] = useState<number>(COUNTDOWN_AMOUNT_TOTAL);

const displaySeconds = seconds % 60;
const displayMinutes = Math.floor(seconds / 60);

useEffect(() => {

if (seconds > 0) {
timeout = setTimeout(() => {
setSeconds((state) => state - 1);
}, 1000);
} else {
clearTimeout(timeout);
}

return () => clearTimeout(timeout);;
}, [seconds]);

return (
<section>
<div className={styles.questionHolder}>
@@ -22,7 +45,9 @@ const Question: React.FC<OwnProp> = (props) => {

<div className={styles.quizTimer}>
<div className={styles.border}>
<div className={styles.time}>01:00</div>
<div className={styles.time}>
{`${displayMinutes < 10 ? "0" : ""}${displayMinutes}:${displaySeconds < 10 ? "0" : ""}${displaySeconds}`}
</div>
</div>
</div>
</div>


+ 5
- 38
src/pages/Quiz/Quiz.module.scss Voir le fichier

@@ -34,6 +34,11 @@
align-self: flex-end;
}

a {
text-decoration: none;
align-self: flex-end;
}

ion-icon {
color: white;
margin-right: 3rem;
@@ -43,44 +48,6 @@

}
}

// .questionHolder {
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: space-between;
// text-align: center;
// color: white;
// width: 90%;
// margin: 0 auto;
// height: 27vh;
// background-image: url("../../assets/icons/desktop-particles.svg");
// background-position: center;
// background-repeat: no-repeat;
// background-size: 150% 150%;

// .questionNumber {
// font-size: 1.3rem;
// font-weight: 600;
// }
// .question {
// font-size: 1.8rem;
// font-weight: 300;
// }

// .quizTimer {
// .border {
// width: 6rem;
// height: 6rem;
// border-radius: 50%;
// border: 0.2rem solid #6BD534;
// .time {
// margin-top: 1.8rem;
// font-size: 1.4rem;
// }
// }
// }
// }
}

.quizOptions {


+ 3
- 1
src/pages/Quiz/Quiz.tsx Voir le fichier

@@ -31,7 +31,9 @@ const Quiz: React.FC = () => {
<div className={styles.upfold}>
<header className={styles.header}>
<h4 className={styles.heading}>Quiz</h4>
<IonIcon icon={closeOutline} />
<Link to="/interviewRounds" >
<IonIcon icon={closeOutline} />
</Link>
</header>

<Question question='How would you correctly display, “Hello, how are you?”?'


+ 3
- 0
src/pages/preliminaryRound/PreliminaryRound.module.scss Voir le fichier

@@ -75,6 +75,9 @@
}
}

a {
text-decoration: none;
}
ion-button {
--background: var(--primary-button-color);
font-weight: 500;


+ 4
- 1
src/pages/preliminaryRound/PreliminaryRound.tsx Voir le fichier

@@ -6,6 +6,7 @@ import StepHeader from '../../components/stepsHeader/StepHeader';
import questionIcon from '../../assets/icons/question-circle-fill.svg';
import checkIcon from '../../assets/icons/check-circle-fill.svg';
import timeIcon from '../../assets/icons/time.svg';
import { Link } from "react-router-dom";

const PreliminaryRound: React.FC = () => {
return (
@@ -38,7 +39,9 @@ const PreliminaryRound: React.FC = () => {
</div>
</div>

<IonButton shape="round" expand='block'>Start quiz</IonButton>
<Link to="./quiz">
<IonButton shape="round" expand='block'>Start quiz</IonButton>
</Link>

<div className={styles.wish}>All the best!</div>
</div>


Chargement…
Annuler
Enregistrer