import React, { useState } from 'react'; import { Check, RotateCcw, ArrowRight } from 'lucide-react'; const LiteralEquationWidget: React.FC = () => { const [problemIdx, setProblemIdx] = useState(0); const [step, setStep] = useState(0); const problems = [ { id: 'perimeter', title: 'Perimeter Formula', goal: 'Isolate W', steps: [ { startEq: <>P = 2L + 2W, options: [ { text: 'Subtract 2L', correct: true }, { text: 'Divide by 2', correct: false } ], feedback: 'Moved 2L to the other side.', nextEq: <>P - 2L = 2W }, { startEq: <>P - 2L = 2W, options: [ { text: 'Divide by 2', correct: true }, { text: 'Subtract 2', correct: false } ], feedback: 'Solved!', nextEq: <>W = P - 2L2 } ] }, { id: 'linear', title: 'Slope-Intercept', goal: 'Isolate x', steps: [ { startEq: <>y = mx + b, options: [ { text: 'Subtract b', correct: true }, { text: 'Divide by m', correct: false } ], feedback: 'Isolated the x term.', nextEq: <>y - b = mx }, { startEq: <>y - b = mx, options: [ { text: 'Divide by m', correct: true }, { text: 'Subtract m', correct: false } ], feedback: 'Solved!', nextEq: <>x = y - bm } ] }, { id: 'standard', title: 'Standard Form', goal: 'Isolate y', steps: [ { startEq: <>Ax + By = C, options: [ { text: 'Subtract Ax', correct: true }, { text: 'Divide by B', correct: false } ], feedback: 'Moved the x term away.', nextEq: <>By = C - Ax }, { startEq: <>By = C - Ax, options: [ { text: 'Divide by B', correct: true }, { text: 'Subtract B', correct: false } ], feedback: 'Solved!', nextEq: <>y = C - AxB } ] }, { id: 'physics', title: 'Velocity Formula', goal: 'Isolate a', steps: [ { startEq: <>v = u + at, options: [ { text: 'Subtract u', correct: true }, { text: 'Divide by t', correct: false } ], feedback: 'Isolated the term with a.', nextEq: <>v - u = at }, { startEq: <>v - u = at, options: [ { text: 'Divide by t', correct: true }, { text: 'Subtract t', correct: false } ], feedback: 'Solved!', nextEq: <>a = v - ut } ] } ]; const currentProb = problems[problemIdx]; const currentStepData = currentProb.steps[step]; const handleNextProblem = () => { let next = Math.floor(Math.random() * problems.length); while (next === problemIdx) { next = Math.floor(Math.random() * problems.length); } setProblemIdx(next); setStep(0); }; const reset = () => { setStep(0); }; const handleOption = (isCorrect: boolean) => { if (isCorrect) { setStep(step + 1); } }; return (

Ex {currentProb.goal}

{step < 2 ? (
{currentStepData.startEq}
{step === 1 &&

{problems[problemIdx].steps[0].feedback}

}

{step === 0 ? "What is the first step?" : "What is the next step?"}

) : (
{currentProb.steps[1].nextEq}
{currentProb.steps[1].feedback}
)}
{step < 2 ? ( <> {currentStepData.options.map((opt, i) => ( ))} ) : ( )}
); }; export default LiteralEquationWidget;