47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { motion } from "framer-motion"
|
|
import { speak } from "@/lib/speech"
|
|
import { GatoMascota } from "@/components/child/gato-mascota"
|
|
import type { Exercise } from "@/curriculum/types"
|
|
|
|
interface Props {
|
|
exercise: Exercise
|
|
onComplete: (correct: boolean) => void
|
|
}
|
|
|
|
export default function EjercicioEleccion({ exercise, onComplete }: Props) {
|
|
const { content } = exercise
|
|
const options = content.options || []
|
|
|
|
const handleChoose = async (opt: (typeof options)[0]) => {
|
|
if (content.audioText) await speak(content.audioText)
|
|
onComplete(opt.correct)
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col items-center gap-6">
|
|
<GatoMascota mood="coach" message={content.instruction} size="sm" />
|
|
|
|
{content.text && (
|
|
<p className="text-2xl font-display font-bold text-center">{content.text}</p>
|
|
)}
|
|
|
|
<div className="flex flex-wrap gap-4 justify-center max-w-sm">
|
|
{options.map((opt, i) => (
|
|
<motion.button
|
|
key={`${opt.label}-${i}`}
|
|
initial={{ opacity: 0, scale: 0.8 }}
|
|
animate={{ opacity: 1, scale: 1 }}
|
|
transition={{ delay: i * 0.12 }}
|
|
onClick={() => handleChoose(opt)}
|
|
className="touch-target-lg rounded-2xl px-8 py-6 text-3xl font-display font-bold shadow-md active:scale-95 transition-transform bg-white"
|
|
>
|
|
{opt.label}
|
|
</motion.button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|