@codecademy/styleguide 78.5.6-alpha.a75de2.0 → 78.5.6-alpha.afe04a.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.
Files changed (37) hide show
  1. package/.storybook/components/Elements/DocsContainer.tsx +4 -0
  2. package/.storybook/components/Elements/Markdown.tsx +0 -1
  3. package/.storybook/preview.ts +14 -0
  4. package/.storybook/theming/GamutThemeProvider.tsx +7 -1
  5. package/CHANGELOG.md +1 -1
  6. package/package.json +2 -2
  7. package/src/lib/Atoms/FormElements/FormGroup/FormGroup.mdx +0 -6
  8. package/src/lib/Atoms/FormElements/FormGroup/FormGroup.stories.tsx +0 -11
  9. package/src/lib/Foundations/System/About.mdx +1 -1
  10. package/src/lib/Foundations/System/Props/About.mdx +81 -0
  11. package/src/lib/Foundations/System/Props/Background.mdx +30 -0
  12. package/src/lib/Foundations/System/Props/Border.mdx +33 -0
  13. package/src/lib/Foundations/System/Props/Color.mdx +28 -0
  14. package/src/lib/Foundations/System/Props/Flex.mdx +28 -0
  15. package/src/lib/Foundations/System/Props/Grid.mdx +31 -0
  16. package/src/lib/Foundations/System/Props/Layout.mdx +34 -0
  17. package/src/lib/Foundations/System/Props/List.mdx +38 -0
  18. package/src/lib/Foundations/System/Props/Positioning.mdx +29 -0
  19. package/src/lib/Foundations/System/Props/Shadow.mdx +31 -0
  20. package/src/lib/Foundations/System/Props/Space.mdx +44 -0
  21. package/src/lib/Foundations/System/Props/Space.stories.tsx +48 -0
  22. package/src/lib/Foundations/System/Props/Typography.mdx +28 -0
  23. package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.mdx +3 -3
  24. package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.stories.tsx +1 -0
  25. package/src/lib/Foundations/shared/elements.tsx +69 -19
  26. package/src/lib/Meta/About.mdx +3 -1
  27. package/src/lib/Meta/Logical and physical CSS properties.mdx +123 -0
  28. package/src/lib/Meta/Usage Guide.mdx +6 -1
  29. package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +8 -24
  30. package/src/lib/Molecules/Tips/InfoTip/InfoTip.stories.tsx +34 -86
  31. package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.mdx +0 -20
  32. package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.stories.tsx +0 -84
  33. package/src/lib/Organisms/GridForm/Fields.mdx +0 -20
  34. package/src/lib/Organisms/GridForm/Fields.stories.tsx +1 -73
  35. package/src/lib/Organisms/GridForm/Layout.mdx +1 -1
  36. package/src/static/meta/toolbar.png +0 -0
  37. package/src/lib/Foundations/System/Props.mdx +0 -230
@@ -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: 'bottom-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
 
Binary file
@@ -1,230 +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: '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} />