@codecademy/styleguide 78.5.5-alpha.ebe1b3.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.ebe1b3.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@78.5.4...@codecademy/styleguide@78.5.5-alpha.ebe1b3.0) (2026-01-06)
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.ebe1b3.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": "873587dd5513aace45c681f478a5ceb4de320604"
11
+ "gitHead": "2434f4c9b000f1952a8a234749e999ac19295882"
12
12
  }
@@ -69,12 +69,6 @@ A field can include <LinkTo id="Molecules/Tips/InfoTip"> our existing `InfoTip`<
69
69
 
70
70
  <Canvas of={FormGroupStories.HighEmphasisInfoTip} />
71
71
 
72
- #### Accessibility
73
-
74
- InfoTip buttons are automatically labelled by string field labels for accessibility.
75
-
76
- <Canvas of={FormGroupStories.InfoTipAutoLabelling} />
77
-
78
72
  ## Playground
79
73
 
80
74
  <Canvas sourceState="shown" of={FormGroupStories.Default} />
@@ -97,14 +97,3 @@ export const HighEmphasisInfoTip: Story = {
97
97
  children: <Input />,
98
98
  },
99
99
  };
100
-
101
- export const InfoTipAutoLabelling: Story = {
102
- args: {
103
- label: 'Email address',
104
- htmlFor: 'auto-label-input',
105
- infotip: {
106
- info: 'We will never share your email with third parties.',
107
- },
108
- children: <Input htmlFor="auto-label-input" type="email" />,
109
- },
110
- };
@@ -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,10 +25,11 @@ 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
- The info button has low and high emphasis variants and the `Tip` has 4 alignment variants.
31
+
32
+ Infotip consists of an icon button and the .tip-bg subcomponent. The info button has low and high emphasis variants and the `.tip` has 4 alignment variants.
32
33
 
33
34
  ## Variants
34
35
 
@@ -56,19 +57,17 @@ This `floating` variant should only be used as needed.
56
57
 
57
58
  ### InfoTips with links or buttons
58
59
 
59
- Links or buttons within InfoTips should be used sparingly and only when the information is critical to the user's understanding of the content. When an InfoTip opens, focus automatically moves to the tip content, allowing keyboard users to immediately interact with any links or buttons inside.
60
+ Links or buttons within InfoTips should be used sparingly and only when the information is critical to the user's understanding of the content. If an infotip _absolutely requires_ a link or button, it needs to provide a programmatic focus by way of the `onClick` prop. The `onClick` prop accepts a function that can accept an `{isTipHidden}` argument and using that you can set programmatic focus as needed.
60
61
 
61
62
  <Canvas of={InfoTipStories.WithLinksOrButtons} />
62
63
 
63
- ### Automatic Focus Management
64
+ ### Floating placement
64
65
 
65
- InfoTips automatically manage focus for optimal keyboard accessibility:
66
+ When using `placement="floating"`, InfoTips implements focus management for easier navigation:
66
67
 
67
- - **Opening**: Focus automatically moves to the tip content when opened
68
- - **Tab (Floating)**: Navigate forward through focusable elements (links, buttons) inside the tip. When reaching the last element, wraps back to the InfoTip button
69
- - **Shift+Tab (Floating)**: Navigate backward naturally - from the button, exits to the previous page element
70
- - **Tab/Shift+Tab (Inline)**: Follows normal document flow
71
- - **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
72
71
 
73
72
  <Canvas of={InfoTipStories.KeyboardNavigation} />
74
73
 
@@ -76,28 +75,13 @@ InfoTips automatically manage focus for optimal keyboard accessibility:
76
75
 
77
76
  InfoTips have intelligent Escape key handling that works correctly both inside and outside Modals:
78
77
 
79
- - **InfoTips close on Escape** regardless of where keyboard focus is, and focus returns to the InfoTip button
80
- - **InfoTips inside Modals close first** - When an InfoTip is placed inside a Modal, pressing Escape closes the InfoTip while keeping the Modal open
81
- - **Layered navigation** - After closing an InfoTip inside a Modal, pressing Escape again closes the Modal
82
- - **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
83
82
 
