@codecademy/styleguide 78.5.5-alpha.cb4c1d.0 → 78.5.5

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.
@@ -0,0 +1,17 @@
1
+ import styled from '@emotion/styled';
2
+ import { css } from '@codecademy/gamut-styles';
3
+
4
+ export const KeyboardKey = styled.kbd(
5
+ css({
6
+ mx: 2 as any,
7
+ fontFamily: 'monospace',
8
+ fontSize: '0.75rem' as any,
9
+ bg: 'background-selected',
10
+ border: 1,
11
+ borderColor: 'border-tertiary',
12
+ borderRadius: 'sm',
13
+ px: 4,
14
+ py: 2 as any,
15
+ boxShadow: 'inset 0 -1px 0 rgba(0, 0, 0, 0.2)',
16
+ })
17
+ );
@@ -2,6 +2,7 @@ export * from './ImageWrapper';
2
2
  export * from './TokenTable';
3
3
  export * from './Headers';
4
4
  export * from './Elements/Callout';
5
+ export * from './Elements/KeyboardKey';
5
6
  export * from './Elements/Markdown';
6
7
  export * from './Elements/ImageGallery';
7
8
  export * from './Scales/ColorScale';
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
- ### [78.5.5-alpha.cb4c1d.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@78.5.4...@codecademy/styleguide@78.5.5-alpha.cb4c1d.0) (2026-01-07)
6
+ ### [78.5.5](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@78.5.4...@codecademy/styleguide@78.5.5) (2026-01-07)
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": "78.5.5-alpha.cb4c1d.0",
4
+ "version": "78.5.5",
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": "8f9681525aad2b306aff70b92f65739463850b5a"
11
+ "gitHead": "2434f4c9b000f1952a8a234749e999ac19295882"
12
12
  }
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
- import { ComponentHeader } from '~styleguide/blocks';
3
+ import { ComponentHeader, KeyboardKey } from '~styleguide/blocks';
4
4
 
5
5
  import * as SkipToContentStories from './SkipToContent.stories';
6
6
 
