@codecademy/styleguide 79.1.5-alpha.515b82.0 → 79.1.5-alpha.81d81f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
### [79.1.5-alpha.
|
|
6
|
+
### [79.1.5-alpha.81d81f.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.4...@codecademy/styleguide@79.1.5-alpha.81d81f.0) (2026-03-11)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @codecademy/styleguide
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/styleguide",
|
|
3
3
|
"description": "Styleguide & Component library for codecademy.com",
|
|
4
|
-
"version": "79.1.5-alpha.
|
|
4
|
+
"version": "79.1.5-alpha.81d81f.0",
|
|
5
5
|
"author": "Codecademy Engineering",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"repository": "git@github.com:Codecademy/gamut.git",
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "e73b4a47deb8f9a6410102d01bfbdcff044680b1"
|
|
12
12
|
}
|
|
@@ -347,9 +347,67 @@ BarChart supports internationalization through the `translations` prop. You can
|
|
|
347
347
|
### Translation structure
|
|
348
348
|
|
|
349
349
|
- **sortLabel**, **sortOptions**, and **locale** — Always strings. Control the sort dropdown label, option labels, and number-formatting locale.
|
|
350
|
-
- **Accessibility
|
|
351
|
-
- **
|
|
352
|
-
- **
|
|
350
|
+
- **Accessibility** — Two optional summary functions; when omitted, default English summaries are used. Each function receives context and returns the full summary string.
|
|
351
|
+
- **stackedBarSummary** — Used for stacked (two-value) rows. Context includes `seriesOneValue`, `seriesTwoValue`, **gained** (seriesTwoValue - seriesOneValue), `unit`, `locale`, `categoryLabel`.
|
|
352
|
+
- **singleValueBarSummary** — Used for all single-value rows. Context includes `value`, `unit`, `locale`, `categoryLabel`.
|
|
353
|
+
|
|
354
|
+
### Where accessibility summaries appear
|
|
355
|
+
|
|
356
|
+
Each bar row gets one summary from either `stackedBarSummary` (stacked rows) or `singleValueBarSummary` (single-value rows). That string is then exposed as **`aria-label`** on the row's link or button when the row is interactive, or as **screenreader-only text** (visually hidden) when the row is not interactive.
|
|
357
|
+
|
|
358
|
+
<table>
|
|
359
|
+
<thead>
|
|
360
|
+
<tr>
|
|
361
|
+
<th>Key</th>
|
|
362
|
+
<th>Used for</th>
|
|
363
|
+
<th>Context (props)</th>
|
|
364
|
+
<th>Default English interpolation</th>
|
|
365
|
+
<th>Summary exposed as</th>
|
|
366
|
+
</tr>
|
|
367
|
+
</thead>
|
|
368
|
+
<tbody>
|
|
369
|
+
<tr>
|
|
370
|
+
<td>
|
|
371
|
+
<code>stackedBarSummary</code>
|
|
372
|
+
</td>
|
|
373
|
+
<td>Stacked rows (two values per row)</td>
|
|
374
|
+
<td>
|
|
375
|
+
<code>seriesOneValue</code>, <code>seriesTwoValue</code>,{' '}
|
|
376
|
+
<code>gained</code>, <code>unit</code>, <code>locale</code>,{' '}
|
|
377
|
+
<code>categoryLabel</code>
|
|
378
|
+
</td>
|
|
379
|
+
<td>
|
|
380
|
+
<code>
|
|
381
|
+
Starting value - {seriesOneValue}{unit}.
|
|
382
|
+
{gained}{unit} gained - now at
|
|
383
|
+
{seriesTwoValue}{unit} in
|
|
384
|
+
{categoryLabel}
|
|
385
|
+
</code>
|
|
386
|
+
</td>
|
|
387
|
+
<td>
|
|
388
|
+
<code>aria-label</code> (if link/button) or screenreader-only text
|
|
389
|
+
</td>
|
|
390
|
+
</tr>
|
|
391
|
+
<tr>
|
|
392
|
+
<td>
|
|
393
|
+
<code>singleValueBarSummary</code>
|
|
394
|
+
</td>
|
|
395
|
+
<td>Single-value rows</td>
|
|
396
|
+
<td>
|
|
397
|
+
<code>value</code>, <code>unit</code>, <code>locale</code>,{' '}
|
|
398
|
+
<code>categoryLabel</code>
|
|
399
|
+
</td>
|
|
400
|
+
<td>
|
|
401
|
+
<code>
|
|
402
|
+
{value}{unit} in {categoryLabel}
|
|
403
|
+
</code>
|
|
404
|
+
</td>
|
|
405
|
+
<td>
|
|
406
|
+
<code>aria-label</code> (if link/button) or screenreader-only text
|
|
407
|
+
</td>
|
|
408
|
+
</tr>
|
|
409
|
+
</tbody>
|
|
410
|
+
</table>
|
|
353
411
|
|
|
354
412
|
### Basic usage
|
|
355
413
|
|
|
@@ -364,9 +422,10 @@ Provide only the translations you want to override; the rest fall back to defaul
|
|
|
364
422
|
title="Habilidades"
|
|
365
423
|
translations={{
|
|
366
424
|
accessibility: {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
425
|
+
stackedBarSummary: (ctx) =>
|
|
426
|
+
`Valor inicial - ${ctx.seriesOneValue} ${ctx.unit}. ${ctx.gained} ${ctx.unit} ganado - ahora en ${ctx.seriesTwoValue} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
427
|
+
singleValueBarSummary: (ctx) =>
|
|
428
|
+
`${ctx.value} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
370
429
|
},
|
|
371
430
|
locale: 'es',
|
|
372
431
|
sortLabel: 'Ordenar por:',
|
|
@@ -398,18 +457,11 @@ translations={{
|
|
|
398
457
|
}}
|
|
399
458
|
```
|
|
400
459
|
|
|
401
|
-
### Accessibility: strings vs functions
|
|
402
|
-
|
|
403
|
-
**Strings** — Use when the built-in template order fits your language. Fragments are plugged into the default pattern (e.g. `"{value} {unit} {inLabel} {categoryLabel}"`).
|
|
404
|
-
|
|
405
|
-
**Functions** — Use when you need full control. Each function receives context (`categoryLabel`, values, `unit`, `locale`) and returns the complete summary string.
|
|
406
|
-
|
|
407
460
|
<Canvas of={BarChartStories.WithFunctionTranslations} />
|
|
408
461
|
|
|
409
462
|
**Best practices:**
|
|
410
463
|
|
|
411
|
-
- Provide
|
|
412
|
-
- Prefer string accessibility keys when the default order works; use functions for pluralization, word order, or locale-specific phrasing.
|
|
464
|
+
- Provide summary functions for the locales your app uses; use default behavior when the default English is acceptable.
|
|
413
465
|
- Use appropriate locale codes (e.g. `'en-US'`, `'es-ES'`, `'fr-FR'`) for number formatting.
|
|
414
466
|
- Test accessibility summaries with screen readers in the target language.
|
|
415
467
|
- Reuse translation objects across BarChart instances where possible.
|
|
@@ -62,10 +62,10 @@ const accessibilityBarData: BarProps[] = [
|
|
|
62
62
|
|
|
63
63
|
const accessibilityTranslations: PartialBarChartTranslations = {
|
|
64
64
|
accessibility: {
|
|
65
|
-
|
|
65
|
+
stackedBarSummary: (ctx) =>
|
|
66
66
|
`${ctx.seriesOneValue} ${ctx.unit} gained — now at ${ctx.seriesTwoValue} ${ctx.unit} in ${ctx.categoryLabel}`,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
singleValueBarSummary: (ctx) =>
|
|
68
|
+
`${ctx.value} ${ctx.unit} in ${ctx.categoryLabel}`,
|
|
69
69
|
},
|
|
70
70
|
locale: 'en',
|
|
71
71
|
};
|
|
@@ -331,9 +331,10 @@ export const WithStringTranslations: Story = {
|
|
|
331
331
|
valueDesc: 'Valor (Alto-Bajo)',
|
|
332
332
|
},
|
|
333
333
|
accessibility: {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
stackedBarSummary: (ctx) =>
|
|
335
|
+
`Valor inicial - ${ctx.seriesOneValue} ${ctx.unit}. ${ctx.gained} ${ctx.unit} ganado - ahora en ${ctx.seriesTwoValue} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
336
|
+
singleValueBarSummary: (ctx) =>
|
|
337
|
+
`${ctx.value} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
337
338
|
},
|
|
338
339
|
},
|
|
339
340
|
},
|