(score: number)
| 284 | * @returns Color hex string - default gray for scores < 90%, green gradient for scores >= 90% |
| 285 | */ |
| 286 | export function getScoreColor(score: number): string { |
| 287 | if (typeof score !== 'number' || isNaN(score)) { |
| 288 | return '#d9d9d9'; // Default gray |
| 289 | } |
| 290 | |
| 291 | const percentage = score * 100; |
| 292 | |
| 293 | // Scores below 90% use default gray |
| 294 | if (percentage < 90) { |
| 295 | return '#d9d9d9'; |
| 296 | } |
| 297 | |
| 298 | // Scores 90% and above: gradient from light green to dark green |
| 299 | // Map 90-100% to color range: #A8E6B2 (light green) to #39C651 (dark green) |
| 300 | const normalized = (percentage - 90) / 10; // 0 to 1 for 90-100% |
| 301 | |
| 302 | // Interpolate between light green (#95de64) and dark green (#52c41a) |
| 303 | const r1 = 0xa8, g1 = 0xe6, b1 = 0xb2; // Light green |
| 304 | const r2 = 0x39, g2 = 0xc6, b2 = 0x51; // Dark green |
| 305 | |
| 306 | const r = Math.round(r1 + (r2 - r1) * normalized); |
| 307 | const g = Math.round(g1 + (g2 - g1) * normalized); |
| 308 | const b = Math.round(b1 + (b2 - b1) * normalized); |
| 309 | |
| 310 | return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`; |
| 311 | } |
| 312 | |
| 313 | // Password validation utilities |
| 314 | export interface PasswordChecks { |
no test coverage detected