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 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 | /** * Weak Skills Summary Component * * Displays skills that need attention, ordered by BKT severity. * Supports both collapsed (compact) and expanded (with percentages) modes. */ 'use client' import { css } from '../../../styled-system/css' import type { WeakSkillInfo, WeakSkillsForProblem } from './weakSkillUtils' import { isLikelyCause } from './weakSkillUtils' export interface WeakSkillsSummaryProps { /** Weak skills analysis result from getWeakSkillsForProblem */ weakSkills: WeakSkillsForProblem /** Whether to show expanded view with mastery percentages */ expanded?: boolean /** Dark mode */ isDark: boolean } /** * Single skill badge for collapsed view */ function SkillBadge({ skill, isDark, showPercentage = false, }: { skill: WeakSkillInfo isDark: boolean showPercentage?: boolean }) { const likelyCause = isLikelyCause(skill) return ( <span data-element="skill-badge" data-skill-id={skill.skillId} data-likely-cause={likelyCause} className={css({ display: 'inline-flex', alignItems: 'center', gap: '0.25rem', padding: '0.125rem 0.375rem', borderRadius: '4px', fontSize: '0.6875rem', fontWeight: '500', backgroundColor: likelyCause ? isDark ? 'red.900/60' : 'red.100' : isDark ? 'yellow.900/60' : 'yellow.100', color: likelyCause ? isDark ? 'red.300' : 'red.700' : isDark ? 'yellow.300' : 'yellow.700', })} > {likelyCause && ( <span className={css({ fontSize: '0.625rem' })} role="img" aria-label="Likely cause of error" > ⚠️ </span> )} <span>{skill.displayLabel}</span> {showPercentage && ( <span className={css({ opacity: 0.8, fontSize: '0.625rem', })} > ({skill.masteryPercent}%) </span> )} </span> ) } /** * Collapsed view - inline skill badges with "+N more" indicator */ function CollapsedView({ weakSkills, isDark, }: { weakSkills: WeakSkillsForProblem isDark: boolean }) { if (weakSkills.displaySkills.length === 0) { return null } return ( <div data-element="weak-skills-collapsed" className={css({ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.375rem', })} > {weakSkills.displaySkills.map((skill) => ( <SkillBadge key={skill.skillId} skill={skill} isDark={isDark} /> ))} {weakSkills.hiddenCount > 0 && ( <span data-element="more-indicator" className={css({ fontSize: '0.6875rem', color: isDark ? 'gray.400' : 'gray.500', fontStyle: 'italic', })} > +{weakSkills.hiddenCount} more </span> )} </div> ) } /** * Expanded view - full skill list with mastery percentages */ function ExpandedView({ weakSkills, isDark, }: { weakSkills: WeakSkillsForProblem isDark: boolean }) { if (weakSkills.weakSkills.length === 0) { return ( <span data-element="no-weak-skills" className={css({ fontSize: '0.75rem', color: isDark ? 'gray.400' : 'gray.500', fontStyle: 'italic', })} > All skills in good standing </span> ) } return ( <div data-element="weak-skills-expanded" className={css({ display: 'flex', flexDirection: 'column', gap: '0.25rem', })} > <div className={css({ display: 'flex', alignItems: 'center', gap: '0.25rem', marginBottom: '0.25rem', })} > <span className={css({ fontSize: '0.625rem', })} > ⚠️ </span> <span className={css({ fontSize: '0.75rem', fontWeight: '600', color: isDark ? 'yellow.300' : 'yellow.700', })} > Weak Skills: </span> </div> <div className={css({ display: 'flex', flexWrap: 'wrap', gap: '0.375rem', })} > {weakSkills.weakSkills.map((skill) => ( <SkillBadge key={skill.skillId} skill={skill} isDark={isDark} showPercentage /> ))} </div> </div> ) } /** * Weak Skills Summary - shows skills that need attention * * In collapsed mode: shows up to 3 skills inline with "+N more" * In expanded mode: shows all skills with mastery percentages */ export function WeakSkillsSummary({ weakSkills, expanded = false, isDark, }: WeakSkillsSummaryProps) { if (weakSkills.weakSkills.length === 0 && !expanded) { // Nothing to show in collapsed mode if no weak skills return null } return ( <div data-component="weak-skills-summary" data-mode={expanded ? 'expanded' : 'collapsed'}> {expanded ? ( <ExpandedView weakSkills={weakSkills} isDark={isDark} /> ) : ( <CollapsedView weakSkills={weakSkills} isDark={isDark} /> )} </div> ) } export default WeakSkillsSummary |