@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
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.6-alpha.
|
|
6
|
+
### [78.5.6-alpha.eca584.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@78.5.5...@codecademy/styleguide@78.5.6-alpha.eca584.0) (2026-01-29)
|
|
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.6-alpha.
|
|
4
|
+
"version": "78.5.6-alpha.eca584.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": "09ec5bd6b3912d8b428472324f7a20de81b0f263"
|
|
12
12
|
}
|
|
@@ -69,6 +69,12 @@ 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 - you can override this behaviour if needed by passing `ariaLabel` or `ariaLabelledBy` to the field's `InfoTip` via the `infoTipProps` object.
|
|
75
|
+
|
|
76
|
+
<Canvas of={FormGroupStories.InfoTipAutoLabelling} />
|
|
77
|
+
|
|
72
78
|
## Playground
|
|
73
79
|
|
|
74
80
|
<Canvas sourceState="shown" of={FormGroupStories.Default} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormGroup, Input } from '@codecademy/gamut';
|
|
1
|
+
import { Box, FormGroup, Input } from '@codecademy/gamut';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import type { TypeWithDeepControls } from 'storybook-addon-deep-controls';
|
|
4
4
|
|
|
@@ -6,9 +6,7 @@ import { infotipNestedArgTypes } from '~styleguide/argTypes';
|
|
|
6
6
|
|
|
7
7
|
const meta: TypeWithDeepControls<Meta<typeof FormGroup>> = {
|
|
8
8
|
component: FormGroup,
|
|
9
|
-
argTypes: {
|
|
10
|
-
...infotipNestedArgTypes,
|
|
11
|
-
},
|
|
9
|
+
argTypes: { ...infotipNestedArgTypes },
|
|
12
10
|
};
|
|
13
11
|
|
|
14
12
|
export default meta;
|
|
@@ -97,3 +95,46 @@ export const HighEmphasisInfoTip: Story = {
|
|
|
97
95
|
children: <Input />,
|
|
98
96
|
},
|
|
99
97
|
};
|
|
98
|
+
|
|
99
|
+
const InfoTipLabellingExamples = () => {
|
|
100
|
+
return (
|
|
101
|
+
<Box display="flex" flexDirection="column" gap={32}>
|
|
102
|
+
<FormGroup
|
|
103
|
+
htmlFor="auto-label-input"
|
|
104
|
+
infotip={{
|
|
105
|
+
info: 'We will never share your email with third parties.',
|
|
106
|
+
}}
|
|
107
|
+
label="Auto-labelling (default)"
|
|
108
|
+
>
|
|
109
|
+
<Input htmlFor="auto-label-input" type="email" />
|
|
110
|
+
</FormGroup>
|
|
111
|
+
|
|
112
|
+
<FormGroup
|
|
113
|
+
htmlFor="aria-label-input"
|
|
114
|
+
infotip={{
|
|
115
|
+
ariaLabel: 'Email privacy information',
|
|
116
|
+
info: 'We will never share your email with third parties.',
|
|
117
|
+
}}
|
|
118
|
+
label="With ariaLabel"
|
|
119
|
+
>
|
|
120
|
+
<Input htmlFor="aria-label-input" type="email" />
|
|
121
|
+
</FormGroup>
|
|
122
|
+
|
|
123
|
+
<FormGroup
|
|
124
|
+
htmlFor="aria-labelledby-input"
|
|
125
|
+
infotip={{
|
|
126
|
+
ariaLabelledby: 'custom-label-id',
|
|
127
|
+
info: 'We will never share your email with third parties.',
|
|
128
|
+
}}
|
|
129
|
+
label="With ariaLabelledBy"
|
|
130
|
+
>
|
|
131
|
+
<span id="custom-label-id">Custom label for InfoTip button</span>
|
|
132
|
+
<Input htmlFor="aria-labelledby-input" type="email" />
|
|
133
|
+
</FormGroup>
|
|
134
|
+
</Box>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const InfoTipAutoLabelling: Story = {
|
|
139
|
+
render: () => <InfoTipLabellingExamples />,
|
|
140
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, Controls, Meta } from '@storybook/blocks';
|
|
2
2
|
|
|
3
|
-
import { ComponentHeader } from '~styleguide/blocks';
|
|
3
|
+
import { ComponentHeader, LinkTo } from '~styleguide/blocks';
|
|
4
4
|
|
|
5
5
|
import * as CheckboxStories from './Checkbox.stories';
|
|
6
6
|
|
|
@@ -133,6 +133,12 @@ To ensure our `Checkboxes` are accessible, we require an `aria-label` be added i
|
|
|
133
133
|
|
|
134
134
|
<Canvas of={CheckboxStories.LabelsAsReactNodes} />
|
|
135
135
|
|
|
136
|
+
## InfoTip
|
|
137
|
+
|
|
138
|
+
You can add an <LinkTo id="Molecules/Tips/InfoTip">`InfoTip`</LinkTo> to a Checkbox by passing the `infotip` prop. The InfoTip button is automatically labeled by the checkbox label for accessibility. To override this behavior, provide `ariaLabel` or `ariaLabelledby` in the infotip props.
|
|
139
|
+
|
|
140
|
+
<Canvas of={CheckboxStories.InfoTip} />
|
|
141
|
+
|
|
136
142
|
## Playground
|
|
137
143
|
|
|
138
144
|
<Canvas sourceState="shown" of={CheckboxStories.Default} />
|
|
@@ -12,8 +12,11 @@ import { MiniStarIcon } from '@codecademy/gamut-icons';
|
|
|
12
12
|
import { Background } from '@codecademy/gamut-styles';
|
|
13
13
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
14
14
|
import { useState } from 'react';
|
|
15
|
+
import type { TypeWithDeepControls } from 'storybook-addon-deep-controls';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
import { infotipNestedArgTypes } from '~styleguide/argTypes';
|
|
18
|
+
|
|
19
|
+
const meta: TypeWithDeepControls<Meta<typeof Checkbox>> = {
|
|
17
20
|
component: Checkbox,
|
|
18
21
|
args: {
|
|
19
22
|
htmlFor: 'example-checkbox',
|
|
@@ -23,6 +26,9 @@ const meta: Meta<typeof Checkbox> = {
|
|
|
23
26
|
readOnly: true,
|
|
24
27
|
onChange: () => {},
|
|
25
28
|
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
...infotipNestedArgTypes,
|
|
31
|
+
},
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
export default meta;
|
|
@@ -166,6 +172,20 @@ export const LabelsAsReactNodes: Story = {
|
|
|
166
172
|
),
|
|
167
173
|
};
|
|
168
174
|
|
|
175
|
+
export const InfoTip: Story = {
|
|
176
|
+
args: {
|
|
177
|
+
htmlFor: 'example-infotip',
|
|
178
|
+
label: 'Checkbox with InfoTip',
|
|
179
|
+
name: 'example-infotip',
|
|
180
|
+
infotip: {
|
|
181
|
+
emphasis: 'high',
|
|
182
|
+
info: 'This is an infotip that provides additional information about the checkbox.',
|
|
183
|
+
placement: 'floating',
|
|
184
|
+
},
|
|
185
|
+
checked: false,
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
169
189
|
type CustomCheckboxProps = Omit<
|
|
170
190
|
CheckboxProps,
|
|
171
191
|
'checked' | 'indeterminate' | 'label'
|
|
@@ -58,6 +58,14 @@ The `label` is a `ReactNode`, making it customizable outside of a standard text
|
|
|
58
58
|
|
|
59
59
|
<Canvas of={RadioStories.CustomLabel} />
|
|
60
60
|
|
|
61
|
+
## RadioGroup with InfoTip
|
|
62
|
+
|
|
63
|
+
You can add an InfoTip to a RadioGroup label by wrapping the `RadioGroup` with a `FormGroup` and passing the `infotip` prop. The InfoTip will be automatically linked to the RadioGroup label via `aria-labelledby` for accessibility.
|
|
64
|
+
|
|
65
|
+
Individual Radio options can also have their own InfoTips, which are automatically linked to their respective labels.
|
|
66
|
+
|
|
67
|
+
<Canvas of={RadioStories.RadioGroupWithInfoTips} />
|
|
68
|
+
|
|
61
69
|
## Playground
|
|
62
70
|
|
|
63
71
|
<Canvas sourceState="shown" of={RadioStories.Default} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Radio, RadioGroup } from '@codecademy/gamut';
|
|
1
|
+
import { FormGroup, Radio, RadioGroup } from '@codecademy/gamut';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import type { TypeWithDeepControls } from 'storybook-addon-deep-controls';
|
|
4
4
|
|
|
@@ -25,13 +25,47 @@ export const Default: Story = {
|
|
|
25
25
|
|
|
26
26
|
export const RadioGroupComponent: Story = {
|
|
27
27
|
render: () => (
|
|
28
|
-
<RadioGroup htmlForPrefix="example-radio">
|
|
29
|
-
<Radio
|
|
30
|
-
<Radio
|
|
28
|
+
<RadioGroup htmlForPrefix="example-radio" name="example-radio">
|
|
29
|
+
<Radio label="Radio 1" />
|
|
30
|
+
<Radio label="Radio 2" />
|
|
31
31
|
</RadioGroup>
|
|
32
32
|
),
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
export const RadioGroupWithInfoTips: Story = {
|
|
36
|
+
render: () => (
|
|
37
|
+
<FormGroup
|
|
38
|
+
htmlFor="example-radio-infotip"
|
|
39
|
+
infotip={{
|
|
40
|
+
info: 'This InfoTip is linked to the RadioGroup label. Individual options can also have their own InfoTips.',
|
|
41
|
+
placement: 'floating',
|
|
42
|
+
}}
|
|
43
|
+
label="Select an option"
|
|
44
|
+
width="fit-content"
|
|
45
|
+
>
|
|
46
|
+
<RadioGroup
|
|
47
|
+
htmlForPrefix="example-radio-infotip"
|
|
48
|
+
name="example-radio-infotip"
|
|
49
|
+
>
|
|
50
|
+
<Radio
|
|
51
|
+
infotip={{
|
|
52
|
+
info: 'This option includes additional information about the choice.',
|
|
53
|
+
placement: 'floating',
|
|
54
|
+
}}
|
|
55
|
+
label="Option with InfoTip"
|
|
56
|
+
/>
|
|
57
|
+
<Radio
|
|
58
|
+
infotip={{
|
|
59
|
+
info: 'Each radio option can have its own InfoTip for context.',
|
|
60
|
+
}}
|
|
61
|
+
label="Another option"
|
|
62
|
+
/>
|
|
63
|
+
<Radio label="Option without InfoTip" />
|
|
64
|
+
</RadioGroup>
|
|
65
|
+
</FormGroup>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
35
69
|
export const Checked: Story = {
|
|
36
70
|
args: {
|
|
37
71
|
htmlFor: 'example-checked',
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '~styleguide/blocks';
|
|
8
8
|
|
|
9
9
|
import { parameters as composeParameters } from './Compose.mdx';
|
|
10
|
-
import { parameters as propsParameters } from './Props
|
|
10
|
+
import { parameters as propsParameters } from './Props.mdx';
|
|
11
11
|
import { parameters as responsivePropertiesParameters } from './ResponsiveProperties/ResponsiveProperties.mdx';
|
|
12
12
|
import { parameters as variantsParameters } from './Variants.mdx';
|
|
13
13
|
|
|
@@ -0,0 +1,230 @@
|
|
|
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: 'Props',
|
|
9
|
+
subtitle:
|
|
10
|
+
'Reusable CSS-in-JS props with predictable behaviors and a consistent API for responsive CSS.',
|
|
11
|
+
source: {
|
|
12
|
+
repo: 'gamut-styles',
|
|
13
|
+
githubLink:
|
|
14
|
+
'https://github.com/Codecademy/gamut/blob/af5be6e39cccca5d5d8a1f811c77a7a0b618c914/packages/gamut-styles/src/variance/config.ts#L11',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
<Meta title="Foundations/System/Props" />
|
|
19
|
+
|
|
20
|
+
<AboutHeader {...parameters} />
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
System props have a few facets that are important to note:
|
|
25
|
+
|
|
26
|
+
- They can some times represent multiple properties.
|
|
27
|
+
- They may be restricted to specific token scales but will always have access to global css values like `initial` and `none`.
|
|
28
|
+
- They may have a function that transforms the given value into a standardized value (e.g. `width={.5}` => `width: 50%`)
|
|
29
|
+
|
|
30
|
+
We've grouped these into a few main groups that affect simliar behaviors: `layout`, `space`, `color`, `border`, `background`, `typography`, `positioning`, `grid`, `flex`, `shadow`.
|
|
31
|
+
|
|
32
|
+
You may import these groups directly from `gamut-styles`.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { variance } from '@codecademy/variance';
|
|
36
|
+
import { system } from '@codecademy/gamut-styles';
|
|
37
|
+
|
|
38
|
+
const Box = styled.div(variance.compose(system.layout, system.positioning));
|
|
39
|
+
|
|
40
|
+
<Box position="absolute" width="50px" height="50px" />;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Each system prop has 3 important features:
|
|
44
|
+
|
|
45
|
+
- `properties`: Any number of CSS Properties this prop is responsible for.
|
|
46
|
+
- `scale`: A set of values that determines valid inputs for each prop (e.g. a scale of `colors` will restrict to only theme 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.
|
|
47
|
+
- `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.
|
|
48
|
+
|
|
49
|
+
<br />
|
|
50
|
+
|
|
51
|
+
## Layout
|
|
52
|
+
|
|
53
|
+
Props for handling dimensions and other layout specific properties.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import styled from '@emotion/styled';
|
|
57
|
+
import { system } from '@codecademy/gamut-styles';
|
|
58
|
+
|
|
59
|
+
const Box = styled.div(system.layout);
|
|
60
|
+
|
|
61
|
+
<Box display="flex" width="50%" height="300px" verticalAlign="middle" />;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
<TokenTable rows={getPropRows('layout')} columns={defaultColumns} />
|
|
65
|
+
|
|
66
|
+
## Space
|
|
67
|
+
|
|
68
|
+
Props for maintaining specific vertical and horizontal rhythms
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import styled from '@emotion/styled';
|
|
72
|
+
import { system } from '@codecademy/gamut-styles';
|
|
73
|
+
|
|
74
|
+
const Spacer = styled.div(system.space);
|
|
75
|
+
|
|
76
|
+
<Spacer p={8} my={[16, 24, 32]} />;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<TokenTable rows={getPropRows('space')} columns={defaultColumns} />
|
|
80
|
+
|
|
81
|
+
## Typography
|
|
82
|
+
|
|
83
|
+
Props for text manipulation
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import styled from '@emotion/styled';
|
|
87
|
+
import { system } from '@codecademy/gamut-styles';
|
|
88
|
+
|
|
89
|
+
const Text = styled.p(system.typography);
|
|
90
|
+
|
|
91
|
+
<Text fontSize={16} fontFamily="accent" textTransform="uppercase" />;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<TokenTable rows={getPropRows('typography')} columns={defaultColumns} />
|
|
95
|
+
|
|
96
|
+
## Color
|
|
97
|
+
|
|
98
|
+
Specific color properties
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import styled from '@emotion/styled';
|
|
102
|
+
import { system } from '@codecademy/gamut-styles';
|
|
103
|
+
|
|
104
|
+
const Background = styled.div(system.color);
|
|
105
|
+
|
|
106
|
+
<Background bg="navy" textColor="gray-100" borderColor="blue" />;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<TokenTable rows={getPropRows('color')} columns={defaultColumns} />
|
|
110
|
+
|
|
111
|
+
## Border
|
|
112
|
+
|
|
113
|
+
Border styles
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import styled from '@emotion/styled';
|
|
117
|
+
import { system } from '@codecademy/gamut-styles';
|
|
118
|
+
|
|
119
|
+
const Box = styled.div(system.border);
|
|
120
|
+
|
|
121
|
+
<Box
|
|
122
|
+
border={1}
|
|
123
|
+
borderLeft="none"
|
|
124
|
+
borderRightStyle="dotted"
|
|
125
|
+
borderRadius="md"
|
|
126
|
+
/>;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
<TokenTable rows={getPropRows('border')} columns={defaultColumns} />
|
|
130
|
+
|
|
131
|
+
## Flex
|
|
132
|
+
|
|
133
|
+
Flex specific properties
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import styled from '@emotion/styled';
|
|
137
|
+
import { system } from '@codecademy/gamut-styles';
|
|
138
|
+
|
|
139
|
+
const FlexBox = styled.div(system.flex);
|
|
140
|
+
|
|
141
|
+
<FlexBox flex={1} justifyContent="center" alignItems="flex-start" />;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
<TokenTable rows={getPropRows('flex')} columns={defaultColumns} />
|
|
145
|
+
|
|
146
|
+
## Grid
|
|
147
|
+
|
|
148
|
+
Grid specific properties
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import styled from '@emotion/styled';
|
|
152
|
+
import { system } from '@codecademy/gamut-styles';
|
|
153
|
+
|
|
154
|
+
const GridBox = styled.div(system.grid);
|
|
155
|
+
|
|
156
|
+
<GridBox gridTemplateColumns="max-content 1fr max-content" columnGap={32} />;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
<TokenTable rows={getPropRows('grid')} columns={defaultColumns} />
|
|
160
|
+
|
|
161
|
+
## Background
|
|
162
|
+
|
|
163
|
+
Props for background manipulation (sizing / repitition / images), for background color see `colors`.
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import styled from '@emotion/styled';
|
|
167
|
+
import { system } from '@codecademy/gamut-styles';
|
|
168
|
+
import myBg from './myBg.png';
|
|
169
|
+
|
|
170
|
+
const Box = styled.div(system.background);
|
|
171
|
+
|
|
172
|
+
<Box background={`url(${myBg}`} backgroundSize="cover" />;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
<TokenTable rows={getPropRows('background')} columns={defaultColumns} />
|
|
176
|
+
|
|
177
|
+
## Positioning
|
|
178
|
+
|
|
179
|
+
Props that affect stacking and position contexts. Like `top`, `position` and `opacity`.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import styled from '@emotion/styled';
|
|
183
|
+
import { system } from '@codecademy/gamut-styles';
|
|
184
|
+
|
|
185
|
+
const Box = styled.div(system.positioning);
|
|
186
|
+
|
|
187
|
+
<Box position="absolute" zIndex={2} top="0" left="0" />;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
<TokenTable rows={getPropRows('positioning')} columns={defaultColumns} />
|
|
191
|
+
|
|
192
|
+
## Shadow
|
|
193
|
+
|
|
194
|
+
Props for box and text shadows.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import styled from '@emotion/styled';
|
|
198
|
+
import { system } from '@codecademy/gamut-styles';
|
|
199
|
+
|
|
200
|
+
const Box = styled.div(system.shadow);
|
|
201
|
+
|
|
202
|
+
<Box
|
|
203
|
+
boxShadow="0 0 4px rgba(0, 0, 0, .15)"
|
|
204
|
+
textShadow="0 0 4px rgba(0, 0, 0, .15)"
|
|
205
|
+
/>;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
<TokenTable rows={getPropRows('shadows')} columns={defaultColumns} />
|
|
209
|
+
|
|
210
|
+
## List
|
|
211
|
+
|
|
212
|
+
Props for adjusting list styles when rendering a component as a `ul` or `ol`
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import styled from '@emotion/styled';
|
|
216
|
+
import { system } from '@codecademy/gamut-styles';
|
|
217
|
+
|
|
218
|
+
const Box = styled.div(system.list);
|
|
219
|
+
|
|
220
|
+
<Box
|
|
221
|
+
as="ul"
|
|
222
|
+
listStyleType="square"
|
|
223
|
+
listStylePosition="inside"
|
|
224
|
+
listStyleImage="none"
|
|
225
|
+
>
|
|
226
|
+
<Box as="li">a list item</Box>
|
|
227
|
+
</Box>;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
<TokenTable rows={getPropRows('list')} columns={defaultColumns} />
|
|
@@ -6,17 +6,17 @@ import { breakpoint } from '../../shared/elements';
|
|
|
6
6
|
import * as ResponsivePropertiesStories from './ResponsiveProperties.stories';
|
|
7
7
|
|
|
8
8
|
export const parameters = {
|
|
9
|
-
title: 'Responsive
|
|
9
|
+
title: 'Responsive Properties',
|
|
10
10
|
subtitle:
|
|
11
11
|
'All system props accept a syntax to generate responsive styles on a per prop basis',
|
|
12
12
|
source: {
|
|
13
13
|
repo: 'variance',
|
|
14
14
|
githubLink:
|
|
15
|
-
'https://github.com/Codecademy/gamut/blob/
|
|
15
|
+
'https://github.com/Codecademy/gamut/blob/cass-gm-842/packages/variance/src/utils/responsive.ts',
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
<Meta
|
|
19
|
+
<Meta title="Foundations/System/Responsive Properties" />
|
|
20
20
|
|
|
21
21
|
<AboutHeader {...parameters} />
|
|
22
22
|
|
|
@@ -2,31 +2,22 @@ import { Anchor, Box } from '@codecademy/gamut';
|
|
|
2
2
|
import {
|
|
3
3
|
Background,
|
|
4
4
|
coreSwatches,
|
|
5
|
-
css,
|
|
6
5
|
lxStudioColors,
|
|
7
6
|
theme,
|
|
8
7
|
trueColors,
|
|
9
8
|
} from '@codecademy/gamut-styles';
|
|
10
9
|
// eslint-disable-next-line gamut/import-paths
|
|
11
10
|
import * as ALL_PROPS from '@codecademy/gamut-styles/src/variance/config';
|
|
12
|
-
import styled from '@emotion/styled';
|
|
13
11
|
import kebabCase from 'lodash/kebabCase';
|
|
14
12
|
|
|
15
13
|
import { Code, ColorScale, LinkTo, TokenTable } from '~styleguide/blocks';
|
|
16
14
|
|
|
17
15
|
import { applyCorrectNotation } from './applyCorrectNotation';
|
|
18
16
|
|
|
19
|
-
const AnchorCode = styled(Code)(
|
|
20
|
-
css({
|
|
21
|
-
textDecoration: 'underline',
|
|
22
|
-
mx: 4,
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
|
|
26
17
|
export const PROP_COLUMN = {
|
|
27
18
|
key: 'key',
|
|
28
19
|
name: 'Prop',
|
|
29
|
-
size: '
|
|
20
|
+
size: 'md',
|
|
30
21
|
render: ({ id }: any) => <Code>{id}</Code>,
|
|
31
22
|
};
|
|
32
23
|
|
|
@@ -425,14 +416,11 @@ const PROPERTIES_COLUMN = {
|
|
|
425
416
|
}) =>
|
|
426
417
|
properties.map((property) => (
|
|
427
418
|
<Anchor
|
|
428
|
-
href={`https://developer.mozilla.org/en-US/docs/Web/CSS/${
|
|
429
|
-
property
|
|
430
|
-
)}`}
|
|
431
|
-
key={property}
|
|
419
|
+
href={`https://developer.mozilla.org/en-US/docs/Web/CSS/${property}`}
|
|
432
420
|
rel=""
|
|
433
421
|
target="_blank"
|
|
434
422
|
>
|
|
435
|
-
<
|
|
423
|
+
<Code key={property}>{kebabCase(property)}</Code>
|
|
436
424
|
</Anchor>
|
|
437
425
|
)),
|
|
438
426
|
};
|
|
@@ -442,7 +430,7 @@ const SCALE_COLUMN = {
|
|
|
442
430
|
name: 'Scale',
|
|
443
431
|
size: 'lg',
|
|
444
432
|
render: ({ scale }: { scale: string }) => (
|
|
445
|
-
<LinkTo id=
|
|
433
|
+
<LinkTo id={`foundations-theme--${kebabCase(scale)}`}>{scale}</LinkTo>
|
|
446
434
|
),
|
|
447
435
|
};
|
|
448
436
|
|
|
@@ -28,8 +28,7 @@ export const parameters = {
|
|
|
28
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
|
-
|
|
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.
|
|
31
|
+
The info button has low and high emphasis variants and the `Tip` has 4 alignment variants.
|
|
33
32
|
|
|
34
33
|
## Variants
|
|
35
34
|
|
|
@@ -57,17 +56,19 @@ This `floating` variant should only be used as needed.
|
|
|
57
56
|
|
|
58
57
|
### InfoTips with links or buttons
|
|
59
58
|
|
|
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.
|
|
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.
|
|
61
60
|
|
|
62
61
|
<Canvas of={InfoTipStories.WithLinksOrButtons} />
|
|
63
62
|
|
|
64
|
-
###
|
|
63
|
+
### Automatic Focus Management
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
InfoTips automatically manage focus for optimal keyboard accessibility:
|
|
67
66
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
- **<KeyboardKey>
|
|
67
|
+
- **Opening**: Focus automatically moves to the tip content when opened
|
|
68
|
+
- ** <KeyboardKey>Tab</KeyboardKey> (Floating)**: Navigate forward through focusable elements (links, buttons) inside the tip. When reaching the last element, wraps back to the InfoTip button
|
|
69
|
+
- **<KeyboardKey>Shift </KeyboardKey> + <KeyboardKey>Tab</KeyboardKey> (Floating)**: Navigate backward naturally - from the button, exits to the previous page element
|
|
70
|
+
- **<KeyboardKey>Tab</KeyboardKey> or <KeyboardKey>Shift</KeyboardKey> +<KeyboardKey>Tab</KeyboardKey> (Inline)**: Follows normal document flow
|
|
71
|
+
- **<KeyboardKey>Escape</KeyboardKey>**: Closes the tip and returns focus to the InfoTip button
|
|
71
72
|
|
|
72
73
|
<Canvas of={InfoTipStories.KeyboardNavigation} />
|
|
73
74
|
|
|
@@ -82,6 +83,21 @@ InfoTips have intelligent Escape key handling that works correctly both inside a
|
|
|
82
83
|
|
|
83
84
|
<Canvas of={InfoTipStories.InfoTipInsideModal} />
|
|
84
85
|
|
|
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
|
+
|
|
85
101
|
## InfoTips and zIndex
|
|
86
102
|
|
|
87
103
|
You can change the zIndex of your `InfoTip` with the zIndex property.
|