@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.515b82.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.4...@codecademy/styleguide@79.1.5-alpha.515b82.0) (2026-03-10)
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.515b82.0",
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": "f7e36cb7a468a3bfa6619278ca728efcc22a6f3e"
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 keys** (`gainedNowAt`, `inLabel`, `inOnly`) Used in auto-generated `aria-label` and screen reader text for bars. Each key can be:
351
- - **String** — A fragment interpolated into the built-in template (e.g. `"in"`, `"gained - now at"`). Use when the default word order works for your language.
352
- - **Function** — Receives scoped context (values, label, unit, locale) and returns the **entire** summary string. Use for pluralization, different word order, or locale-specific phrasing.
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 - &#123;seriesOneValue&#125;&#123;unit&#125;.
382
+ &#123;gained&#125;&#123;unit&#125; gained - now at
383
+ &#123;seriesTwoValue&#125;&#123;unit&#125; in
384
+ &#123;categoryLabel&#125;
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
+ &#123;value&#125;&#123;unit&#125; in &#123;categoryLabel&#125;
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
- gainedNowAt: 'ganado - ahora en',
368
- inLabel: 'en',
369
- inOnly: 'en ',
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 complete translations for the language your app uses; use partial overrides for one-off changes.
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
- gainedNowAt: (ctx) =>
65
+ stackedBarSummary: (ctx) =>
66
66
  `${ctx.seriesOneValue} ${ctx.unit} gained — now at ${ctx.seriesTwoValue} ${ctx.unit} in ${ctx.categoryLabel}`,
67
- inLabel: (ctx) => `${ctx.value} ${ctx.unit} in ${ctx.categoryLabel}`,
68
- inOnly: (ctx) => `${ctx.value} ${ctx.unit}`.trim(),
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
- gainedNowAt: 'ganado - ahora en',
335
- inLabel: 'en',
336
- inOnly: 'en ',
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
  },