diff --git a/src/App.tsx b/src/App.tsx index ca41992..260a357 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -39,7 +39,6 @@ import Celebration from './pages/celebration/Celebration'; import SignaturePhoto from './pages/joiningLetter/SignaturePhoto'; import TechinicalInterviewResults from './pages/technicalInterview/TechinicalInterviewResults'; - setupIonicReact(); const App: React.FC = () => ( diff --git a/src/components/RadioButton/RadioButton.module.scss b/src/components/RadioButton/RadioButton.module.scss new file mode 100644 index 0000000..151eaea --- /dev/null +++ b/src/components/RadioButton/RadioButton.module.scss @@ -0,0 +1,29 @@ +.radioHolder { + display: flex; + align-items: center; + min-width: 33.5rem; + margin: 0 auto; + --background: white; + border: 1px solid #DBDBDB; + border-radius: 25px; + height: 4rem; + + .icon { + width: 2rem; + height: 2rem; + margin-left: 1.5rem; + } + .option { + margin-left: 2rem; + color: #626262; + font-size: 1.2rem; + font-weight: 200; + } + + &.highlighted { + box-shadow: 0px 0px 10px #00000029; + .icon { + color: var(--primary-button-color); + } + } +} \ No newline at end of file diff --git a/src/components/RadioButton/RadioButton.tsx b/src/components/RadioButton/RadioButton.tsx new file mode 100644 index 0000000..a0ba9f7 --- /dev/null +++ b/src/components/RadioButton/RadioButton.tsx @@ -0,0 +1,35 @@ +import styles from "./RadioButton.module.scss"; +import { radioButtonOff, radioButtonOn } from "ionicons/icons"; +import { IonIcon } from "@ionic/react"; +import { useEffect, useState } from "react"; + +interface OwnProps { + option: string; + isChecked: boolean; + isHighlighted?: boolean; +} + +const RadioButton: React.FC = (props) => { + + const [icon, setIcon] = useState(radioButtonOff); + + useEffect(() => { + if (props.isChecked) { + setIcon(radioButtonOn); + } else { + setIcon(radioButtonOff); + } + + }, [props.isChecked]); + + return ( +
+
+ +
{props.option}
+
+
+ ); +} + +export default RadioButton; \ No newline at end of file diff --git a/src/mockData/QuizDetails.ts b/src/mockData/QuizDetails.ts index 10a70a2..435eb6c 100644 --- a/src/mockData/QuizDetails.ts +++ b/src/mockData/QuizDetails.ts @@ -12,7 +12,7 @@ const QUIZ_DETAILS: QuizDetails[] = [ ], answer: ["System.out.println('Hello, how are you?');"], result: false, - timeLimit: 5, + timeLimit: 5000, type: OptionType.SINGLE_SELECT }, { @@ -25,7 +25,7 @@ const QUIZ_DETAILS: QuizDetails[] = [ ], answer: ["alert('Hello World');"], result: false, - timeLimit: 10, + timeLimit: 5, type: OptionType.SINGLE_SELECT }, @@ -63,6 +63,19 @@ const QUIZ_DETAILS: QuizDetails[] = [ timeLimit: 35, type: OptionType.MULTI_SELECT }, + { + question: "is javascript", + options: [ + "A", + "B", + "C", + "D" + ], + answer: ["B", "C"], + result: false, + timeLimit: 35, + type: OptionType.MULTI_SELECT + } ]; export default QUIZ_DETAILS; \ No newline at end of file diff --git a/src/pages/quiz/Options.tsx b/src/pages/quiz/Options.tsx index ca190be..b70c575 100644 --- a/src/pages/quiz/Options.tsx +++ b/src/pages/quiz/Options.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react'; import { Link } from 'react-router-dom'; import styles from './Options.module.scss'; import { OptionType } from '../../models/QuizDetails' +import RadioButton from '../../components/RadioButton/RadioButton'; interface OwnProps { options: string[] | undefined; @@ -22,10 +23,11 @@ const Options: React.FC = (props) => { const inputRef = useRef(null); useEffect(() => { - setSelected(undefined); + setSelected(""); setSelectedOptions([]); setTextInput(""); - }, [props.options]); + + }, [props.questionNumber]); const selectChecked = (option: string) => { let newOption: string[] = []; @@ -43,7 +45,8 @@ const Options: React.FC = (props) => { setAnswers(answers + 1); } } else if (props.type === "multiSelect") { - if (props.answer.length === selectedOptions.length && props.answer.sort().join(',') === selectedOptions.sort().join(',')) { + if (props.answer.length === selectedOptions.length && + props.answer.sort().join(',') === selectedOptions.sort().join(',')) { setAnswers(answers + 1); } @@ -55,21 +58,22 @@ const Options: React.FC = (props) => { } const handleInput = () => { - setTextInput(inputRef.current?.value!) + setTextInput(inputRef.current?.value!); } const setAnswer = () => { localStorage.setItem("answer", answers.toString()); } + const getAnswer = () => { + } const options = props.options!.map((option, key) => { return ( - - {option} - - +
setSelected(option)}> + +
); }); @@ -92,9 +96,9 @@ const Options: React.FC = (props) => {
{props.type === "singleSelect" && - setSelected(e.detail.value)} allowEmptySelection={true} className={styles.options}> +
{options} - +
} {props.type === "multiSelect" &&