@@ -21,11 +21,10 @@ export const parameters = {
21
21
 
22
22
  ## Usage
23
23
 
24
- Use `<SkipToContent />` to add a hidden-by-default link that becomes visible when the user <kbd>Tab</kbd>s over it (gives it focus).
24
+ Use `<SkipToContent />` to add a hidden-by-default link that becomes visible when the user <KeyboardKey>Tab</KeyboardKey>s over it (gives it focus).
25
25
  It takes in the ID of the element it will scroll to and focus ([dev.to article explaining why](https://dev.to/robdodson/managing-focus-64l)) on click (via mouse or keyboard).
26
26
 
27
- This type of control is necessary for pages that have a bunch of stuff keyboard users would have to Tab through to get
28
- to the page's main content (like navigations).
27
+ This type of control is necessary for pages that have a bunch of stuff keyboard users would have to <KeyboardKey>Tab</KeyboardKey> through to get to the page's main content (like navigations).
29
28
 
30
29
  For this element to work properly, there must be a `<SkipToContentTarget />` component with the id passed into this component for the `contentId` prop. The `<SkipToContentTarget />` component by default has a `tabIndex` of -1.
31
30
  Example:
@@ -43,7 +42,7 @@ Example:
43
42
  </div>
44
43
  ```
45
44
 
46
- To see it, keep tabbing around on this page or visit [the catalog](https://www.codecademy.com/catalog/language/javascript) and navigate via tab to see it in action.
45
+ To see it, keep pressing <KeyboardKey>Tab</KeyboardKey> around on this page or visit [the catalog](https://www.codecademy.com/catalog/language/javascript) and navigate via <KeyboardKey>Tab</KeyboardKey> to see it in action.
47
46
 
48
47
  ## Playground
49
48
 
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
- import { ComponentHeader, LinkTo } from '~styleguide/blocks';
3
+ import { ComponentHeader, KeyboardKey, LinkTo } from '~styleguide/blocks';
4
4
 
5
5
  import * as FlyoutStories from './Flyout.stories';
6
6
 
@@ -25,7 +25,7 @@ export const parameters = {
25
25
 
26
26
  ## Usage
27
27
 
28
- On button click, a container animates in from the left or right side of the window. Flyout can be configured to close by pressing the X close icon, pressing they “esc” key, and/or clicking outside of the container.
28
+ On button click, a container animates in from the left or right side of the window. Flyout can be configured to close by pressing the "X" close icon, pressing the <KeyboardKey>Esc</KeyboardKey> key, and/or clicking outside of the container.
29
29
 
30
30
  Internally, Flyout is a combination of <LinkTo id="Molecules/Modals/Overlay">Overlay</LinkTo> and <LinkTo id="Atoms/Drawer">Drawer</LinkTo>.
31
31
 
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
- import { ComponentHeader } from '~styleguide/blocks';
3
+ import { ComponentHeader, KeyboardKey } from '~styleguide/blocks';
4
4
 
5
5
  import * as ModalStories from './Modal.stories';
6
6
 
@@ -77,7 +77,7 @@ If the close button is hidden, you will need to create a custom way to close the
77
77
  Other than creating buttons that can close the Modal, there are other ways a Modal can be closed by the user.
78
78
 
79
79
  1. Clicking the content outside of the Modal
80
- 2. Clicking the escape key on their keyboard
80
+ 2. Pressing the <KeyboardKey>Esc</KeyboardKey> key on their keyboard
81
81
 
82
82
  All of these methods default to `true` for accessibility reasons, and rely on setting the required `onRequestClose` prop and making sure it toggles the `isOpen` prop on the Modal.
83
83
 
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
- import { ComponentHeader, LinkTo } from '~styleguide/blocks';
3
+ import { ComponentHeader, KeyboardKey, LinkTo } from '~styleguide/blocks';
4
4
 
5
5
  import * as TabStories from './Tabs.stories';
6
6
 
@@ -67,7 +67,7 @@ It is recommended to add a unique `aria-label` to the `TabNav` component, to dif
67
67
 
68
68
  ### Tabs with interactive content
69
69
 
70
- Normally, when you navigate to the contents of a `TabPanel` using the <kbd>tab</kbd> key or arrow keys, the entire section of the `TabPanel` will be in focus.
70
+ Normally, when you navigate to the contents of a `TabPanel` using the <KeyboardKey>Tab</KeyboardKey> key or arrow keys, the entire section of the `TabPanel` will be in focus.
71
71
 
72
72
  However, if you have tabs with interactive content within them (such as a button or link), and tab into the `TabPanel`, the focus will be on the interactive content and not the entirety of the `TabPanel`.
73
73
 
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
- import { ComponentHeader } from '~styleguide/blocks';
3
+ import { ComponentHeader, KeyboardKey } from '~styleguide/blocks';
4
4
 
5
5
  import * as InfoTipStories from './InfoTip.stories';
6
6
 
@@ -25,7 +25,7 @@ export const parameters = {
25
25
 
26
26
  ## Usage
27
27
 
28
- A tip is triggered by clicking on an information icon button and can be closed by clicking outside, pressing <kbd>Esc</kbd>, or clicking the info button again.
28
+ A tip is triggered by clicking on an information icon button and can be closed by clicking outside, pressing <KeyboardKey>Esc</KeyboardKey>, or clicking the info button again.
29
29
 
30
30
  Use an infotip to provide additional info about a nearby element or content.
31
31
 
@@ -65,9 +65,9 @@ Links or buttons within InfoTips should be used sparingly and only when the info
65
65
 
66
66
  When using `placement="floating"`, InfoTips implements focus management for easier navigation:
67
67
 
68
- - **Tab**: Navigate forward through focusable elements (links, buttons) inside the tip. When reaching the last element, wraps back to the InfoTip button for convenience
69
- - **Shift+Tab**: Navigate backward naturally through the page
70
- - **Escape**: Closes the tip and returns focus to the InfoTip button
68
+ - **<KeyboardKey>Tab</KeyboardKey>**: Navigate forward through focusable elements (links, buttons) inside the tip. When reaching the last element, wraps back to the InfoTip button for convenience
69
+ - **<KeyboardKey>Shift</KeyboardKey>+<KeyboardKey>Tab</KeyboardKey>**: Navigate backward naturally through the page
70
+ - **<KeyboardKey>Esc</KeyboardKey>**: Closes the tip and returns focus to the InfoTip button
71
71
 
72
72
  <Canvas of={InfoTipStories.KeyboardNavigation} />
73
73
 
@@ -75,10 +75,10 @@ When using `placement="floating"`, InfoTips implements focus management for easi
75
75
 
76
76
  InfoTips have intelligent Escape key handling that works correctly both inside and outside Modals:
77
77
 
78
- - **InfoTips close on Escape** regardless of where keyboard focus is, and focus returns to the InfoTip button
79
- - **InfoTips inside Modals close first** - When an InfoTip is placed inside a Modal, pressing Escape closes the InfoTip while keeping the Modal open
80
- - **Layered navigation** - After closing an InfoTip inside a Modal, pressing Escape again closes the Modal
81
- - **Modals take priority over external InfoTips** - InfoTips detect when `dialog[open]`, `role="dialog"`, or `role="alertdialog"` elements are present and defer Escape handling to them when the InfoTip is outside the Modal
78
+ - **InfoTips close on <KeyboardKey>Esc</KeyboardKey>** regardless of where keyboard focus is, and focus returns to the InfoTip button
79
+ - **InfoTips inside Modals close first** - When an InfoTip is placed inside a Modal, pressing <KeyboardKey>Esc</KeyboardKey> closes the InfoTip while keeping the Modal open
80
+ - **Layered navigation** - After closing an InfoTip inside a Modal, pressing <KeyboardKey>Esc</KeyboardKey> again closes the Modal
81
+ - **Modals take priority over external InfoTips** - InfoTips detect when `dialog[open]`, `role="dialog"`, or `role="alertdialog"` elements are present and defer <KeyboardKey>Esc</KeyboardKey> handling to them when the InfoTip is outside the Modal
82
82
 
83
83
  <Canvas of={InfoTipStories.InfoTipInsideModal} />
84
84
 
@@ -1,92 +0,0 @@
1
- import { Canvas, Controls, Meta } from '@storybook/blocks';
2
-
3
- import { ComponentHeader } from '~styleguide/blocks';
4
-
5
- import * as BarChartStories from './BarChart.stories';
6
-
7
- export const parameters = {
8
- subtitle: `A horizontal bar chart for visualizing comparative data`,
9
- design: {
10
- type: 'figma',
11
- url: 'https://www.figma.com/design/ReGfRNillGABAj5SlITalN/%F0%9F%93%90-Gamut?node-id=55123-4176',
12
- },
13
- status: 'current',
14
- source: {
15
- repo: 'gamut',
16
- githubLink:
17
- 'https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/BarChart',
18
- },
19
- };
20
-
21
- <Meta of={BarChartStories} />;
22
-
23
- <ComponentHeader {...parameters} />
24
-
25
- ## Usage
26
-
27
- Use BarChart to display comparative data across categories, such as skills progress, XP earned, or any quantitative metrics that benefit from visual comparison.
28
-
29
- ### Best practices:
30
-
31
- - Use consistent units across all bars in a chart
32
- - Limit the number of bars to maintain readability (5-10 is optimal)
33
- - Consider using the stacked variant to show progress toward a goal
34
- - Sort bars by value (descending) when ranking is important
35
-
36
- When NOT to use
37
-
38
- - For showing trends over time - use a line chart instead
39
- - For showing parts of a whole - use a pie or donut chart
40
- - For very small datasets (1-2 items) - consider using ProgressBar
41
-
42
- ## Variants
43
-
44
- ### Simple (Non-stacked)
45
-
46
- Use the simple variant when showing single values per category. Only `seriesOneValue` is provided.
47
-
48
- <Canvas of={BarChartStories.Default} />
49
-
50
- ### Stacked
51
-
52
- Use the stacked variant when showing progress within a total. Provide both `seriesOneValue` (progress) and `seriesTwoValue` (total).
53
-
54
- <Canvas of={BarChartStories.Stacked} />
55
-
56
- ### With Icons
57
-
58
- Add icons to labels for better visual identification of categories.
59
-
60
- <Canvas of={BarChartStories.WithIcons} />
61
-
62
- ### Animated
63
-
64
- Enable entrance animations for a more engaging experience.
65
-
66
- <Canvas of={BarChartStories.Animated} />
67
-
68
- ### Interactive
69
-
70
- Rows can be made interactive with `onClick` handlers or `href` links.
71
-
72
- <Canvas of={BarChartStories.Interactive} />
73
-
74
- ## Playground
75
-
76
- <Canvas sourceState="shown" of={BarChartStories.Default} />
77
-
78
- <Controls />
79
-
80
- ## Accessibility considerations
81
-
82
- - Always provide either `aria-label` or `aria-labelledby` to describe the chart
83
- - Each row automatically generates an accessible label summarizing its values
84
- - Interactive rows (with onClick/href) are properly announced as buttons/links
85
- - Grid lines are marked as decorative and hidden from screen readers
86
- - The scale header is hidden on small screens and marked as decorative
87
-
88
- ## UX writing
89
-
90
- - Keep y-axis labels concise (1-3 words)
91
- - Use consistent unit labels (e.g., "XP", "hours", "points")
92
- - Consider locale-aware number formatting for international audiences
@@ -1,183 +0,0 @@
1
- import { BarChart, BarProps } from '@codecademy/gamut';
2
- import {
3
- BookFlipPageIcon,
4
- CodeIcon,
5
- DataScienceIcon,
6
- GameControllerIcon,
7
- TerminalIcon,
8
- } from '@codecademy/gamut-icons';
9
- import { action } from '@storybook/addon-actions';
10
- import type { Meta, StoryObj } from '@storybook/react';
11
-
12
- const meta: Meta<typeof BarChart> = {
13
- component: BarChart,
14
- args: {
15
- 'aria-label': 'Skills experience chart',
16
- minRange: 0,
17
- maxRange: 2000,
18
- unit: 'XP',
19
- },
20
- };
21
-
22
- export default meta;
23
- type Story = StoryObj<typeof BarChart>;
24
-
25
- // Sample data for non-stacked (simple) bars
26
- const simpleBarData: BarProps[] = [
27
- { yLabel: 'Python', seriesOneValue: 1500 },
28
- { yLabel: 'JavaScript', seriesOneValue: 2000 },
29
- { yLabel: 'HTML/CSS', seriesOneValue: 800 },
30
- { yLabel: 'SQL', seriesOneValue: 600 },
31
- { yLabel: 'React', seriesOneValue: 450 },
32
- ];
33
-
34
- // Sample data for stacked bars (with seriesTwoValue)
35
- const stackedBarData: BarProps[] = [
36
- { yLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
37
- { yLabel: 'JavaScript', seriesOneValue: 1800, seriesTwoValue: 2000 },
38
- { yLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
39
- { yLabel: 'SQL', seriesOneValue: 550, seriesTwoValue: 600 },
40
- { yLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
41
- ];
42
-
43
- // Sample data with icons
44
- const barDataWithIcons: BarProps[] = [
45
- {
46
- yLabel: 'Python',
47
- seriesOneValue: 200,
48
- seriesTwoValue: 1500,
49
- icon: CodeIcon,
50
- },
51
- {
52
- yLabel: 'JavaScript',
53
- seriesOneValue: 150,
54
- seriesTwoValue: 2000,
55
- icon: TerminalIcon,
56
- },
57
- {
58
- yLabel: 'Data Science',
59
- seriesOneValue: 100,
60
- seriesTwoValue: 800,
61
- icon: DataScienceIcon,
62
- },
63
- {
64
- yLabel: 'Game Dev',
65
- seriesOneValue: 50,
66
- seriesTwoValue: 600,
67
- icon: GameControllerIcon,
68
- },
69
- {
70
- yLabel: 'Reading',
71
- seriesOneValue: 75,
72
- seriesTwoValue: 450,
73
- icon: BookFlipPageIcon,
74
- },
75
- ];
76
-
77
- /**
78
- * Default non-stacked bar chart showing single values
79
- */
80
- export const Default: Story = {
81
- args: {
82
- barValues: simpleBarData,
83
- },
84
- };
85
-
86
- /**
87
- * Stacked bar chart showing progress (seriesOneValue) over total (seriesTwoValue)
88
- */
89
- export const Stacked: Story = {
90
- args: {
91
- barValues: stackedBarData,
92
- },
93
- };
94
-
95
- /**
96
- * Bar chart with icons next to labels
97
- */
98
- export const WithIcons: Story = {
99
- args: {
100
- barValues: barDataWithIcons,
101
- },
102
- };
103
-
104
- /**
105
- * Animated bar chart with staggered entrance
106
- */
107
- export const Animated: Story = {
108
- args: {
109
- barValues: stackedBarData,
110
- animate: true,
111
- },
112
- };
113
-
114
- /**
115
- * Bar chart sorted by value in descending order
116
- */
117
- export const SortedByValue: Story = {
118
- args: {
119
- barValues: simpleBarData,
120
- sortBy: 'value',
121
- order: 'descending',
122
- },
123
- };
124
-
125
- /**
126
- * Bar chart sorted alphabetically by label
127
- */
128
- export const SortedByLabel: Story = {
129
- args: {
130
- barValues: simpleBarData,
131
- sortBy: 'label',
132
- order: 'ascending',
133
- },
134
- };
135
-
136
- /**
137
- * Interactive bar chart with clickable rows
138
- */
139
- export const Interactive: Story = {
140
- args: {
141
- barValues: simpleBarData.map((bar) => ({
142
- ...bar,
143
- onClick: action(`Clicked ${bar.yLabel}`),
144
- })),
145
- },
146
- };
147
-
148
- /**
149
- * Interactive bar chart with linked rows
150
- */
151
- export const WithLinks: Story = {
152
- args: {
153
- barValues: simpleBarData.map((bar) => ({
154
- ...bar,
155
- href: `#${bar.yLabel.toLowerCase().replace(/\s+/g, '-')}`,
156
- })),
157
- },
158
- };
159
-
160
- /**
161
- * Bar chart with custom styling
162
- */
163
- export const CustomStyles: Story = {
164
- args: {
165
- barValues: stackedBarData,
166
- styleConfig: {
167
- backgroundBarColor: 'paleGreen',
168
- foregroundBarColor: 'feedback-success',
169
- textColor: 'navy',
170
- },
171
- },
172
- };
173
-
174
- /**
175
- * Bar chart with custom xScale interval
176
- */
177
- export const CustomScale: Story = {
178
- args: {
179
- barValues: simpleBarData,
180
- maxRange: 2000,
181
- xScale: 250,
182
- },
183
- };