Ver código fonte

isCheckbox prop to RadioButton component and replaced it with Ion checkbox

develop
Ajay_S 3 anos atrás
pai
commit
a0d40d5793
5 arquivos alterados com 20 adições e 23 exclusões
  1. +2
    -1
      src/components/RadioButton/RadioButton.module.scss
  2. +5
    -1
      src/components/RadioButton/RadioButton.tsx
  3. +6
    -6
      src/mockData/QuizDetails.ts
  4. +1
    -1
      src/pages/preliminaryRoundResults/PreliminaryRoundResults.tsx
  5. +6
    -14
      src/pages/quiz/Options.tsx

+ 2
- 1
src/components/RadioButton/RadioButton.module.scss Ver arquivo

@@ -7,7 +7,7 @@
border: 1px solid #DBDBDB; border: 1px solid #DBDBDB;
border-radius: 25px; border-radius: 25px;
height: 4rem; height: 4rem;
.icon { .icon {
width: 2rem; width: 2rem;
height: 2rem; height: 2rem;
@@ -24,6 +24,7 @@
box-shadow: 0px 0px 10px #00000029; box-shadow: 0px 0px 10px #00000029;
.icon { .icon {
color: var(--primary-button-color); color: var(--primary-button-color);
transform: scale(1.1);
} }
} }
} }

+ 5
- 1
src/components/RadioButton/RadioButton.tsx Ver arquivo

@@ -1,5 +1,5 @@
import styles from "./RadioButton.module.scss"; import styles from "./RadioButton.module.scss";
import { radioButtonOff, radioButtonOn } from "ionicons/icons";
import { radioButtonOff, radioButtonOn, checkmarkCircle } from "ionicons/icons";
import { IonIcon } from "@ionic/react"; import { IonIcon } from "@ionic/react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";


@@ -7,6 +7,7 @@ interface OwnProps {
option: string; option: string;
isChecked: boolean; isChecked: boolean;
isHighlighted?: boolean; isHighlighted?: boolean;
isCheckBox?: boolean;
} }


const RadioButton: React.FC<OwnProps> = (props) => { const RadioButton: React.FC<OwnProps> = (props) => {
@@ -16,6 +17,9 @@ const RadioButton: React.FC<OwnProps> = (props) => {
useEffect(() => { useEffect(() => {
if (props.isChecked) { if (props.isChecked) {
setIcon(radioButtonOn); setIcon(radioButtonOn);
if (props.isCheckBox) {
setIcon(checkmarkCircle);
}
} else { } else {
setIcon(radioButtonOff); setIcon(radioButtonOff);
} }


+ 6
- 6
src/mockData/QuizDetails.ts Ver arquivo

@@ -12,7 +12,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
], ],
answer: ["System.out.println('Hello, how are you?');"], answer: ["System.out.println('Hello, how are you?');"],
result: false, result: false,
timeLimit: 5000,
timeLimit: 60,
type: OptionType.SINGLE_SELECT type: OptionType.SINGLE_SELECT
}, },
{ {
@@ -25,7 +25,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
], ],
answer: ["alert('Hello World');"], answer: ["alert('Hello World');"],
result: false, result: false,
timeLimit: 5,
timeLimit: 30,
type: OptionType.SINGLE_SELECT type: OptionType.SINGLE_SELECT


}, },
@@ -39,7 +39,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
], ],
answer: ["B", "C"], answer: ["B", "C"],
result: false, result: false,
timeLimit: 60,
timeLimit: 120,
type: OptionType.MULTI_SELECT type: OptionType.MULTI_SELECT
}, },
{ {
@@ -47,7 +47,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
options: [], options: [],
answer: ["single threaded"], answer: ["single threaded"],
result: false, result: false,
timeLimit: 60,
timeLimit: 120,
type: OptionType.INPUT_TEXT type: OptionType.INPUT_TEXT
}, },
{ {
@@ -60,7 +60,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
], ],
answer: ["B", "C"], answer: ["B", "C"],
result: false, result: false,
timeLimit: 35,
timeLimit: 60,
type: OptionType.MULTI_SELECT type: OptionType.MULTI_SELECT
}, },
{ {
@@ -73,7 +73,7 @@ const QUIZ_DETAILS: QuizDetails[] = [
], ],
answer: ["B", "C"], answer: ["B", "C"],
result: false, result: false,
timeLimit: 35,
timeLimit: 60,
type: OptionType.MULTI_SELECT type: OptionType.MULTI_SELECT
} }
]; ];


+ 1
- 1
src/pages/preliminaryRoundResults/PreliminaryRoundResults.tsx Ver arquivo

@@ -18,7 +18,7 @@ const PreliminaryRoundResults: React.FC = () => {
<IonIcon src={goodJobIcon} /> <IonIcon src={goodJobIcon} />
<div className={styles.score}> <div className={styles.score}>
<h5>You have scored</h5> <h5>You have scored</h5>
<h5 className={styles.result}>{(parseInt(localStorage.getItem("answer")!) / Quiz_Details.length) * 100}%</h5>
<h5 className={styles.result}>{((parseInt(localStorage.getItem("answer")!) / Quiz_Details.length) * 100).toFixed(2)}%</h5>
</div> </div>
<p className={styles.description}> <p className={styles.description}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.


+ 6
- 14
src/pages/quiz/Options.tsx Ver arquivo

@@ -65,10 +65,6 @@ const Options: React.FC<OwnProps> = (props) => {
localStorage.setItem("answer", answers.toString()); localStorage.setItem("answer", answers.toString());
} }


const getAnswer = () => {

}

const options = props.options!.map((option, key) => { const options = props.options!.map((option, key) => {
return ( return (
<div key={key} onClick={() => setSelected(option)}> <div key={key} onClick={() => setSelected(option)}>
@@ -79,16 +75,12 @@ const Options: React.FC<OwnProps> = (props) => {


const MultiSelectOptions = props.options!.map((option, key) => { const MultiSelectOptions = props.options!.map((option, key) => {
return ( return (
<IonItem lines='none' key={key} className={(selectedOptions.includes(option)) ? styles.highlighted : ""}>
<div className={(selectedOptions.includes(option)) ? (styles.activeCheck + " " + styles.checkBoxHolder) : styles.checkBoxHolder}>
<IonCheckbox
slot="start"
mode='ios'
className={styles.checkBox}
onIonChange={e => selectChecked(option)} />
</div>
<IonLabel className={styles.multiSelectLabel}>{option}</IonLabel>
</IonItem>
<div key={key} onClick={() => selectChecked(option)}>
<RadioButton
isCheckBox={true}
option={option}
isChecked={selectedOptions.includes(option)} />
</div>
); );
}); });




Carregando…
Cancelar
Salvar