@codecademy/styleguide 78.5.6-alpha.ea1cbb.0 → 78.5.6-alpha.eca584.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/.storybook/components/Elements/Markdown.tsx +1 -0
- package/CHANGELOG.md +1 -1
- package/package.json +2 -2
- package/src/lib/Atoms/FormElements/FormGroup/FormGroup.mdx +6 -0
- package/src/lib/Atoms/FormElements/FormGroup/FormGroup.stories.tsx +45 -4
- package/src/lib/Atoms/FormInputs/Checkbox/Checkbox.mdx +7 -1
- package/src/lib/Atoms/FormInputs/Checkbox/Checkbox.stories.tsx +21 -1
- package/src/lib/Atoms/FormInputs/Radio/Radio.mdx +8 -0
- package/src/lib/Atoms/FormInputs/Radio/Radio.stories.tsx +38 -4
- package/src/lib/Foundations/System/About.mdx +1 -1
- package/src/lib/Foundations/System/Props.mdx +230 -0
- package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.mdx +3 -3
- package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.stories.tsx +0 -1
- package/src/lib/Foundations/shared/elements.tsx +4 -16
- package/src/lib/Layouts/Boxes/Box/Box.stories.tsx +0 -1
- package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +24 -8
- package/src/lib/Molecules/Tips/InfoTip/InfoTip.stories.tsx +86 -34
- package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.mdx +19 -0
- package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.stories.tsx +73 -0
- package/src/lib/Organisms/GridForm/Fields.mdx +19 -0
- package/src/lib/Organisms/GridForm/Fields.stories.tsx +62 -1
- package/src/lib/Organisms/GridForm/Layout.mdx +1 -1
- package/src/lib/Foundations/System/Props/About.mdx +0 -81
- package/src/lib/Foundations/System/Props/Background.mdx +0 -30
- package/src/lib/Foundations/System/Props/Border.mdx +0 -33
- package/src/lib/Foundations/System/Props/Color.mdx +0 -28
- package/src/lib/Foundations/System/Props/Flex.mdx +0 -28
- package/src/lib/Foundations/System/Props/Grid.mdx +0 -31
- package/src/lib/Foundations/System/Props/Layout.mdx +0 -34
- package/src/lib/Foundations/System/Props/List.mdx +0 -38
- package/src/lib/Foundations/System/Props/Positioning.mdx +0 -29
- package/src/lib/Foundations/System/Props/Shadow.mdx +0 -31
- package/src/lib/Foundations/System/Props/Space.mdx +0 -28
- package/src/lib/Foundations/System/Props/Typography.mdx +0 -28
|
@@ -4,17 +4,20 @@ import {
|
|
|
4
4
|
FillButton,
|
|
5
5
|
FlexBox,
|
|
6
6
|
GridBox,
|
|
7
|
+
IconButton,
|
|
7
8
|
InfoTip,
|
|
8
9
|
Modal,
|
|
9
10
|
Text,
|
|
10
11
|
} from '@codecademy/gamut';
|
|
12
|
+
import { SparkleIcon } from '@codecademy/gamut-icons';
|
|
11
13
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
-
import {
|
|
14
|
+
import { useState } from 'react';
|
|
13
15
|
|
|
14
16
|
const meta: Meta<typeof InfoTip> = {
|
|
15
17
|
component: InfoTip,
|
|
16
18
|
args: {
|
|
17
19
|
alignment: 'top-left',
|
|
20
|
+
ariaLabel: 'More information',
|
|
18
21
|
info: `I am additional information about a nearby element or content.`,
|
|
19
22
|
},
|
|
20
23
|
};
|
|
@@ -28,7 +31,10 @@ export const Emphasis: Story = {
|
|
|
28
31
|
},
|
|
29
32
|
render: (args) => (
|
|
30
33
|
<FlexBox center m={24} py={64}>
|
|
31
|
-
<Text mr={4}>
|
|
34
|
+
<Text id="emphasis-text" mr={4}>
|
|
35
|
+
Some text that needs info
|
|
36
|
+
</Text>
|
|
37
|
+
<InfoTip {...args} ariaLabelledby="emphasis-text" />
|
|
32
38
|
</FlexBox>
|
|
33
39
|
),
|
|
34
40
|
};
|
|
@@ -38,10 +44,15 @@ export const Alignments: Story = {
|
|
|
38
44
|
<GridBox gap={24} gridTemplateColumns="1fr 1fr" ml={8} py={64}>
|
|
39
45
|
{(['top-right', 'top-left', 'bottom-right', 'bottom-left'] as const).map(
|
|
40
46
|
(alignment) => {
|
|
47
|
+
const labelId = `alignment-${alignment}`;
|
|
41
48
|
return (
|
|
42
49
|
<Box key={alignment}>
|
|
43
|
-
<Text>{alignment}</Text>
|
|
44
|
-
<InfoTip
|
|
50
|
+
<Text id={labelId}>{alignment}</Text>
|
|
51
|
+
<InfoTip
|
|
52
|
+
{...args}
|
|
53
|
+
alignment={alignment}
|
|
54
|
+
ariaLabelledby={labelId}
|
|
55
|
+
/>
|
|
45
56
|
</Box>
|
|
46
57
|
);
|
|
47
58
|
}
|
|
@@ -56,10 +67,51 @@ export const Placement: Story = {
|
|
|
56
67
|
},
|
|
57
68
|
render: (args) => (
|
|
58
69
|
<FlexBox center>
|
|
59
|
-
<Text mr={4}>
|
|
70
|
+
<Text id="placement-text" mr={4}>
|
|
60
71
|
This text is in a small space and needs floating placement
|
|
61
72
|
</Text>{' '}
|
|
62
|
-
<InfoTip {...args} />
|
|
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>
|
|
63
115
|
</FlexBox>
|
|
64
116
|
),
|
|
65
117
|
};
|
|
@@ -69,19 +121,16 @@ export const WithLinksOrButtons: Story = {
|
|
|
69
121
|
placement: 'floating',
|
|
70
122
|
},
|
|
71
123
|
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
|
-
|
|
78
124
|
return (
|
|
79
125
|
<FlexBox center py={64}>
|
|
80
|
-
<Text mr={4}>
|
|
126
|
+
<Text id="links-text" mr={4}>
|
|
127
|
+
This text is in a small space and needs info
|
|
128
|
+
</Text>{' '}
|
|
81
129
|
<InfoTip
|
|
82
130
|
{...args}
|
|
131
|
+
ariaLabelledby="links-text"
|
|
83
132
|
info={
|
|
84
|
-
<Text
|
|
133
|
+
<Text tabIndex={-1}>
|
|
85
134
|
Hey! Here is a{' '}
|
|
86
135
|
<Anchor href="https://giphy.com/search/nichijou">
|
|
87
136
|
cool link
|
|
@@ -93,7 +142,6 @@ export const WithLinksOrButtons: Story = {
|
|
|
93
142
|
that is also super important.
|
|
94
143
|
</Text>
|
|
95
144
|
}
|
|
96
|
-
onClick={onClick}
|
|
97
145
|
/>
|
|
98
146
|
</FlexBox>
|
|
99
147
|
);
|
|
@@ -102,42 +150,35 @@ export const WithLinksOrButtons: Story = {
|
|
|
102
150
|
|
|
103
151
|
export const KeyboardNavigation: Story = {
|
|
104
152
|
render: function KeyboardNavigation() {
|
|
105
|
-
const floatingRef = useRef<HTMLDivElement>(null);
|
|
106
|
-
const inlineRef = useRef<HTMLDivElement>(null);
|
|
107
|
-
|
|
108
153
|
const examples = [
|
|
109
154
|
{
|
|
110
155
|
title: 'Floating Placement',
|
|
111
156
|
placement: 'floating' as const,
|
|
112
|
-
ref: floatingRef,
|
|
113
157
|
links: ['Link 1', 'Link 2', 'Link 3'],
|
|
114
158
|
},
|
|
115
159
|
{
|
|
116
160
|
title: 'Inline Placement',
|
|
117
161
|
placement: 'inline' as const,
|
|
118
162
|
alignment: 'bottom-right' as const,
|
|
119
|
-
ref: inlineRef,
|
|
120
163
|
links: ['Link A', 'Link B'],
|
|
121
164
|
},
|
|
122
165
|
];
|
|
123
166
|
|
|
124
167
|
return (
|
|
125
|
-
<FlexBox center column gap={24} py={64}>
|
|
168
|
+
<FlexBox center flexDirection="column" gap={24} py={64}>
|
|
126
169
|
<GridBox gap={16} gridTemplateColumns="1fr 1fr">
|
|
127
|
-
{examples.map(({ title, placement, alignment,
|
|
128
|
-
const
|
|
129
|
-
if (!isTipHidden) ref.current?.focus();
|
|
130
|
-
};
|
|
131
|
-
|
|
170
|
+
{examples.map(({ title, placement, alignment, links }) => {
|
|
171
|
+
const labelId = `keyboard-nav-${placement}`;
|
|
132
172
|
return (
|
|
133
173
|
<FlexBox gap={8} key={placement}>
|
|
134
|
-
<Text fontSize={16} fontWeight="bold">
|
|
174
|
+
<Text fontSize={16} fontWeight="bold" id={labelId}>
|
|
135
175
|
{title}
|
|
136
176
|
</Text>
|
|
137
177
|
<InfoTip
|
|
138
178
|
alignment={alignment}
|
|
179
|
+
ariaLabelledby={labelId}
|
|
139
180
|
info={
|
|
140
|
-
<Text
|
|
181
|
+
<Text>
|
|
141
182
|
{links.map((label, idx) => (
|
|
142
183
|
<>
|
|
143
184
|
{idx > 0 && ', '}
|
|
@@ -150,7 +191,6 @@ export const KeyboardNavigation: Story = {
|
|
|
150
191
|
</Text>
|
|
151
192
|
}
|
|
152
193
|
placement={placement}
|
|
153
|
-
onClick={onClick}
|
|
154
194
|
/>
|
|
155
195
|
</FlexBox>
|
|
156
196
|
);
|
|
@@ -162,6 +202,10 @@ export const KeyboardNavigation: Story = {
|
|
|
162
202
|
Keyboard Navigation:
|
|
163
203
|
</Text>
|
|
164
204
|
<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>
|
|
165
209
|
<li>
|
|
166
210
|
<strong>Floating - Tab:</strong> Navigates forward through links,
|
|
167
211
|
then wraps to button (contained)
|
|
@@ -224,8 +268,10 @@ export const InfoTipInsideModal: Story = {
|
|
|
224
268
|
<Text>This modal contains an InfoTip below:</Text>
|
|
225
269
|
|
|
226
270
|
<FlexBox alignItems="center" gap={8}>
|
|
227
|
-
<Text
|
|
228
|
-
|
|
271
|
+
<Text id="modal-infotip-text">
|
|
272
|
+
Some text that needs explanation
|
|
273
|
+
</Text>
|
|
274
|
+
<InfoTip {...args} ariaLabelledby="modal-infotip-text" />
|
|
229
275
|
</FlexBox>
|
|
230
276
|
|
|
231
277
|
<Text color="text-disabled" fontSize={14}>
|
|
@@ -253,11 +299,14 @@ export const ZIndex: Story = {
|
|
|
253
299
|
<Box bg="paleBlue" zIndex={3}>
|
|
254
300
|
I will not be behind the infotip, sad + unreadable
|
|
255
301
|
</Box>
|
|
256
|
-
<InfoTip
|
|
302
|
+
<InfoTip
|
|
303
|
+
ariaLabel="z-index example without override"
|
|
304
|
+
info="I am inline, cool"
|
|
305
|
+
/>
|
|
257
306
|
<Box bg="paleBlue" zIndex={3}>
|
|
258
307
|
I will be behind the infotip, nice + great
|
|
259
308
|
</Box>
|
|
260
|
-
<InfoTip {...args} />
|
|
309
|
+
<InfoTip {...args} ariaLabel="z-index example with override" />
|
|
261
310
|
</FlexBox>
|
|
262
311
|
),
|
|
263
312
|
};
|
|
@@ -265,7 +314,10 @@ export const ZIndex: Story = {
|
|
|
265
314
|
export const Default: Story = {
|
|
266
315
|
render: (args) => (
|
|
267
316
|
<FlexBox center m={24} py={64}>
|
|
268
|
-
<Text mr={4}>
|
|
317
|
+
<Text id="default-text" mr={4}>
|
|
318
|
+
Some text that needs info
|
|
319
|
+
</Text>
|
|
320
|
+
<InfoTip {...args} ariaLabelledby="default-text" />
|
|
269
321
|
</FlexBox>
|
|
270
322
|
),
|
|
271
323
|
};
|
|
@@ -61,6 +61,25 @@ 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), the InfoTip is automatically labelled by the field label. You can override this behavior by providing:
|
|
77
|
+
|
|
78
|
+
- `ariaLabel` - provide a custom accessible name
|
|
79
|
+
- `ariaLabelledby` - reference another element on the page, such as a section heading
|
|
80
|
+
|
|
81
|
+
<Canvas of={ConnectedFormGroupStories.InfoTipWithReactNodeLabel} />
|
|
82
|
+
|
|
64
83
|
## Playground
|
|
65
84
|
|
|
66
85
|
To see how a `ConnectedFormGroup` can be used in a `ConnectedForm`, check out the <LinkTo id="Organisms/ConnectedForm/ConnectedForm">ConnectedForm</LinkTo> page.
|
|
@@ -2,7 +2,9 @@ import {
|
|
|
2
2
|
ConnectedForm,
|
|
3
3
|
ConnectedFormGroup,
|
|
4
4
|
ConnectedFormGroupProps,
|
|
5
|
+
ConnectedInput,
|
|
5
6
|
ConnectedRadioGroupInput,
|
|
7
|
+
Text,
|
|
6
8
|
useConnectedForm,
|
|
7
9
|
} from '@codecademy/gamut';
|
|
8
10
|
import { action } from '@storybook/addon-actions';
|
|
@@ -119,3 +121,74 @@ export const States = () => {
|
|
|
119
121
|
</ConnectedForm>
|
|
120
122
|
);
|
|
121
123
|
};
|
|
124
|
+
|
|
125
|
+
export const InfoTipAutoLabelling: Story = {
|
|
126
|
+
render: () => (
|
|
127
|
+
<ConnectedForm
|
|
128
|
+
defaultValues={{ email: '' }}
|
|
129
|
+
onSubmit={(values) => action('Form Submitted')(values)}
|
|
130
|
+
>
|
|
131
|
+
<ConnectedFormGroup
|
|
132
|
+
field={{ component: ConnectedInput, type: 'email' }}
|
|
133
|
+
infotip={{
|
|
134
|
+
info: 'We will never share your email with third parties.',
|
|
135
|
+
placement: 'floating',
|
|
136
|
+
}}
|
|
137
|
+
label="Email address"
|
|
138
|
+
name="email"
|
|
139
|
+
/>
|
|
140
|
+
</ConnectedForm>
|
|
141
|
+
),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const InfoTipWithReactNodeLabel: Story = {
|
|
145
|
+
render: () => (
|
|
146
|
+
<ConnectedForm
|
|
147
|
+
defaultValues={{ username: '', password: '', apiKey: '' }}
|
|
148
|
+
onSubmit={(values) => action('Form Submitted')(values)}
|
|
149
|
+
>
|
|
150
|
+
<Text as="h3" id="api-section-heading" mb={8}>
|
|
151
|
+
API Configuration
|
|
152
|
+
</Text>
|
|
153
|
+
<ConnectedFormGroup
|
|
154
|
+
field={{ component: ConnectedInput }}
|
|
155
|
+
infotip={{
|
|
156
|
+
alignment: 'bottom-left',
|
|
157
|
+
info: 'Choose a unique username between 3-20 characters.',
|
|
158
|
+
}}
|
|
159
|
+
label={
|
|
160
|
+
<Text as="span" fontWeight="bold">
|
|
161
|
+
Username (automatic label)
|
|
162
|
+
</Text>
|
|
163
|
+
}
|
|
164
|
+
name="username"
|
|
165
|
+
/>
|
|
166
|
+
<ConnectedFormGroup
|
|
167
|
+
field={{ component: ConnectedInput, type: 'password' }}
|
|
168
|
+
infotip={{
|
|
169
|
+
info: 'Password must be at least 8 characters with one uppercase letter and one number.',
|
|
170
|
+
ariaLabel: 'Password requirements',
|
|
171
|
+
}}
|
|
172
|
+
label={
|
|
173
|
+
<Text as="span" fontWeight="bold">
|
|
174
|
+
Password (ariaLabel)
|
|
175
|
+
</Text>
|
|
176
|
+
}
|
|
177
|
+
name="password"
|
|
178
|
+
/>
|
|
179
|
+
<ConnectedFormGroup
|
|
180
|
+
field={{ component: ConnectedInput }}
|
|
181
|
+
infotip={{
|
|
182
|
+
info: 'You can find your API key in the developer settings dashboard.',
|
|
183
|
+
ariaLabelledby: 'api-section-heading',
|
|
184
|
+
}}
|
|
185
|
+
label={
|
|
186
|
+
<Text as="span" fontWeight="bold">
|
|
187
|
+
API Key (ariaLabelledby)
|
|
188
|
+
</Text>
|
|
189
|
+
}
|
|
190
|
+
name="apiKey"
|
|
191
|
+
/>
|
|
192
|
+
</ConnectedForm>
|
|
193
|
+
),
|
|
194
|
+
};
|
|
@@ -95,3 +95,22 @@ 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, the InfoTip is automatically labelled by the field label. You can override this behavior by providing:
|
|
112
|
+
|
|
113
|
+
- `ariaLabel` - provide a custom accessible name
|
|
114
|
+
- `ariaLabelledby` - reference another element on the page, such as a section heading
|
|
115
|
+
|
|
116
|
+
<Canvas of={FieldsStories.InfoTipWithReactNodeLabel} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormGroup, GridForm, Input } from '@codecademy/gamut';
|
|
1
|
+
import { FormGroup, GridForm, Input, Text } from '@codecademy/gamut';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
4
|
|
|
@@ -328,3 +328,64 @@ export const SweetContainer: Story = {
|
|
|
328
328
|
],
|
|
329
329
|
},
|
|
330
330
|
};
|
|
331
|
+
|
|
332
|
+
export const InfoTipAutoLabelling: Story = {
|
|
333
|
+
args: {
|
|
334
|
+
fields: [
|
|
335
|
+
{
|
|
336
|
+
label: 'Email address',
|
|
337
|
+
name: 'email',
|
|
338
|
+
size: 9,
|
|
339
|
+
type: 'email',
|
|
340
|
+
infotip: {
|
|
341
|
+
info: 'We will never share your email with third parties.',
|
|
342
|
+
placement: 'floating',
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export const InfoTipWithReactNodeLabel: Story = {
|
|
350
|
+
render: (args) => (
|
|
351
|
+
<>
|
|
352
|
+
<Text as="h3" id="api-section-heading" mb={8}>
|
|
353
|
+
API Configuration
|
|
354
|
+
</Text>
|
|
355
|
+
<GridForm {...args} />
|
|
356
|
+
</>
|
|
357
|
+
),
|
|
358
|
+
args: {
|
|
359
|
+
fields: [
|
|
360
|
+
{
|
|
361
|
+
label: <strong>Username (automatic label)</strong>,
|
|
362
|
+
name: 'username',
|
|
363
|
+
size: 9,
|
|
364
|
+
type: 'text',
|
|
365
|
+
infotip: {
|
|
366
|
+
info: 'Choose a unique username between 3-20 characters.',
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: <strong>Password (ariaLabel)</strong>,
|
|
371
|
+
name: 'password',
|
|
372
|
+
size: 9,
|
|
373
|
+
type: 'password',
|
|
374
|
+
infotip: {
|
|
375
|
+
info: 'Password must be at least 8 characters with one uppercase letter and one number.',
|
|
376
|
+
ariaLabel: 'Password requirements',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
label: <strong>API Key (ariaLabelledby)</strong>,
|
|
381
|
+
name: 'apiKey',
|
|
382
|
+
size: 9,
|
|
383
|
+
type: 'text',
|
|
384
|
+
infotip: {
|
|
385
|
+
info: 'You can find your API key in the developer settings dashboard.',
|
|
386
|
+
ariaLabelledby: 'api-section-heading',
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
],
|
|
390
|
+
},
|
|
391
|
+
};
|
|
@@ -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">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">Fields</LinkTo> story for specific accessibility tooling and <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
|
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AboutHeader,
|
|
5
|
-
addParentPath,
|
|
6
|
-
TableOfContents,
|
|
7
|
-
} from '~styleguide/blocks';
|
|
8
|
-
|
|
9
|
-
import { parameters as backgroundParameters } from './Background.mdx';
|
|
10
|
-
import { parameters as borderParameters } from './Border.mdx';
|
|
11
|
-
import { parameters as colorParameters } from './Color.mdx';
|
|
12
|
-
import { parameters as flexParameters } from './Flex.mdx';
|
|
13
|
-
import { parameters as gridParameters } from './Grid.mdx';
|
|
14
|
-
import { parameters as layoutParameters } from './Layout.mdx';
|
|
15
|
-
import { parameters as listParameters } from './List.mdx';
|
|
16
|
-
import { parameters as positioningParameters } from './Positioning.mdx';
|
|
17
|
-
import { parameters as shadowParameters } from './Shadow.mdx';
|
|
18
|
-
import { parameters as spaceParameters } from './Space.mdx';
|
|
19
|
-
import { parameters as typographyParameters } from './Typography.mdx';
|
|
20
|
-
|
|
21
|
-
export const parameters = {
|
|
22
|
-
id: 'Foundations/System/Props',
|
|
23
|
-
title: 'Props',
|
|
24
|
-
subtitle:
|
|
25
|
-
'Reusable CSS-in-JS props with predictable behaviors and a consistent API for responsive CSS.',
|
|
26
|
-
status: 'current',
|
|
27
|
-
source: {
|
|
28
|
-
repo: 'gamut-styles',
|
|
29
|
-
githubLink:
|
|
30
|
-
'https://github.com/Codecademy/gamut/blob/main/packages/gamut-styles/src/variance/config.ts',
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
<Meta title="Foundations/System/Props/About" />
|
|
35
|
-
|
|
36
|
-
<AboutHeader {...parameters} />
|
|
37
|
-
|
|
38
|
-
We provide a set of out of style functions out of the box through `@codecademy/gamut-styles` that are standardized throughout all of our components. These props are strongly typed and can be included as necessary on any styled component.
|
|
39
|
-
|
|
40
|
-
System props have a few facets that are important to note:
|
|
41
|
-
|
|
42
|
-
- They can some times represent multiple properties.
|
|
43
|
-
- They may be restricted to specific token scales but will always have access to global css values like `initial` and `none`.
|
|
44
|
-
- They may have a function that transforms the given value into a standardized value (e.g. `width={.5}` => `width: 50%`)
|
|
45
|
-
|
|
46
|
-
We've grouped these into a few main groups that affect simliar behaviors: `layout`, `space`, `color`, `border`, `background`, `typography`, `positioning`, `grid`, `flex`, `shadow`.
|
|
47
|
-
|
|
48
|
-
You may import these groups directly from `gamut-styles`.
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
import { variance } from '@codecademy/variance';
|
|
52
|
-
import { system } from '@codecademy/gamut-styles';
|
|
53
|
-
|
|
54
|
-
const ExampleContainer = styled.div(
|
|
55
|
-
variance.compose(system.layout, system.positioning)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
<ExampleContainer position="absolute" width="50px" height="50px" />;
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Each system prop has 3 important features:
|
|
62
|
-
|
|
63
|
-
- `properties`: Any number of CSS Properties this prop is responsible for.
|
|
64
|
-
- `scale`: A set of values that determines valid inputs for each prop based on the selected theme and that theme's typing (e.g. if the `lxStudio` theme is being used, a scale of `colors` will restrict to the `lxStudio` theme's colors). These are generally aliases for more verbose or opaque CSS properties allowing you to specify a human readable name in your props. If a prop doesn't have a scale that means it accepts all valid `CSSType` values as props, however if it does have a scale it will only accept global values and keys of the provided scale.
|
|
65
|
-
- `transform`: A function that changes the prop / scale value prior to adding it to the stylehseet. This allows us to add / change units for properties like `width` and `height`. Or ensure extra defaults or fallbacks are added dynamically.
|
|
66
|
-
|
|
67
|
-
<TableOfContents
|
|
68
|
-
links={addParentPath(parameters.id, [
|
|
69
|
-
layoutParameters,
|
|
70
|
-
spaceParameters,
|
|
71
|
-
typographyParameters,
|
|
72
|
-
colorParameters,
|
|
73
|
-
borderParameters,
|
|
74
|
-
flexParameters,
|
|
75
|
-
gridParameters,
|
|
76
|
-
backgroundParameters,
|
|
77
|
-
positioningParameters,
|
|
78
|
-
shadowParameters,
|
|
79
|
-
listParameters,
|
|
80
|
-
])}
|
|
81
|
-
/>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import { AboutHeader, TokenTable } from '~styleguide/blocks';
|
|
4
|
-
|
|
5
|
-
import { defaultColumns, getPropRows } from '../../shared/elements';
|
|
6
|
-
|
|
7
|
-
export const parameters = {
|
|
8
|
-
title: 'Background',
|
|
9
|
-
subtitle:
|
|
10
|
-
'Props for background manipulation (sizing / repitition / images), for background color see `colors`.',
|
|
11
|
-
status: 'current',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
<Meta title="Foundations/System/Props/Background" />
|
|
15
|
-
|
|
16
|
-
<AboutHeader {...parameters} />
|
|
17
|
-
|
|
18
|
-
Background props control how background images and patterns are displayed on elements. These properties give you control over image sizing, positioning, and repetition behavior. For solid background colors, use the color props which connect to the theme's color palette.
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
import styled from '@emotion/styled';
|
|
22
|
-
import { system } from '@codecademy/gamut-styles';
|
|
23
|
-
import myBg from './myBg.png';
|
|
24
|
-
|
|
25
|
-
const BackgroundExample = styled.div(system.background);
|
|
26
|
-
|
|
27
|
-
<BackgroundExample background={`url(${myBg}`} backgroundSize="cover" />;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
<TokenTable rows={getPropRows('background')} columns={defaultColumns} />
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import { AboutHeader, TokenTable } from '~styleguide/blocks';
|
|
4
|
-
|
|
5
|
-
import { defaultColumns, getPropRows } from '../../shared/elements';
|
|
6
|
-
|
|
7
|
-
export const parameters = {
|
|
8
|
-
title: 'Border',
|
|
9
|
-
subtitle: 'Border styles',
|
|
10
|
-
status: 'updating',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
<Meta title="Foundations/System/Props/Border" />
|
|
14
|
-
|
|
15
|
-
<AboutHeader {...parameters} />
|
|
16
|
-
|
|
17
|
-
Border props enable you to add and style borders on any side of an element. These properties support directional borders (top, right, bottom, left) as well as convenient shorthands for horizontal and vertical borders. Border radius values connect to the theme's `borderRadii` scale for consistent corner rounding.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import styled from '@emotion/styled';
|
|
21
|
-
import { system } from '@codecademy/gamut-styles';
|
|
22
|
-
|
|
23
|
-
const BorderExample = styled.div(system.border);
|
|
24
|
-
|
|
25
|
-
<BorderExample
|
|
26
|
-
border={1}
|
|
27
|
-
borderLeft="none"
|
|
28
|
-
borderRightStyle="dotted"
|
|
29
|
-
borderRadius="md"
|
|
30
|
-
/>;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
<TokenTable rows={getPropRows('border')} columns={defaultColumns} />
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import { AboutHeader, TokenTable } from '~styleguide/blocks';
|
|
4
|
-
|
|
5
|
-
import { defaultColumns, getPropRows } from '../../shared/elements';
|
|
6
|
-
|
|
7
|
-
export const parameters = {
|
|
8
|
-
title: 'Color',
|
|
9
|
-
subtitle: 'Specific color properties',
|
|
10
|
-
status: 'current',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
<Meta title="Foundations/System/Props/Color" />
|
|
14
|
-
|
|
15
|
-
<AboutHeader {...parameters} />
|
|
16
|
-
|
|
17
|
-
Color props control the foreground, background, and border colors of elements. All color values are restricted to your theme's color palette, ensuring consistent color usage throughout your application. The `bg` shorthand provides a convenient way to set background colors quickly.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import styled from '@emotion/styled';
|
|
21
|
-
import { system } from '@codecademy/gamut-styles';
|
|
22
|
-
|
|
23
|
-
const ColorExample = styled.div(system.color);
|
|
24
|
-
|
|
25
|
-
<ColorExample bg="navy" textColor="gray-100" borderColor="blue" />;
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
<TokenTable rows={getPropRows('color')} columns={defaultColumns} />
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import { AboutHeader, TokenTable } from '~styleguide/blocks';
|
|
4
|
-
|
|
5
|
-
import { defaultColumns, getPropRows } from '../../shared/elements';
|
|
6
|
-
|
|
7
|
-
export const parameters = {
|
|
8
|
-
title: 'Flex',
|
|
9
|
-
subtitle: 'Flex specific properties',
|
|
10
|
-
status: 'current',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
<Meta title="Foundations/System/Props/Flex" />
|
|
14
|
-
|
|
15
|
-
<AboutHeader {...parameters} />
|
|
16
|
-
|
|
17
|
-
Flex props provide complete control over flexbox layouts, from container behavior to individual flex item properties. These properties make it easy to create flexible, responsive layouts with proper alignment and distribution of child elements. Use these on flex containers to control their children or on flex items to control their own behavior.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import styled from '@emotion/styled';
|
|
21
|
-
import { system } from '@codecademy/gamut-styles';
|
|
22
|
-
|
|
23
|
-
const FlexExample = styled.div(system.flex);
|
|
24
|
-
|
|
25
|
-
<FlexExample flex={1} justifyContent="center" alignItems="flex-start" />;
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
<TokenTable rows={getPropRows('flex')} columns={defaultColumns} />
|