diff --git a/web-app/app/(profile)/question.tsx b/web-app/app/(profile)/question.tsx new file mode 100644 index 0000000..255e569 --- /dev/null +++ b/web-app/app/(profile)/question.tsx @@ -0,0 +1,133 @@ +"use client"; + +import * as React from "react" +import { Input } from "../../components/ui/input"; +import { Label } from "../../components/ui/label"; + +import { cn } from "@/lib/utils" +import { Textarea } from "../../components/ui/textarea"; +import { useState } from "react"; + +type QuestionProps = { + question: string; + questionDataName: string; +} + +type QuestionPropsScale = QuestionProps & { + scaleOptions: any[]; +} + +// /** +// * The red star next to a required question. +// * @param required Whether or not to display the star. +// */ +// function QuestionRequiredStar({ required }: { required: boolean }) { +// if (required) { +// return ( +// * +// ) +// } +// return (); +// } + +// /** +// * Component with an input (like a radio or checkbox) with a label below it. +// * The width of the label does not effect the width of the component. +// * @param textLabel The label below the option item. +// * @param dataName The name in the form of the response. +// * @param type The type of input (like "checkbox", "radio"). +// */ +// function QuestionOptionItem({ textLabel, dataName, type }: { textLabel: string, dataName: string, type: string }) { +// return ( + +// ) +// } + +/** + * Displays the options for a question and aligns them, along with the question text itself. + * Used to align radio and multiple choice questions. + * @param children The question text component. + * @param items The `QuestionOptionItem`s to select from. + */ +function QuestionScaleContainer({ children, items }: React.ComponentProps<"div"> & { items: any[] }) { + return (
+

+ {children} +

+
+ {items} +
+
); +} + +/** + * A radio question (select one). + */ +function QuestionScale({ question, questionDataName, scaleOptions }: QuestionPropsScale) { + const items = []; + + for (let i = 0; i < scaleOptions.length; i++) { + const id = `${questionDataName}-radio-${question}`; + items.push( +
+ + +
+ ); + } + + return ({question}); +} + +/** + * A checkbox question (select multiple). + */ +function QuestionScaleMultiple({ question, questionDataName, scaleOptions }: QuestionPropsScale) { + const items = []; + + for (let i = 0; i < scaleOptions.length; i++) { + const id = `${questionDataName}-radio-${question}`; + items.push( +
+ + +
+ ) + } + + return ({question}); +} + +/** + * A freeform textarea question. + */ +function QuestionFreeform({ question, questionDataName }: QuestionProps) { + return ( +
+

{question}

+