84
83
  <Canvas of={InfoTipStories.InfoTipInsideModal} />
85
84
 
86
- ## Custom Accessible Labeling
87
-
88
- Provide either `ariaLabel` or `ariaLabelledby` to ensure screen reader users understand the purpose of the InfoTip button.
89
-
90
- The InfoTip button's accessible label can be customized using either prop:
91
-
92
- - **`ariaLabel`**: Directly sets the accessible label text. Useful when you want to provide a custom label without referencing another element.
93
- - **`ariaLabelledby`**: References the ID of another element to use as the label. Useful when you want the InfoTip button to be labeled by visible text elsewhere on the page. This is useful for when the `InfoTip` is beside text that contextualizes it.
94
-
95
- ### Custom Role Description
96
-
97
- The `InfoTipButton` uses [`aria-roledescription`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-roledescription) to provide additional context to screen reader users about the button's specific purpose. This defaults to `"More information button"` but can be customized via the `ariaRoleDescription` prop for translation or other accessibility needs.
98
-
99
- <Canvas of={InfoTipStories.AriaLabel} />
100
-
101
85
  ## InfoTips and zIndex
102
86
 
103
87
  You can change the zIndex of your `InfoTip` with the zIndex property.
@@ -4,20 +4,17 @@ import {
4
4
  FillButton,
5
5
  FlexBox,
6
6
  GridBox,
7
- IconButton,
8
7
  InfoTip,
9
8
  Modal,
10
9
  Text,
11
10
  } from '@codecademy/gamut';
12
- import { SparkleIcon } from '@codecademy/gamut-icons';
13
11
  import type { Meta, StoryObj } from '@storybook/react';
14
- import { useState } from 'react';
12
+ import { useRef, useState } from 'react';
15
13
 
16
14
  const meta: Meta<typeof InfoTip> = {
17
15
  component: InfoTip,
18
16
  args: {
19
17
  alignment: 'top-left',
20
- ariaLabel: 'More information',
21
18
  info: `I am additional information about a nearby element or content.`,
22
19
  },
23
20
  };
@@ -31,10 +28,7 @@ export const Emphasis: Story = {
31
28
  },
32
29
  render: (args) => (
33
30
  <FlexBox center m={24} py={64}>
34
- <Text id="emphasis-text" mr={4}>
35
- Some text that needs info
36
- </Text>
37
- <InfoTip {...args} ariaLabelledby="emphasis-text" />
31
+ <Text mr={4}>Some text that needs info</Text> <InfoTip {...args} />
38
32
  </FlexBox>
39
33
  ),
40
34
  };
