Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCQ component added and wrote stories for that #1

Merged
merged 7 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
MCQ component added and wrote stories for that
  • Loading branch information
Sourav12061999 committed May 9, 2022
commit ded7627da60e72ac7945443226a0ee8aa00636ed
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;
}
Sparkenstein marked this conversation as resolved.
Show resolved Hide resolved