import { motion } from 'framer-motion'; import { useState, useLayoutEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import { correctAnswerClasses, incorrectAnswerClasses, defaultSlideUpVariant, defaultViewerStreamActionTransition } from './viewerStreamActionsTheme'; import { clsm, isTextColorInverted } from '../../../utils'; import { createAnimationProps } from '../../../helpers/animationPropsHelper'; import { PROFILE_COLORS } from '../../../constants'; import { usePlayerContext } from '../contexts/Player'; import { useResponsiveDevice } from '../../../contexts/ResponsiveDevice'; import Button from '../../../components/Button'; import ProgressBar from './ProgressBar'; const defaultQuizAnswerHeight = 42; const QuizCard = ({ answers, color, correctAnswerIndex, duration, question, setCurrentViewerAction, shouldRenderActionInTab, shouldShowStream, startTime }) => { const [answerHeight, setAnswerHeight] = useState(defaultQuizAnswerHeight); const [isAnswerSelected, setIsAnswerSelected] = useState(); const [chosenAnswerIndex, setChosenAnswerIndex] = useState(); const { isMobileView } = useResponsiveDevice(); const { isOverlayVisible } = usePlayerContext(); const quizButtonArrRef = useRef([]); const shouldInvertColors = isTextColorInverted(color); const profileColorButtonClassNames = clsm([ 'disabled:text-black', 'focus:shadow-black', 'text-black', `bg-profile-${color}-light`, `focus:bg-profile-${color}-light`, `hover:bg-profile-${color}-light-hover`, shouldInvertColors && [ 'disabled:text-white', 'focus:shadow-white', 'text-white' ] ]); const selectAnswer = (index) => { setIsAnswerSelected(true); setChosenAnswerIndex(index); setTimeout(() => setCurrentViewerAction(null), 2000); }; useLayoutEffect(() => { quizButtonArrRef.current.forEach((quizButton) => { if (quizButton.clientHeight > answerHeight) { setAnswerHeight(quizButton.clientHeight); } }); }, [answerHeight]); return (