Commit 8d7c9d1
feat(mcp): widget UX polish — i18n, colour semantics, CTAs, dead payload data, card alignment (#570)
Seven independent polish items from the fixture render pass. None of these were
broken output; each one worked and read badly.
1. i18n. Every string a widget owned was hardcoded English and every date was
formatted with an implicit en-US, rendered above Spanish course content.
New `resources/shared/i18n.tsx` gives `useLang` / `useStrings` / `useFormat`,
driven by `useWidget().locale` (the BCP 47 tag the host supplies) and
`timeZone`. All 13 widgets with user-visible chrome now carry an en/es table
typed so a missing Spanish string is a compile error, and every
`toLocaleDateString(undefined, …)` call site is gone. practice-player's
hand-rolled `navigator.language` sniff is replaced by the shared hook.
Only widget-owned strings are translated; course titles, lesson titles and
tags come from the database in the school's language and stay verbatim.
2. Colour semantics. `completionColor` and `progressColor` were the same
percent-to-colour function copied into two widgets, both running
amber -> brand -> green, which made the school's brand colour a mid value on
a severity scale. They collapse into `resources/shared/severity.tsx` on a
red/amber/green ramp with brand removed, per the rule already stated in
the epic. The two copies had drifted (0% returned zinc in one and red in the
other); "no data" is now `null` and distinct from a real zero, so a draft
course with nothing to complete reads neutral instead of failing.
KPI tiles gain a stated rule — colour marks a verdict, counts stay neutral —
and the "3 published · 2 draft" caption gains the missing archived bucket so
the parts sum to the total above them. Also replaces a hardcoded
"active · 0 lessons done" caption with the rule the number is really
computed from.
3. exam-readiness sorts topics by mastery ascending, so the weakest is first
rather than last; marks it "Focus here first"; drops the practice CTA to a
quiet link on already-mastered topics; and renders days-until-exam from
`exam.exam_date`, counted in calendar days.
4. my-learning's next lesson becomes a real primary button that opens the
lesson, instead of a grey pill in the card footer.
5. course-catalog can convert. `lms_browse_catalog` never asked the database
for a price, so there was none to render: it now joins `product_courses` to
`products` and reports the cheapest active product per course (a course can
be sold under several). `Enroll` and `Access` collapse into one verb,
`Not in plan` becomes a real path instead of grey text, and the 96px book
emoji placeholder is dropped when there is no thumbnail.
6. study-plan renders `context.next_lessons`, which the server has always sent
and the widget only showed in the empty state — so it was dropped in the
common case.
7. Card alignment. course-dashboard, course-catalog and gamification-profile
give their cards a shared row grid (`grid-rows-subgrid`), so a null
description or an absent tag row collapses without pushing the tags and
footers out of line with the neighbouring cards.
Drive-by, because this change needed the same channel: the demo tools' documented
`brand=ocean|sunset|forest` argument never worked. `src/tools/demo.ts` computed
the branding and named it in the output text but never attached it to the
result, so every "branded" preview rendered the platform violet. It now goes
through `widget({ metadata })`. The same sideband carries a new `lang` argument,
so the offline harness can render the Spanish path it otherwise could not show.
Verified: tsc clean, `npm run build` (18 widgets), 39/39 vitest, and every
affected fixture re-shot in dark and light and in both languages.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bs69mfRZXog8KPM1n626RA1 parent a6c88d3 commit 8d7c9d1
20 files changed
Lines changed: 1809 additions & 493 deletions
File tree
- mcp-server
- docs
- resources
- course-catalog
- course-dashboard
- course-detail
- exam-readiness
- exam-submissions
- gamification-profile
- my-exam-results
- my-learning
- practice-player
- school-overview
- student-progress-roster
- study-plan
- submission-grader
- src
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 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 | + | |
81 | 112 | | |
82 | 113 | | |
83 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
42 | 47 | | |
43 | 48 | | |
44 | 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 | + | |
45 | 88 | | |
46 | 89 | | |
47 | 90 | | |
| |||
72 | 115 | | |
73 | 116 | | |
74 | 117 | | |
| 118 | + | |
| 119 | + | |
75 | 120 | | |
76 | 121 | | |
77 | 122 | | |
| |||
80 | 125 | | |
81 | 126 | | |
82 | 127 | | |
83 | | - | |
| 128 | + | |
84 | 129 | | |
85 | 130 | | |
86 | 131 | | |
| |||
102 | 147 | | |
103 | 148 | | |
104 | 149 | | |
105 | | - | |
| 150 | + | |
106 | 151 | | |
107 | 152 | | |
108 | 153 | | |
| |||
121 | 166 | | |
122 | 167 | | |
123 | 168 | | |
124 | | - | |
| 169 | + | |
125 | 170 | | |
126 | 171 | | |
127 | | - | |
128 | | - | |
| 172 | + | |
| 173 | + | |
129 | 174 | | |
130 | 175 | | |
131 | 176 | | |
| |||
142 | 187 | | |
143 | 188 | | |
144 | 189 | | |
145 | | - | |
| 190 | + | |
146 | 191 | | |
147 | 192 | | |
148 | 193 | | |
149 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
150 | 205 | | |
151 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
152 | 217 | | |
153 | 218 | | |
154 | 219 | | |
155 | | - | |
| 220 | + | |
156 | 221 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
168 | 235 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
179 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
180 | 246 | | |
| 247 | + | |
181 | 248 | | |
182 | | - | |
| 249 | + | |
183 | 250 | | |
184 | 251 | | |
185 | 252 | | |
| |||
190 | 257 | | |
191 | 258 | | |
192 | 259 | | |
| 260 | + | |
193 | 261 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
218 | 270 | | |
219 | 271 | | |
220 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
221 | 325 | | |
222 | 326 | | |
223 | 327 | | |
| |||
0 commit comments