Spaces:
Sleeping
Sleeping
File size: 7,946 Bytes
86d71bd | 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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | /**
* Real-time Score Display
*
* Shows live interview performance scores.
* Updates as the user answers questions.
*/
import React, { useMemo } from 'react';
import {
Brain,
MessageCircle,
Code2,
Eye,
TrendingUp,
TrendingDown,
Minus,
} from 'lucide-react';
import { getScoreGrade } from '../services/scoringService';
function ScoreCard({ icon: Icon, label, score, previousScore = null }) {
const { grade, label: gradeLabel, color } = getScoreGrade(score);
const trend = useMemo(() => {
if (previousScore === null) return 'neutral';
if (score > previousScore + 2) return 'up';
if (score < previousScore - 2) return 'down';
return 'neutral';
}, [score, previousScore]);
return (
<div className="score-card">
<div className="score-header">
<Icon size={16} className="score-icon" />
<span className="score-label">{label}</span>
{trend === 'up' && <TrendingUp size={14} className="trend-up" />}
{trend === 'down' && <TrendingDown size={14} className="trend-down" />}
{trend === 'neutral' && previousScore !== null && <Minus size={14} className="trend-neutral" />}
</div>
<div className="score-value">
<span className="score-number" style={{ color }}>{score}</span>
<span className="score-grade" style={{ backgroundColor: `${color}20`, color }}>{grade}</span>
</div>
<div className="score-bar">
<div
className="score-bar-fill"
style={{ width: `${score}%`, backgroundColor: color }}
/>
</div>
</div>
);
}
function RealTimeScoreDisplay({ scores = {}, previousScores = null, compact = false }) {
const {
clarity = 50,
confidence = 50,
technical = 50,
eyeContact = 50,
overall = 50,
} = scores;
const prev = previousScores || {};
const { grade, label, color } = getScoreGrade(overall);
if (compact) {
return (
<div className="score-display compact">
<div className="overall-compact">
<span className="overall-label">Score</span>
<span className="overall-value" style={{ color }}>{overall}</span>
<span className="overall-grade" style={{ backgroundColor: `${color}20`, color }}>{grade}</span>
</div>
<style jsx>{`
.score-display.compact {
display: flex;
align-items: center;
gap: var(--space-2);
padding: var(--space-2) var(--space-3);
background: var(--bg-tertiary);
border-radius: var(--radius-lg);
}
.overall-compact {
display: flex;
align-items: center;
gap: var(--space-2);
}
.overall-label {
font-size: var(--text-xs);
color: var(--text-muted);
}
.overall-value {
font-weight: var(--font-bold);
font-size: var(--text-lg);
}
.overall-grade {
padding: 2px 6px;
font-size: var(--text-xs);
font-weight: var(--font-semibold);
border-radius: var(--radius-sm);
}
`}</style>
</div>
);
}
return (
<div className="score-display">
<div className="overall-score">
<div className="overall-value" style={{ color }}>{overall}</div>
<div className="overall-grade" style={{ backgroundColor: `${color}20`, color }}>{label}</div>
<div className="overall-label">Overall Score</div>
</div>
<div className="score-breakdown">
<ScoreCard
icon={MessageCircle}
label="Clarity"
score={clarity}
previousScore={prev.clarity}
/>
<ScoreCard
icon={Brain}
label="Confidence"
score={confidence}
previousScore={prev.confidence}
/>
<ScoreCard
icon={Code2}
label="Technical"
score={technical}
previousScore={prev.technical}
/>
<ScoreCard
icon={Eye}
label="Eye Contact"
score={eyeContact}
previousScore={prev.eyeContact}
/>
</div>
<style jsx>{`
.score-display {
padding: var(--space-4);
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-xl);
}
.overall-score {
text-align: center;
padding-bottom: var(--space-4);
margin-bottom: var(--space-4);
border-bottom: 1px solid var(--border-color);
}
.overall-value {
font-family: var(--font-display);
font-size: 3rem;
font-weight: var(--font-extrabold);
line-height: 1;
}
.overall-grade {
display: inline-block;
margin-top: var(--space-2);
padding: var(--space-1) var(--space-3);
font-size: var(--text-sm);
font-weight: var(--font-semibold);
border-radius: var(--radius-full);
}
.overall-label {
margin-top: var(--space-2);
font-size: var(--text-sm);
color: var(--text-muted);
}
.score-breakdown {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--space-3);
}
@media (max-width: 600px) {
.score-breakdown {
grid-template-columns: 1fr;
}
}
`}</style>
<style jsx global>{`
.score-card {
padding: var(--space-3);
background: var(--bg-tertiary);
border-radius: var(--radius-lg);
}
.score-header {
display: flex;
align-items: center;
gap: var(--space-2);
margin-bottom: var(--space-2);
}
.score-icon {
color: var(--text-muted);
}
.score-label {
flex: 1;
font-size: var(--text-xs);
font-weight: var(--font-medium);
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.trend-up {
color: #10b981;
}
.trend-down {
color: #ef4444;
}
.trend-neutral {
color: var(--text-muted);
}
.score-value {
display: flex;
align-items: center;
gap: var(--space-2);
margin-bottom: var(--space-2);
}
.score-number {
font-size: var(--text-xl);
font-weight: var(--font-bold);
}
.score-grade {
padding: 2px 6px;
font-size: var(--text-xs);
font-weight: var(--font-semibold);
border-radius: var(--radius-sm);
}
.score-bar {
height: 4px;
background: var(--bg-card);
border-radius: var(--radius-full);
overflow: hidden;
}
.score-bar-fill {
height: 100%;
border-radius: var(--radius-full);
transition: width 0.5s ease-out;
}
`}</style>
</div>
);
}
export default RealTimeScoreDisplay;
|