Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/gameplay/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ const Question: React.FC<QuestionProps> = ({
return `${mins.toString().padStart(2, '0')} : ${secs.toString().padStart(2, '0')}`;
};

const isTimeWarning = timeLeft <= 30;

return (
<div className="w-full h-full flex flex-col justify-between p-4 md:p-6 rounded-xl bg-linear-to-b from-green-900 to-emerald-900 border-2 border-green-800 shadow-lg overflow-hidden">

<div className="flex items-center justify-start gap-2 mb-2">
<img src={timerIcon} alt="Timer" className="w-6 h-6 object-contain" />
<span className="text-xl font-bold text-yellow-400 font-mono">
<span
role="timer"
aria-live="polite"
aria-atomic="true"
className={`text-xl font-bold font-mono ${isTimeWarning ? 'text-red-400 animate-pulse' : 'text-yellow-400'}`}
>
{formatTime(timeLeft)}
</span>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/components/gameplay/QuestionContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ const QuestionContainer: React.FC<QuestionContainerProps> = ({
setTimeLeft(prev => (prev <= 1 ? 0 : prev - 1));
}, 1000);
return () => clearInterval(interval);
} else if (timeLeft === 0 && !isSubmitted) {
// Auto-submit as incorrect when time runs out
setIsSubmitted(true);
const progressDelay = setTimeout(() => {
onAnswerSubmit?.('', false, timeLimit);
}, 1500);
return () => clearTimeout(progressDelay);
}
}, [timeLeft, isSubmitted]);
}, [timeLeft, isSubmitted, timeLimit, onAnswerSubmit]);

// Map raw data to the visual states your UI uses
const formattedAnswers: AnswerState[] = answers.map((answer, index) => ({
Expand Down