Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | 'use client' import { useMemo } from 'react' import type { ObservedResult } from '@/hooks/useSessionObserver' import { css } from '../../../styled-system/css' interface MobileResultsSummaryProps { /** Accumulated results from the session */ results: ObservedResult[] /** Total problems in the session */ totalProblems: number /** Whether dark mode */ isDark: boolean /** Callback to expand to full report view */ onExpand: () => void } /** * Compact results summary for mobile screens * * Shows progress, accuracy, and incorrect count in a horizontal chip layout. * Tapping expands to full report view. */ export function MobileResultsSummary({ results, totalProblems, isDark, onExpand, }: MobileResultsSummaryProps) { // Compute stats const stats = useMemo(() => { const correct = results.filter((r) => r.isCorrect).length const incorrect = results.filter((r) => !r.isCorrect).length const completed = results.length const accuracy = completed > 0 ? correct / completed : 0 return { correct, incorrect, completed, accuracy } }, [results]) // No results yet - show minimal placeholder if (results.length === 0) { return ( <div data-component="mobile-results-summary" data-state="empty" className={css({ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '8px 16px', borderRadius: '20px', backgroundColor: isDark ? 'gray.800' : 'gray.100', fontSize: '0.8125rem', color: isDark ? 'gray.500' : 'gray.400', })} > Waiting for results... </div> ) } return ( <button type="button" data-component="mobile-results-summary" onClick={onExpand} className={css({ display: 'flex', alignItems: 'center', gap: '12px', padding: '8px 16px', borderRadius: '20px', backgroundColor: isDark ? 'gray.800' : 'gray.100', border: '1px solid', borderColor: isDark ? 'gray.700' : 'gray.200', cursor: 'pointer', transition: 'background-color 0.15s ease', _hover: { backgroundColor: isDark ? 'gray.700' : 'gray.200', }, })} > {/* Progress */} <span className={css({ fontSize: '0.875rem', fontWeight: 'bold', color: isDark ? 'gray.200' : 'gray.700', })} > {stats.completed}/{totalProblems} </span> {/* Divider */} <span className={css({ width: '1px', height: '16px', backgroundColor: isDark ? 'gray.600' : 'gray.300', })} /> {/* Accuracy */} <span className={css({ fontSize: '0.875rem', fontWeight: 'bold', color: stats.accuracy >= 0.8 ? isDark ? 'green.400' : 'green.600' : stats.accuracy >= 0.6 ? isDark ? 'yellow.400' : 'yellow.600' : isDark ? 'red.400' : 'red.600', })} > {Math.round(stats.accuracy * 100)}% </span> {/* Incorrect count badge (only if there are incorrect) */} {stats.incorrect > 0 && ( <span className={css({ display: 'flex', alignItems: 'center', gap: '4px', padding: '2px 8px', borderRadius: '9999px', backgroundColor: isDark ? 'red.900/50' : 'red.100', fontSize: '0.75rem', fontWeight: 'bold', color: isDark ? 'red.300' : 'red.700', })} > <span>✗</span> <span>{stats.incorrect}</span> </span> )} {/* View report arrow */} <span className={css({ marginLeft: 'auto', fontSize: '0.75rem', color: isDark ? 'blue.400' : 'blue.600', fontWeight: 'medium', })} > Report → </span> </button> ) } export default MobileResultsSummary |