Skip to content

Commit

Permalink
MCQ component added and wrote stories for that
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourav12061999 committed May 9, 2022
1 parent 29b2c7b commit ded7627
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/MCQ/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Props,Options} from "./mcq.types"

const optionsArray:Array<Options>=[
{value:1,labelText:"Classes and IDs both are reusable"},
{value:2,labelText:"Classes are unique and IDs are reusable"},
{value:1,labelText:"IDs are unique and Classes are reusable"},
{value:1,labelText:"Both classes and IDs are reusable"},

]
const data:Props = {
question:"What is the difference between class and id in css",
description:"Classes and IDs in are something we have learned in unit-2",
required: true,
options:optionsArray,
currect_option:3,
orientation:"horizontal",
}
export default data;
27 changes: 27 additions & 0 deletions components/MCQ/mcq.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import MCQ from "./mcq";
import data from "./data";
export default {
title: "MCQ",
};

export const Horizontal = () => (
<MCQ
question={data.question}
description={data.description}
required={data.required}
options={data.options}
currect_option={data.currect_option}
orientation={data.orientation}
/>
);

export const Vertical = () => (
<MCQ
question={data.question}
description={data.description}
required={data.required}
options={data.options}
currect_option={data.currect_option}
orientation={"vertical"}
/>
);
14 changes: 14 additions & 0 deletions components/MCQ/mcq.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RadioGroup, Radio } from "@mantine/core";
import React from "react";
import { Props } from "./mcq.types";

export default function MCQ(props: Props) {
const { question, description, required, options , orientation } = props;
return (
<RadioGroup label={question} orientation={orientation} description={description} required={required}>
{options.map((option) => (
<Radio value={option.value.toString()} label={option.labelText}></Radio>
))}
</RadioGroup>
);
}
13 changes: 13 additions & 0 deletions components/MCQ/mcq.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type Props = {
question: string;
description: string;
options:Array<Options>;
required: boolean;
currect_option:number,
orientation:"horizontal" | "vertical",
}

export type Options = {
value: number;
labelText: string;
}

0 comments on commit ded7627

Please sign in to comment.