diff --git a/packages/worksheet/src/components/HTMLPrint.tsx b/packages/worksheet/src/components/HTMLPrint.tsx new file mode 100644 index 00000000..f436cf4e --- /dev/null +++ b/packages/worksheet/src/components/HTMLPrint.tsx @@ -0,0 +1,18 @@ +// Lib +import * as React from "react"; + +// Interface +export interface IHtmlPrint { + html: string; +} + +// Utility Component that returns a div using a markup +// TODO: find an alternate way to avoid using innerHTML +const HtmlPrint: React.FC = ({ html }) => { + const createMarkup = (markup) => { + return { __html: markup }; + }; + return
; +}; + +export default HtmlPrint; diff --git a/packages/worksheet/src/components/QuestionBox/QuestionOption.tsx b/packages/worksheet/src/components/QuestionBox/QuestionOption.tsx new file mode 100644 index 00000000..619390e3 --- /dev/null +++ b/packages/worksheet/src/components/QuestionBox/QuestionOption.tsx @@ -0,0 +1,42 @@ +// Lib +import * as React from "react"; +import { HStack } from "native-base"; +import { BodyMedium, overrideColorTheme } from "@shiksha/common-lib"; + +// Components +import HtmlPrint from "components/HTMLPrint"; + +// Constants +import colorTheme from "../../colorTheme"; +const alphabet = ["a", "b", "c", "d", "e", "f"]; +const colors = overrideColorTheme(colorTheme); + +// Interface +export interface IQuestionOption { + item: any; + isAnswerHide: boolean; + index: number; +} + +// Returns a single option for a Question +const QuestionOption: React.FC = ({ + item, + isAnswerHide, + index, +}) => { + return ( + + + {alphabet[index] + ". "} + + + + + + ); +}; + +export default QuestionOption; diff --git a/packages/worksheet/src/components/QuestionBox/index.js b/packages/worksheet/src/components/QuestionBox/index.js deleted file mode 100644 index 37827669..00000000 --- a/packages/worksheet/src/components/QuestionBox/index.js +++ /dev/null @@ -1,79 +0,0 @@ -import React from "react"; -import { Box, HStack, VStack } from "native-base"; -import { colourPalette } from "constants/colours"; -import "../../App.css"; -import { BodyMedium, overrideColorTheme } from "@shiksha/common-lib"; -import { useTranslation } from "react-i18next"; -import colorTheme from "../../colorTheme"; -const colors = overrideColorTheme(colorTheme); - -const styles = { questionDiv: { display: "flex" } }; - -const HtmlPrint = ({ html }) => { - const createMarkup = (markup) => { - return { __html: markup }; - }; - return
; -}; - -const QuestionBox = ({ questionObject, isAnswerHide, infoIcon, _box }) => { - const { t } = useTranslation(); - - const alphabet = ["a", "b", "c", "d", "e", "f"]; - - return ( - - - -
- -
- {infoIcon} -
-
- {!questionObject?.options && questionObject?.answer ? ( - - - - ) : questionObject?.options ? ( - - - {questionObject.options?.map((item, index) => { - return ( - - - {alphabet[index] + ". "} - - - - - - ); - })} - - - ) : ( - - )} -
- ); -}; - -export default QuestionBox; diff --git a/packages/worksheet/src/components/QuestionBox/index.tsx b/packages/worksheet/src/components/QuestionBox/index.tsx new file mode 100644 index 00000000..77516c4f --- /dev/null +++ b/packages/worksheet/src/components/QuestionBox/index.tsx @@ -0,0 +1,79 @@ +// Lib +import React from "react"; +import { Box, HStack, VStack } from "native-base"; + +// Styles +import "../../App.css"; + +// Constants +import { colourPalette } from "constants/colours"; +import colorTheme from "colorTheme"; + +// Components +import HtmlPrint from "components/HTMLPrint"; +import QuestionOption from "./QuestionOption"; + +const styles = { questionDiv: { display: "flex" } }; + +// Interface +export interface IQuestionBox { + questionObject: any; + isAnswerHide: boolean; + infoIcon: Object; + _box: Object; +} + +// Renders a box for a question using an object +const QuestionBox: React.FC = ({ + questionObject, + isAnswerHide, + infoIcon, + _box, +}) => { + return ( + + + +
+ +
+ {infoIcon} +
+
+ {!questionObject?.options && questionObject?.answer ? ( + + + + ) : questionObject?.options ? ( + + + {questionObject.options?.map((item, index) => ( + + ))} + + + ) : ( + + )} +
+ ); +}; + +export default QuestionBox;