Updated the FillBlanks exercise and solution to the new design
This commit is contained in:
@@ -6,6 +6,7 @@ import clsx from "clsx";
|
||||
import reactStringReplace from "react-string-replace";
|
||||
import {CommonProps} from ".";
|
||||
import {Fragment} from "react";
|
||||
import Button from "../Low/Button";
|
||||
|
||||
export default function FillBlanksSolutions({prompt, solutions, text, userSolutions, onNext, onBack}: FillBlanksExercise & CommonProps) {
|
||||
const renderLines = (line: string) => {
|
||||
@@ -18,23 +19,46 @@ export default function FillBlanksSolutions({prompt, solutions, text, userSoluti
|
||||
|
||||
if (!userSolution) {
|
||||
return (
|
||||
<>
|
||||
<button className={clsx("border-2 rounded-xl px-4 text-gray-500 border-gray-500 my-2")}>{solution.solution}</button>
|
||||
</>
|
||||
<button
|
||||
className={clsx(
|
||||
"rounded-full hover:text-white hover:bg-mti-blue transition duration-300 ease-in-out my-1",
|
||||
userSolution && "px-5 py-2 text-center text-white bg-mti-blue-light",
|
||||
)}>
|
||||
{solution.solution}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
if (userSolution.solution === solution.solution) {
|
||||
return <button className={clsx("border-2 rounded-xl px-4 text-green-500 border-green-500 my-2")}>{solution.solution}</button>;
|
||||
return (
|
||||
<button
|
||||
className={clsx(
|
||||
"rounded-full hover:text-white hover:bg-mti-green transition duration-300 ease-in-out my-1",
|
||||
userSolution && "px-5 py-2 text-center text-white bg-mti-green-light",
|
||||
)}>
|
||||
{solution.solution}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
if (userSolution.solution !== solution.solution) {
|
||||
return (
|
||||
<>
|
||||
<button className={clsx("border-2 rounded-xl px-4 text-red-500 border-red-500 mr-1 my-2")}>
|
||||
<button
|
||||
className={clsx(
|
||||
"rounded-full hover:text-white hover:bg-mti-orange transition duration-300 ease-in-out my-1",
|
||||
userSolution && "px-5 py-2 text-center text-white bg-mti-orange-light",
|
||||
)}>
|
||||
{userSolution.solution}
|
||||
</button>
|
||||
<button className={clsx("border-2 rounded-xl px-4 text-green-400 border-green-400 my-2")}>{solution.solution}</button>
|
||||
|
||||
<button
|
||||
className={clsx(
|
||||
"rounded-full hover:text-white hover:bg-mti-green transition duration-300 ease-in-out my-1",
|
||||
userSolution && "px-5 py-2 text-center text-white bg-mti-green-light",
|
||||
)}>
|
||||
{solution.solution}
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -45,8 +69,8 @@ export default function FillBlanksSolutions({prompt, solutions, text, userSoluti
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-4">
|
||||
<span className="text-base md:text-lg font-medium text-center px-2 md:px-4 lg:px-48">
|
||||
<div className="flex flex-col gap-4 mt-4 h-full mb-20">
|
||||
<span className="text-sm w-full leading-6">
|
||||
{prompt.split("\\n").map((line, index) => (
|
||||
<Fragment key={index}>
|
||||
{line}
|
||||
@@ -54,29 +78,24 @@ export default function FillBlanksSolutions({prompt, solutions, text, userSoluti
|
||||
</Fragment>
|
||||
))}
|
||||
</span>
|
||||
<span>
|
||||
<span className="bg-mti-gray-smoke rounded-xl px-5 py-6">
|
||||
{text.split("\\n").map((line, index) => (
|
||||
<Fragment key={index}>
|
||||
<p key={index}>
|
||||
{renderLines(line)}
|
||||
<br />
|
||||
</Fragment>
|
||||
</p>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="self-end flex flex-col-reverse items-center w-full md:justify-between md:items-start md:flex-row gap-8">
|
||||
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}>
|
||||
<div className="absolute left-4">
|
||||
<Icon path={mdiArrowLeft} color="white" size={1} />
|
||||
</div>
|
||||
<div className="self-end flex justify-between w-full gap-8 absolute bottom-8 left-0 px-8">
|
||||
<Button color="green" variant="outline" onClick={onBack} className="max-w-[200px] w-full">
|
||||
Back
|
||||
</button>
|
||||
<button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={onNext}>
|
||||
</Button>
|
||||
|
||||
<Button color="green" onClick={() => onNext()} className="max-w-[200px] self-end w-full">
|
||||
Next
|
||||
<div className="absolute right-4">
|
||||
<Icon path={mdiArrowRight} color="white" size={1} />
|
||||
</div>
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user