@codecademy/styleguide 79.2.3-alpha.66bcf1.0 → 79.2.3-alpha.66d178.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.2.3-alpha.
|
|
6
|
+
### [79.2.3-alpha.66d178.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.2.2...@codecademy/styleguide@79.2.3-alpha.66d178.0) (2026-03-19)
|
|
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.2.3-alpha.
|
|
4
|
+
"version": "79.2.3-alpha.66d178.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": "e17036cd3d4e50fa86d1bd97b1643b0bfd373725"
|
|
12
12
|
}
|
|
@@ -131,14 +131,15 @@ When a bar has an `href` link, an `aria-label` is automatically generated from t
|
|
|
131
131
|
|
|
132
132
|
## Title and description
|
|
133
133
|
|
|
134
|
-
The `BarChart` component uses semantic HTML to provide context and accessibility. The chart is wrapped in a [`<figure>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure), and the description is displayed in a [`<figcaption>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption). This semantic structure helps screen readers and other assistive technologies understand the relationship between the chart and its description.
|
|
134
|
+
The `BarChart` component uses semantic HTML to provide context and accessibility. The chart is wrapped in a [`<figure>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure), and the description is displayed in a [`<figcaption>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption). This semantic structure helps screen readers and other assistive technologies understand the relationship between the chart and its description.
|
|
135
135
|
|
|
136
136
|
**Preferred pattern: Visual title + description**
|
|
137
137
|
|
|
138
138
|
Provide both `title` and `description` props to make the chart's purpose and key takeaways clear to all users:
|
|
139
139
|
|
|
140
|
-
- `title`: A heading that identifies the chart. Can be a string or an object with `{ as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', title: string, variant?: Text['variant'] }` to specify the heading level and optionally override the default styling with a <LinkTo id="Typography/Text">Text variant</LinkTo>.
|
|
141
|
-
- `description`: A summary of the information or the overall takeaway displayed in the `<figcaption>` element.
|
|
140
|
+
- `title`: A heading that identifies the chart. Can be a string or an object with `{ as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', title: string, variant?: Text['variant'] }` to specify the heading level and optionally override the default styling with a <LinkTo id="Typography/Text">Text variant</LinkTo>. Use semantic heading levels (h1–h6) so the surrounding document outline stays correct.
|
|
141
|
+
- `description`: **Required.** A summary of the information or the overall takeaway displayed in the `<figcaption>` element.
|
|
142
|
+
- When the visible title lives outside the chart, use `aria-labelledby` to point at that heading (see below). The referenced element must exist and have an accessible name.
|
|
142
143
|
|
|
143
144
|
<Canvas of={BarChartStories.WithVisualTitleAndDescription} />
|
|
144
145
|
|
|
@@ -151,12 +152,6 @@ Provide both `title` and `description` props to make the chart's purpose and key
|
|
|
151
152
|
|
|
152
153
|
<Canvas of={BarChartStories.WithExternalTitle} />
|
|
153
154
|
|
|
154
|
-
**Best practices:**
|
|
155
|
-
|
|
156
|
-
- Always provide a `description` prop - it's required and should summarize the chart's key information
|
|
157
|
-
- Use semantic heading levels for titles (h1-h6) to maintain proper document structure
|
|
158
|
-
- When using `aria-labelledby`, ensure the referenced element exists and is properly labeled
|
|
159
|
-
|
|
160
155
|
## Sorting
|
|
161
156
|
|
|
162
157
|
`BarChart` includes an optional sorting dropdown in the title area. The dropdown only renders when the `sortFns` prop is provided. You can control which sort options appear by including string literals or custom sort functions in the array.
|
|
@@ -251,22 +246,6 @@ The `styleConfig` prop accepts an object with the following optional properties:
|
|
|
251
246
|
|
|
252
247
|
All color values should be valid color tokens from the Gamut design system. When customizing colors, ensure they maintain at least a 3:1 contrast ratio with the background for accessibility.
|
|
253
248
|
|
|
254
|
-
### Default values
|
|
255
|
-
|
|
256
|
-
If `styleConfig` is not provided, BarChart uses these default colors:
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
{
|
|
260
|
-
textColor: 'text',
|
|
261
|
-
seriesOneBarColor: 'text',
|
|
262
|
-
seriesTwoBarColor: 'primary',
|
|
263
|
-
seriesOneLabel: 'text-secondary',
|
|
264
|
-
seriesTwoLabel: 'primary',
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### Example
|
|
269
|
-
|
|
270
249
|
<Canvas of={BarChartStories.CustomStyles} />
|
|
271
250
|
|
|
272
251
|
## Custom scale
|
|
@@ -349,7 +328,7 @@ BarChart supports internationalization through the `translations` prop. You can
|
|
|
349
328
|
- **sortLabel**, **sortOptions**, and **locale** — Always strings. Control the sort dropdown label, option labels, and number-formatting locale.
|
|
350
329
|
- **Accessibility** — Two optional summary functions; when omitted, default English summaries are used. Each function receives context and returns the full summary string.
|
|
351
330
|
- `**stackedBarSummary**` — Used for stacked (two-value) rows. Context includes `seriesOneValue`, `seriesTwoValue`, **gained** (seriesTwoValue - seriesOneValue), `unit`, `locale`, `categoryLabel`.
|
|
352
|
-
-
|
|
331
|
+
- `**singleValueBarSummary**` — Used for all single-value rows. Context includes `value`, `unit`, `locale`, `categoryLabel`.
|
|
353
332
|
|
|
354
333
|
### Where accessibility summaries appear
|
|
355
334
|
|