@@ -44,15 +38,10 @@ export const Alignments: Story = {
44
38
  <GridBox gap={24} gridTemplateColumns="1fr 1fr" ml={8} py={64}>
45
39
  {(['top-right', 'top-left', 'bottom-right', 'bottom-left'] as const).map(
46
40
  (alignment) => {
47
- const labelId = `alignment-${alignment}`;
48
41
  return (
49
42
  <Box key={alignment}>
50
- <Text id={labelId}>{alignment}</Text>
51
- <InfoTip
52
- {...args}
53
- alignment={alignment}
54
- ariaLabelledby={labelId}
55
- />
43
+ <Text>{alignment}</Text>
44
+ <InfoTip {...args} alignment={alignment} />
56
45
  </Box>
57
46
  );
58
47
  }
@@ -67,51 +56,10 @@ export const Placement: Story = {
67
56
  },
68
57
  render: (args) => (
69
58
  <FlexBox center>
70
- <Text id="placement-text" mr={4}>
59
+ <Text mr={4}>
71
60
  This text is in a small space and needs floating placement
72
61
  </Text>{' '}
73
- <InfoTip {...args} ariaLabelledby="placement-text" />
74
- </FlexBox>
75
- ),
76
- };
77
-
78
- export const AriaLabel: Story = {
79
- render: (args) => (
80
- <FlexBox center column gap={24} my={48} width={1}>
81
- <FlexBox alignItems="center" gap={8}>
82
- <Text fontSize={16} fontWeight="bold">
83
- Using ariaLabel (no visible label text):
84
- </Text>
85
- </FlexBox>
86
- <FlexBox alignItems="center" gap={8}>
87
- <IconButton
88
- icon={SparkleIcon}
89
- tip="This tool needs to be explained in the InfoTip"
90
- tipProps={{ placement: 'floating' }}
91
- onClick={() => null}
92
- />
93
- <InfoTip
94
- {...args}
95
- ariaLabel="Learn more about this tool"
96
- info="This is some helpful info about the tool represented by the IconButton"
97
- />
98
- </FlexBox>
99
-
100
- <FlexBox alignItems="center" gap={8}>
101
- <Text fontSize={16} fontWeight="bold">
102
- Using ariaLabelledby (references visible text):
103
- </Text>
104
- </FlexBox>
105
- <FlexBox alignItems="center" gap={8}>
106
- <Text id="custom-info-id">
107
- I am some helpful yet concise text that needs more explanation
108
- </Text>
109
- <InfoTip
110
- alignment="bottom-left"
111
- ariaLabelledby="custom-info-id"
112
- info="I am clarifying information related to the concise text."
113
- />
114
- </FlexBox>
62
+ <InfoTip {...args} />
115
63
  </FlexBox>
116
64
  ),
117
65
  };
@@ -121,16 +69,19 @@ export const WithLinksOrButtons: Story = {
121
69
  placement: 'floating',
122
70
  },
123
71
  render: function WithLinksOrButtons(args) {
72
+ const ref = useRef<HTMLDivElement>(null);
73
+
74
+ const onClick = ({ isTipHidden }: { isTipHidden: boolean }) => {
75
+ if (!isTipHidden) ref.current?.focus();
76
+ };
77
+
124
78
  return (
125
79
  <FlexBox center py={64}>
126
- <Text id="links-text" mr={4}>
127
- This text is in a small space and needs info
128
- </Text>{' '}
80
+ <Text mr={4}>This text is in a small space and needs info </Text>{' '}
129
81
  <InfoTip
130
82
  {...args}
131
- ariaLabelledby="links-text"
132
83
  info={
133
- <Text tabIndex={-1}>
84
+ <Text ref={ref} tabIndex={-1}>
134
85
  Hey! Here is a{' '}
135
86
  <Anchor href="https://giphy.com/search/nichijou">
136
87
  cool link
@@ -142,6 +93,7 @@ export const WithLinksOrButtons: Story = {
142
93
  that is also super important.
143
94
  </Text>
144
95
  }
96
+ onClick={onClick}
145
97
  />
146
98
  </FlexBox>
147
99
  );
@@ -150,35 +102,42 @@ export const WithLinksOrButtons: Story = {
150
102
 
151
103
  export const KeyboardNavigation: Story = {
152
104
  render: function KeyboardNavigation() {
105
+ const floatingRef = useRef<HTMLDivElement>(null);
106
+ const inlineRef = useRef<HTMLDivElement>(null);
107
+
153
108
  const examples = [
154
109
  {
155
110
  title: 'Floating Placement',
156
111
  placement: 'floating' as const,
112
+ ref: floatingRef,
157
113
  links: ['Link 1', 'Link 2', 'Link 3'],
158
114
  },
159
115
  {
160
116
  title: 'Inline Placement',
161
117
  placement: 'inline' as const,
162
118
  alignment: 'bottom-right' as const,
119
+ ref: inlineRef,
163
120
  links: ['Link A', 'Link B'],
164
121
  },
165
122
  ];
166
123
 
167
124
  return (
168
- <FlexBox center flexDirection="column" gap={24} py={64}>
125
+ <FlexBox center column gap={24} py={64}>
169
126
  <GridBox gap={16} gridTemplateColumns="1fr 1fr">
170
- {examples.map(({ title, placement, alignment, links }) => {
171
- const labelId = `keyboard-nav-${placement}`;
127
+ {examples.map(({ title, placement, alignment, ref, links }) => {
128
+ const onClick = ({ isTipHidden }: { isTipHidden: boolean }) => {
129
+ if (!isTipHidden) ref.current?.focus();
130
+ };
131
+
172
132
  return (
173
133
  <FlexBox gap={8} key={placement}>
174
- <Text fontSize={16} fontWeight="bold" id={labelId}>
134
+ <Text fontSize={16} fontWeight="bold">
175
135
  {title}
176
136
  </Text>
177
137
  <InfoTip
178
138
  alignment={alignment}
179
- ariaLabelledby={labelId}
180
139
  info={
181
- <Text>
140
+ <Text ref={ref} tabIndex={-1}>
182
141
  {links.map((label, idx) => (
183
142
  <>
184
143
  {idx > 0 && ', '}
@@ -191,6 +150,7 @@ export const KeyboardNavigation: Story = {
191
150
  </Text>
192
151
  }
193
152
  placement={placement}
153
+ onClick={onClick}
194
154
  />
195
155
  </FlexBox>
196
156
  );
@@ -202,10 +162,6 @@ export const KeyboardNavigation: Story = {
202
162
  Keyboard Navigation:
203
163
  </Text>
204
164
  <Box as="ul" fontSize={14} pl={16}>
205
- <li>
206
- <strong>Opening:</strong> Focus automatically moves to the tip
207
- content when opened
208
- </li>
209
165
  <li>
210
166
  <strong>Floating - Tab:</strong> Navigates forward through links,
211
167
  then wraps to button (contained)
@@ -268,10 +224,8 @@ export const InfoTipInsideModal: Story = {
268
224
  <Text>This modal contains an InfoTip below:</Text>
269
225
 
270
226
  <FlexBox alignItems="center" gap={8}>
271
- <Text id="modal-infotip-text">
272
- Some text that needs explanation
273
- </Text>
274
- <InfoTip {...args} ariaLabelledby="modal-infotip-text" />
227
+ <Text>Some text that needs explanation</Text>
228
+ <InfoTip {...args} />
275
229
  </FlexBox>
276
230
 
277
231
  <Text color="text-disabled" fontSize={14}>
@@ -299,14 +253,11 @@ export const ZIndex: Story = {
299
253
  <Box bg="paleBlue" zIndex={3}>
300
254
  I will not be behind the infotip, sad + unreadable
301
255
  </Box>
302
- <InfoTip
303
- ariaLabel="z-index example without override"
304
- info="I am inline, cool"
305
- />
256
+ <InfoTip info="I am inline, cool" />
306
257
  <Box bg="paleBlue" zIndex={3}>
307
258
  I will be behind the infotip, nice + great
308
259
  </Box>
309
- <InfoTip {...args} ariaLabel="z-index example with override" />
260
+ <InfoTip {...args} />
310
261
  </FlexBox>
311
262
  ),
312
263
  };
@@ -314,10 +265,7 @@ export const ZIndex: Story = {
314
265
  export const Default: Story = {
315
266
  render: (args) => (
316
267
  <FlexBox center m={24} py={64}>
317
- <Text id="default-text" mr={4}>
318
- Some text that needs info
319
- </Text>
320
- <InfoTip {...args} ariaLabelledby="default-text" />
268
+ <Text mr={4}>Some text that needs info</Text> <InfoTip {...args} />
321
269
  </FlexBox>
322
270
  ),
323
271
  };
@@ -61,26 +61,6 @@ A `ConnectedFormGroup` can be in one of three states: `default`, `error`, or `di
61
61
 
62
62
  <Canvas of={ConnectedFormGroupStories.States} />
63
63
 
64
- ## InfoTip
65
-
66
- A `ConnectedFormGroup` can include an `infotip` prop to provide additional context.
67
-
68
- ### Automatic labelling
69
-
70
- InfoTip buttons are automatically labelled by string field labels for accessibility.
71
-
72
- <Canvas of={ConnectedFormGroupStories.InfoTipAutoLabelling} />
73
-
74
- ### ReactNode labels
75
-
76
- For ReactNode labels (e.g., styled text or icons), you have three options:
77
-
78
- - `labelledByFieldLabel: true` - opt into automatic labelling by the field label
79
- - `ariaLabel` - provide a custom accessible name
80
- - `ariaLabelledby` - reference another element on the page, such as a section heading
81
-
82
- <Canvas of={ConnectedFormGroupStories.InfoTipWithReactNodeLabel} />
83
-
84
64
  ## Playground
85
65
 
86
66
  To see how a `ConnectedFormGroup` can be used in a `ConnectedForm`, check out the <LinkTo id="Organisms/ConnectedForm/ConnectedForm">ConnectedForm</LinkTo> page.
@@ -2,9 +2,7 @@ import {
2
2
  ConnectedForm,
3
3
  ConnectedFormGroup,
4
4
  ConnectedFormGroupProps,
5
- ConnectedInput,
6
5
  ConnectedRadioGroupInput,
7
- Text,
8
6
  useConnectedForm,
9
7
  } from '@codecademy/gamut';
10
8
  import { action } from '@storybook/addon-actions';
@@ -121,85 +119,3 @@ export const States = () => {
121
119
  </ConnectedForm>
122
120
  );
123
121
  };
124
-
125
- /**
126
- * InfoTip buttons are automatically labelled by string field labels for accessibility.
127
- * Screen readers will announce "Field Label, button" when focusing the InfoTip.
128
- */
129
- export const InfoTipAutoLabelling: Story = {
130
- render: () => (
131
- <ConnectedForm
132
- defaultValues={{ email: '' }}
133
- onSubmit={(values) => action('Form Submitted')(values)}
134
- >
135
- <ConnectedFormGroup
136
- field={{ component: ConnectedInput, type: 'email' }}
137
- infotip={{
138
- info: 'We will never share your email with third parties.',
139
- placement: 'floating',
140
- }}
141
- label="Email address"
142
- name="email"
143
- />
144
- </ConnectedForm>
145
- ),
146
- };
147
-
148
- /**
149
- * For ReactNode labels, you have three options for accessible InfoTip labelling:
150
- * - `labelledByFieldLabel: true` - uses the field label
151
- * - `ariaLabel` - provides a custom accessible name
152
- * - `ariaLabelledby` - references another element on the page
153
- */
154
- export const InfoTipWithReactNodeLabel: Story = {
155
- render: () => (
156
- <ConnectedForm
157
- defaultValues={{ username: '', password: '', apiKey: '' }}
158
- onSubmit={(values) => action('Form Submitted')(values)}
159
- >
160
- <Text as="h3" id="api-section-heading" mb={8}>
161
- API Configuration
162
- </Text>
163
- <ConnectedFormGroup
164
- field={{ component: ConnectedInput }}
165
- infotip={{
166
- alignment: 'top-left',
167
- info: 'Choose a unique username between 3-20 characters.',
168
- labelledByFieldLabel: true,
169
- }}
170
- label={
171
- <Text as="span" fontWeight="bold">
172
- Username (labelledByFieldLabel)
173
- </Text>
174
- }
175
- name="username"
176
- />
177
- <ConnectedFormGroup
178
- field={{ component: ConnectedInput, type: 'password' }}
179
- infotip={{
180
- info: 'Password must be at least 8 characters with one uppercase letter and one number.',
181
- ariaLabel: 'Password requirements',
182
- }}
183
- label={
184
- <Text as="span" fontWeight="bold">
185
- Password (ariaLabel)
186
- </Text>
187
- }
188
- name="password"
189
- />
190
- <ConnectedFormGroup
191
- field={{ component: ConnectedInput }}
192
- infotip={{
193
- info: 'You can find your API key in the developer settings dashboard.',
194
- ariaLabelledby: 'api-section-heading',
195
- }}
196
- label={
197
- <Text as="span" fontWeight="bold">
198
- API Key (ariaLabelledby)
199
- </Text>
200
- }
201
- name="apiKey"
202
- />
203
- </ConnectedForm>
204
- ),
205
- };
@@ -95,23 +95,3 @@ Hidden inputs can be used to include data that users can't see or modify with th
95
95
  We call it a "sweet container" so that bots do not immediately detect it as a honeypot input.
96
96
 
97
97
  <Canvas of={FieldsStories.SweetContainer} />
98
-
99
- ## InfoTip
100
-
101
- Any field can include an `infotip` prop to provide additional context to users.
102
-
103
- ### Automatic labelling
104
-
105
- InfoTip buttons are automatically labelled by string field labels for accessibility.
106
-
107
- <Canvas of={FieldsStories.InfoTipAutoLabelling} />
108
-
109
- ### ReactNode labels
110
-
111
- For ReactNode labels, you have three options:
112
-
113
- - `labelledByFieldLabel: true` - opt into automatic labelling by the field label
114
- - `ariaLabel` - provide a custom accessible name
115
- - `ariaLabelledby` - reference another element on the page, such as a section heading
116
-
117
- <Canvas of={FieldsStories.InfoTipWithReactNodeLabel} />
@@ -1,4 +1,4 @@
1
- import { FormGroup, GridForm, Input, Text } from '@codecademy/gamut';
1
+ import { FormGroup, GridForm, Input } from '@codecademy/gamut';
2
2
  import { action } from '@storybook/addon-actions';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
 
@@ -328,75 +328,3 @@ export const SweetContainer: Story = {
328
328
  ],
329
329
  },
330
330
  };
331
-
332
- /**
333
- * InfoTip buttons are automatically labelled by string field labels for accessibility.
334
- * Screen readers will announce "Field Label, button" when focusing the InfoTip.
335
- */
336
- export const InfoTipAutoLabelling: Story = {
337
- args: {
338
- fields: [
339
- {
340
- label: 'Email address',
341
- name: 'email',
342
- size: 9,
343
- type: 'email',
344
- infotip: {
345
- info: 'We will never share your email with third parties.',
346
- placement: 'floating',
347
- },
348
- },
349
- ],
350
- },
351
- };
352
-
353
- /**
354
- * For ReactNode labels, you have three options for accessible InfoTip labelling:
355
- * - `labelledByFieldLabel: true` - uses the field label
356
- * - `ariaLabel` - provides a custom accessible name
357
- * - `ariaLabelledby` - references another element on the page
358
- */
359
- export const InfoTipWithReactNodeLabel: Story = {
360
- render: (args) => (
361
- <>
362
- <Text as="h3" id="api-section-heading" mb={8}>
363
- API Configuration
364
- </Text>
365
- <GridForm {...args} />
366
- </>
367
- ),
368
- args: {
369
- fields: [
370
- {
371
- label: <strong>Username (labelledByFieldLabel)</strong>,
372
- name: 'username',
373
- size: 9,
374
- type: 'text',
375
- infotip: {
376
- info: 'Choose a unique username between 3-20 characters.',
377
- labelledByFieldLabel: true,
378
- },
379
- },
380
- {
381
- label: <strong>Password (ariaLabel)</strong>,
382
- name: 'password',
383
- size: 9,
384
- type: 'password',
385
- infotip: {
386
- info: 'Password must be at least 8 characters with one uppercase letter and one number.',
387
- ariaLabel: 'Password requirements',
388
- },
389
- },
390
- {
391
- label: <strong>API Key (ariaLabelledby)</strong>,
392
- name: 'apiKey',
393
- size: 9,
394
- type: 'text',
395
- infotip: {
396
- info: 'You can find your API key in the developer settings dashboard.',
397
- ariaLabelledby: 'api-section-heading',
398
- },
399
- },
400
- ],
401
- },
402
- };
@@ -34,7 +34,7 @@ Solo field form should always have their solo input be required. They should aut
34
34
 
35
35
  ## InfoTips
36
36
 
37
- A field can include our existing `InfoTip`. See the <LinkTo id="Molecules/Tips/InfoTip">Fields</LinkTo> story for specific accessibility tooling and <LinkTo id="Molecules/Tips/InfoTip">InfoTip</LinkTo> story for more information on what props are available.
37
+ A field can include our existing `InfoTip`. See the <LinkTo id="Molecules/Tips/InfoTip">InfoTip</LinkTo> story for more information on what props are available.
38
38
 
39
39
  See the <LinkTo id="Atoms/FormInputs/Radio">Radio</LinkTo> story for an example of how to add a infotip to a radio option.
40
40