diff --git a/apps/web/src/app/games/memory-quiz/page.tsx b/apps/web/src/app/games/memory-quiz/page.tsx index dcc52177..f3a8a148 100644 --- a/apps/web/src/app/games/memory-quiz/page.tsx +++ b/apps/web/src/app/games/memory-quiz/page.tsx @@ -4,6 +4,7 @@ import Link from 'next/link' import React, { useEffect, useReducer, useRef, useCallback, useMemo, useState } from 'react' import { css } from '../../../../styled-system/css' import { TypstSoroban } from '../../../components/TypstSoroban' +import { isPrefix } from '../../../lib/memory-quiz-utils' interface QuizCard { number: number @@ -705,18 +706,216 @@ function CardGrid({ state }: { state: SorobanQuizState }) { ) } +// Results card grid that reuses CardGrid with all cards revealed and success/failure indicators +function ResultsCardGrid({ state }: { state: SorobanQuizState }) { + if (state.quizCards.length === 0) return null + + // Create a modified state where all cards are revealed for results display + const resultsState = { + ...state, + revealedCards: state.quizCards.map(card => card.number) // Reveal all cards + } + + // Calculate optimal grid layout based on number of cards (same as CardGrid) + const cardCount = state.quizCards.length + + // Define static grid classes that Panda can generate (same as CardGrid) + const getGridClass = (count: number) => { + if (count <= 2) return 'repeat(2, 1fr)' + if (count <= 4) return 'repeat(2, 1fr)' + if (count <= 6) return 'repeat(3, 1fr)' + if (count <= 9) return 'repeat(3, 1fr)' + if (count <= 12) return 'repeat(4, 1fr)' + return 'repeat(5, 1fr)' + } + + const getCardSize = (count: number) => { + if (count <= 2) return { minSize: '180px', cardHeight: '160px' } + if (count <= 4) return { minSize: '160px', cardHeight: '150px' } + if (count <= 6) return { minSize: '140px', cardHeight: '140px' } + if (count <= 9) return { minSize: '120px', cardHeight: '130px' } + if (count <= 12) return { minSize: '110px', cardHeight: '120px' } + return { minSize: '100px', cardHeight: '110px' } + } + + const gridClass = getGridClass(cardCount) + const cardSize = getCardSize(cardCount) + + return ( +