@codecademy/styleguide 79.1.5-alpha.a28b9a.0 → 79.1.5-alpha.b03ce1.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.b03ce1.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.4...@codecademy/styleguide@79.1.5-alpha.b03ce1.0) (2026-03-12)
|
|
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.b03ce1.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": "d03a4c2d4b5dd73e45d990f755ba3ca2366f9ce5"
|
|
12
12
|
}
|
|
@@ -271,11 +271,11 @@ If `styleConfig` is not provided, BarChart uses these default colors:
|
|
|
271
271
|
|
|
272
272
|
## Custom scale
|
|
273
273
|
|
|
274
|
-
BarChart allows you to customize the x-axis scale interval using the `
|
|
274
|
+
BarChart allows you to customize the x-axis scale interval using the `scaleInterval` prop, which controls the spacing and granularity of scale markers along the horizontal axis.
|
|
275
275
|
|
|
276
276
|
### Scale configuration
|
|
277
277
|
|
|
278
|
-
The `
|
|
278
|
+
The `scaleInterval` prop determines the interval between scale markers on the x-axis. By default, BarChart automatically calculates an appropriate scale interval based on the `maxScaleValue` value (the scale always starts at 0). However, you can override this with a custom interval to achieve more granular or specific scale markings.
|
|
279
279
|
|
|
280
280
|
**When to use custom scale:**
|
|
281
281
|
|
|
@@ -286,12 +286,12 @@ The `xScale` prop determines the interval between scale markers on the x-axis. B
|
|
|
286
286
|
|
|
287
287
|
**How it works:**
|
|
288
288
|
|
|
289
|
-
The `
|
|
289
|
+
The `scaleInterval` value represents the interval between consecutive scale markers. For example:
|
|
290
290
|
|
|
291
|
-
- `
|
|
292
|
-
- `
|
|
291
|
+
- `scaleInterval: 250` creates markers at 0, 250, 500, 750, 1000, etc.
|
|
292
|
+
- `scaleInterval: 500` creates markers at 0, 500, 1000, 1500, 2000, etc.
|
|
293
293
|
|
|
294
|
-
The number of tick marks is automatically calculated as: `Math.ceil(
|
|
294
|
+
The number of tick marks is automatically calculated as: `Math.ceil(maxScaleValue / scaleInterval) + 1`
|
|
295
295
|
|
|
296
296
|
### Example
|
|
297
297
|
|
|
@@ -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
|
|
|
@@ -359,14 +417,15 @@ Provide only the translations you want to override; the rest fall back to defaul
|
|
|
359
417
|
<BarChart
|
|
360
418
|
barValues={barData}
|
|
361
419
|
description="Progreso de habilidades"
|
|
362
|
-
|
|
420
|
+
maxScaleValue={200}
|
|
363
421
|
sortFns={['alphabetically', 'none']}
|
|
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.
|
|
@@ -16,7 +16,7 @@ const meta: Meta<typeof BarChart> = {
|
|
|
16
16
|
component: BarChart,
|
|
17
17
|
args: {
|
|
18
18
|
description: 'Chart showing programming language experience levels',
|
|
19
|
-
|
|
19
|
+
maxScaleValue: 2000,
|
|
20
20
|
title: 'Skills experience chart',
|
|
21
21
|
unit: 'XP',
|
|
22
22
|
},
|
|
@@ -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
|
};
|
|
@@ -175,7 +175,7 @@ export const WithHiddenTitleAndDescription: Story = {
|
|
|
175
175
|
description="Experience points earned across different programming languages"
|
|
176
176
|
hideDescription
|
|
177
177
|
hideTitle
|
|
178
|
-
|
|
178
|
+
maxScaleValue={2000}
|
|
179
179
|
title="Programming Skills Overview"
|
|
180
180
|
unit="XP"
|
|
181
181
|
/>
|
|
@@ -199,11 +199,11 @@ export const WithExternalTitle: Story = {
|
|
|
199
199
|
Programming Skills Overview
|
|
200
200
|
</Box>
|
|
201
201
|
<BarChart
|
|
202
|
-
aria-labelledby="external-title"
|
|
202
|
+
aria-labelledby="external-chart-title"
|
|
203
203
|
barValues={simpleBarData}
|
|
204
204
|
description="Experience points earned across different programming languages"
|
|
205
205
|
hideDescription={false}
|
|
206
|
-
|
|
206
|
+
maxScaleValue={2000}
|
|
207
207
|
unit="XP"
|
|
208
208
|
/>
|
|
209
209
|
</>
|
|
@@ -306,8 +306,8 @@ export const CustomStyles: Story = {
|
|
|
306
306
|
export const CustomScale: Story = {
|
|
307
307
|
args: {
|
|
308
308
|
barValues: simpleBarData,
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
maxScaleValue: 2000,
|
|
310
|
+
scaleInterval: 250,
|
|
311
311
|
title: 'Skills chart with custom scale',
|
|
312
312
|
description: 'Custom scale intervals for more granular value display',
|
|
313
313
|
},
|
|
@@ -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
|
},
|