import React, { useEffect, useRef } from 'react'; import Card from '../ui/Card'; export default function ConceptExplainer({ content, onComplete }) { const containerRef = useRef(null); // Trigger completion when scrolled to the end useEffect(() => { const handleScroll = () => { if (!containerRef.current) return; const { scrollTop, scrollHeight, clientHeight } = containerRef.current; if (scrollTop + clientHeight >= scrollHeight - 50) { onComplete(); } }; // Check initially in case content is short and doesn't need scrolling if (containerRef.current && containerRef.current.scrollHeight <= containerRef.current.clientHeight) { onComplete(); } const currentRef = containerRef.current; currentRef?.addEventListener('scroll', handleScroll); return () => currentRef?.removeEventListener('scroll', handleScroll); }, [onComplete]); return (

Concept Explainer

{content?.sections?.map((section, i) => (

{section.title}

))}
); }