@codecademy/styleguide 79.0.1-alpha.8aa868.0 → 79.0.1-alpha.aec23e.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/DocsContainer.tsx +0 -4
- package/.storybook/components/Elements/Markdown.tsx +1 -0
- package/.storybook/preview.ts +0 -14
- package/.storybook/theming/GamutThemeProvider.tsx +1 -7
- package/CHANGELOG.md +1 -1
- package/package.json +2 -2
- 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 +19 -69
- package/src/lib/Meta/About.mdx +1 -3
- package/src/lib/Meta/Usage Guide.mdx +1 -6
- package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +1 -1
- package/src/lib/Organisms/BarChart/BarChart.mdx +413 -0
- package/src/lib/Organisms/BarChart/BarChart.stories.tsx +375 -0
- package/src/static/meta/toolbar.png +0 -0
- 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 -44
- package/src/lib/Foundations/System/Props/Space.stories.tsx +0 -48
- package/src/lib/Foundations/System/Props/Typography.mdx +0 -28
- package/src/lib/Meta/Logical and physical CSS properties.mdx +0 -123
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BarChart,
|
|
3
|
+
BarProps,
|
|
4
|
+
Box,
|
|
5
|
+
PartialBarChartTranslations,
|
|
6
|
+
} from '@codecademy/gamut';
|
|
7
|
+
import {
|
|
8
|
+
BookFlipPageIcon,
|
|
9
|
+
DataScienceIcon,
|
|
10
|
+
TerminalIcon,
|
|
11
|
+
} from '@codecademy/gamut-icons';
|
|
12
|
+
import { action } from '@storybook/addon-actions';
|
|
13
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
14
|
+
|
|
15
|
+
const meta: Meta<typeof BarChart> = {
|
|
16
|
+
component: BarChart,
|
|
17
|
+
args: {
|
|
18
|
+
description: 'Chart showing programming language experience levels',
|
|
19
|
+
maxRange: 2000,
|
|
20
|
+
title: 'Skills experience chart',
|
|
21
|
+
unit: 'XP',
|
|
22
|
+
},
|
|
23
|
+
parameters: {
|
|
24
|
+
docs: {
|
|
25
|
+
description: {
|
|
26
|
+
component:
|
|
27
|
+
'BarChart supports i18n via the `translations` prop. Accessibility keys (`gainedNowAt`, `inLabel`, `inOnly`) may be strings (fragments in the built-in template) or functions that receive scoped context (values, label, unit, locale) and return the full accessibility summary—useful for pluralization, word order, or locale-specific phrasing.',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof BarChart>;
|
|
35
|
+
|
|
36
|
+
const simpleBarData: BarProps[] = [
|
|
37
|
+
{ yLabel: 'Python', seriesOneValue: 1500 },
|
|
38
|
+
{ yLabel: 'JavaScript', seriesOneValue: 2000 },
|
|
39
|
+
{ yLabel: 'HTML/CSS', seriesOneValue: 800 },
|
|
40
|
+
{ yLabel: 'SQL', seriesOneValue: 600 },
|
|
41
|
+
{ yLabel: 'React', seriesOneValue: 450 },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const stackedBarData: BarProps[] = [
|
|
45
|
+
{ yLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
|
|
46
|
+
{
|
|
47
|
+
yLabel: 'JavaScript',
|
|
48
|
+
icon: TerminalIcon,
|
|
49
|
+
seriesOneValue: 1800,
|
|
50
|
+
seriesTwoValue: 2000,
|
|
51
|
+
},
|
|
52
|
+
{ yLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
|
|
53
|
+
{ yLabel: 'SQL', seriesOneValue: 550, seriesTwoValue: 600 },
|
|
54
|
+
{ yLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const accessibilityBarData: BarProps[] = [
|
|
58
|
+
{ yLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
|
|
59
|
+
{
|
|
60
|
+
yLabel: 'JavaScript',
|
|
61
|
+
seriesOneValue: 1800,
|
|
62
|
+
seriesTwoValue: 2000,
|
|
63
|
+
href: '/javascript',
|
|
64
|
+
},
|
|
65
|
+
{ yLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
|
|
66
|
+
{ yLabel: 'SQL', seriesOneValue: 550, href: '/sql' },
|
|
67
|
+
{ yLabel: 'Rust', seriesOneValue: 400 },
|
|
68
|
+
{ yLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const accessibilityTranslations: PartialBarChartTranslations = {
|
|
72
|
+
accessibility: {
|
|
73
|
+
gainedNowAt: (ctx) =>
|
|
74
|
+
`${ctx.seriesOneValue} ${ctx.unit} gained — now at ${ctx.seriesTwoValue} ${ctx.unit} in ${ctx.yLabel}`,
|
|
75
|
+
inLabel: (ctx) => `${ctx.value} ${ctx.unit} in ${ctx.yLabel}`,
|
|
76
|
+
inOnly: (ctx) => `${ctx.value} ${ctx.unit}`.trim(),
|
|
77
|
+
},
|
|
78
|
+
locale: 'en',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const barDataWithIcons: BarProps[] = [
|
|
82
|
+
{
|
|
83
|
+
yLabel: 'Python',
|
|
84
|
+
seriesOneValue: 200,
|
|
85
|
+
seriesTwoValue: 1500,
|
|
86
|
+
icon: TerminalIcon,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
yLabel: 'JavaScript',
|
|
90
|
+
seriesOneValue: 150,
|
|
91
|
+
seriesTwoValue: 2000,
|
|
92
|
+
icon: TerminalIcon,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
yLabel: 'Data Science',
|
|
96
|
+
seriesOneValue: 100,
|
|
97
|
+
seriesTwoValue: 800,
|
|
98
|
+
icon: DataScienceIcon,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
yLabel: 'Backend',
|
|
102
|
+
seriesOneValue: 50,
|
|
103
|
+
seriesTwoValue: 600,
|
|
104
|
+
icon: TerminalIcon,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
yLabel: 'Reading',
|
|
108
|
+
seriesOneValue: 75,
|
|
109
|
+
seriesTwoValue: 450,
|
|
110
|
+
icon: BookFlipPageIcon,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export const Default: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
barValues: simpleBarData,
|
|
117
|
+
title: 'Skills experience chart',
|
|
118
|
+
description: 'Chart showing programming language experience levels',
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const Stacked: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
barValues: stackedBarData,
|
|
125
|
+
title: 'Skills progress chart',
|
|
126
|
+
description: 'Progress toward total goals for each programming language',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const WithIcons: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
barValues: barDataWithIcons,
|
|
133
|
+
title: 'Skills progress with icons',
|
|
134
|
+
description: 'Skills progress with visual icons for each category',
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Animated: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
barValues: stackedBarData,
|
|
141
|
+
animate: true,
|
|
142
|
+
title: 'Animated skills chart',
|
|
143
|
+
description: 'Animated chart showing progress with entrance animations',
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const Interactive: Story = {
|
|
148
|
+
args: {
|
|
149
|
+
barValues: simpleBarData.map((bar) => ({
|
|
150
|
+
...bar,
|
|
151
|
+
onClick: action(`Clicked ${bar.yLabel}`),
|
|
152
|
+
})),
|
|
153
|
+
title: 'Interactive skills chart',
|
|
154
|
+
description: 'Click on any row to view detailed course information',
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const WithLinks: Story = {
|
|
159
|
+
args: {
|
|
160
|
+
barValues: simpleBarData.map((bar) => ({
|
|
161
|
+
...bar,
|
|
162
|
+
href: `#${bar.yLabel.toLowerCase().replace(/\s+/g, '-')}`,
|
|
163
|
+
})),
|
|
164
|
+
title: 'Skills chart with links',
|
|
165
|
+
description: 'Each row links to its corresponding course page',
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const WithVisualTitleAndDescription: Story = {
|
|
170
|
+
args: {
|
|
171
|
+
barValues: simpleBarData,
|
|
172
|
+
title: 'Programming Skills Overview',
|
|
173
|
+
description:
|
|
174
|
+
'Experience points earned across different programming languages',
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const WithHiddenTitleAndDescription: Story = {
|
|
179
|
+
render: () => {
|
|
180
|
+
return (
|
|
181
|
+
<BarChart
|
|
182
|
+
barValues={simpleBarData}
|
|
183
|
+
description="Experience points earned across different programming languages"
|
|
184
|
+
hideDescription
|
|
185
|
+
hideTitle
|
|
186
|
+
maxRange={2000}
|
|
187
|
+
title="Programming Skills Overview"
|
|
188
|
+
unit="XP"
|
|
189
|
+
/>
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const WithExternalTitle: Story = {
|
|
195
|
+
render: () => {
|
|
196
|
+
return (
|
|
197
|
+
<>
|
|
198
|
+
<Box
|
|
199
|
+
as="h2"
|
|
200
|
+
bg="paleBlue"
|
|
201
|
+
border={1}
|
|
202
|
+
borderRadius="lg"
|
|
203
|
+
id="external-chart-title"
|
|
204
|
+
p={16}
|
|
205
|
+
textAlign="right"
|
|
206
|
+
>
|
|
207
|
+
Programming Skills Overview
|
|
208
|
+
</Box>
|
|
209
|
+
<BarChart
|
|
210
|
+
aria-labelledby="external-title"
|
|
211
|
+
barValues={simpleBarData}
|
|
212
|
+
description="Experience points earned across different programming languages"
|
|
213
|
+
hideDescription={false}
|
|
214
|
+
maxRange={2000}
|
|
215
|
+
unit="XP"
|
|
216
|
+
/>
|
|
217
|
+
</>
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const WithSorting: Story = {
|
|
223
|
+
args: {
|
|
224
|
+
barValues: simpleBarData,
|
|
225
|
+
sortFns: ['alphabetically', 'numerically', 'none'],
|
|
226
|
+
title: 'Skills experience chart',
|
|
227
|
+
description: 'Use the dropdown to sort bars by different criteria',
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const customSortingBarValues = [
|
|
232
|
+
{
|
|
233
|
+
yLabel: 'Python',
|
|
234
|
+
seriesOneValue: 1500,
|
|
235
|
+
dateAdded: new Date('2023-01-15'),
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
yLabel: 'JavaScript',
|
|
239
|
+
seriesOneValue: 2000,
|
|
240
|
+
dateAdded: new Date('2023-03-20'),
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
yLabel: 'React',
|
|
244
|
+
seriesOneValue: 450,
|
|
245
|
+
dateAdded: new Date('2023-06-10'),
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
yLabel: 'TypeScript',
|
|
249
|
+
seriesOneValue: 300,
|
|
250
|
+
dateAdded: new Date('2023-08-05'),
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
yLabel: 'SQL',
|
|
254
|
+
seriesOneValue: 600,
|
|
255
|
+
dateAdded: new Date('2023-02-28'),
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
export const WithCustomSorting: Story = {
|
|
260
|
+
args: {
|
|
261
|
+
barValues: customSortingBarValues,
|
|
262
|
+
sortFns: [
|
|
263
|
+
'none',
|
|
264
|
+
{
|
|
265
|
+
label: 'Recently Added',
|
|
266
|
+
value: 'recent',
|
|
267
|
+
sortFn: (bars) => {
|
|
268
|
+
return [...bars].sort((a, b) => {
|
|
269
|
+
// TypeScript infers the type from barValues, so dateAdded is properly typed
|
|
270
|
+
const aDate = a.dateAdded as Date | undefined;
|
|
271
|
+
const bDate = b.dateAdded as Date | undefined;
|
|
272
|
+
if (!aDate && !bDate) return 0;
|
|
273
|
+
if (!aDate) return 1;
|
|
274
|
+
if (!bDate) return -1;
|
|
275
|
+
return bDate.getTime() - aDate.getTime();
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
label: 'Oldest First',
|
|
281
|
+
value: 'oldest',
|
|
282
|
+
sortFn: (bars) => {
|
|
283
|
+
return [...bars].sort((a, b) => {
|
|
284
|
+
// TypeScript infers the type from barValues, so dateAdded is properly typed
|
|
285
|
+
const aDate = a.dateAdded as Date | undefined;
|
|
286
|
+
const bDate = b.dateAdded as Date | undefined;
|
|
287
|
+
if (!aDate && !bDate) return 0;
|
|
288
|
+
if (!aDate) return 1;
|
|
289
|
+
if (!bDate) return -1;
|
|
290
|
+
return aDate.getTime() - bDate.getTime();
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
title: 'Skills chart with date sorting',
|
|
296
|
+
description:
|
|
297
|
+
'Custom sort functions can access additional properties on BarProps, such as dates',
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Bar chart with custom styling
|
|
303
|
+
*/
|
|
304
|
+
export const CustomStyles: Story = {
|
|
305
|
+
args: {
|
|
306
|
+
barValues: stackedBarData,
|
|
307
|
+
styleConfig: {
|
|
308
|
+
seriesTwoBarColor: 'text',
|
|
309
|
+
seriesOneBarColor: 'primary',
|
|
310
|
+
textColor: 'primary',
|
|
311
|
+
seriesOneLabel: 'feedback-error',
|
|
312
|
+
seriesTwoLabel: 'feedback-success',
|
|
313
|
+
},
|
|
314
|
+
title: 'Custom styled skills chart',
|
|
315
|
+
description: 'Custom color scheme applied to chart elements',
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Bar chart with custom xScale interval
|
|
321
|
+
*/
|
|
322
|
+
export const CustomScale: Story = {
|
|
323
|
+
args: {
|
|
324
|
+
barValues: simpleBarData,
|
|
325
|
+
maxRange: 2000,
|
|
326
|
+
xScale: 250,
|
|
327
|
+
title: 'Skills chart with custom scale',
|
|
328
|
+
description: 'Custom scale intervals for more granular value display',
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Bar chart with string-based translations (e.g. Spanish).
|
|
334
|
+
* Partial translations are merged with defaults.
|
|
335
|
+
*/
|
|
336
|
+
export const WithStringTranslations: Story = {
|
|
337
|
+
args: {
|
|
338
|
+
barValues: stackedBarData,
|
|
339
|
+
sortFns: ['alphabetically', 'numerically', 'none'],
|
|
340
|
+
title: 'Gráfico de habilidades',
|
|
341
|
+
description: 'Progreso hacia los objetivos totales por lenguaje',
|
|
342
|
+
unit: 'XP',
|
|
343
|
+
translations: {
|
|
344
|
+
locale: 'es',
|
|
345
|
+
sortLabel: 'Ordenar por:',
|
|
346
|
+
sortOptions: {
|
|
347
|
+
none: 'Ninguno',
|
|
348
|
+
labelAsc: 'Etiqueta (A-Z)',
|
|
349
|
+
labelDesc: 'Etiqueta (Z-A)',
|
|
350
|
+
valueAsc: 'Valor (Bajo-Alto)',
|
|
351
|
+
valueDesc: 'Valor (Alto-Bajo)',
|
|
352
|
+
},
|
|
353
|
+
accessibility: {
|
|
354
|
+
gainedNowAt: 'ganado - ahora en',
|
|
355
|
+
inLabel: 'en',
|
|
356
|
+
inOnly: 'en ',
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Bar chart with function-based accessibility translations.
|
|
364
|
+
* Exercises gainedNowAt (stacked), inLabel (link/button single bar), and inOnly (non-interactive single bar).
|
|
365
|
+
*/
|
|
366
|
+
export const WithFunctionTranslations: Story = {
|
|
367
|
+
args: {
|
|
368
|
+
barValues: accessibilityBarData,
|
|
369
|
+
description:
|
|
370
|
+
'Custom aria-label summaries via translation functions (stacked, link, and non-interactive bars)',
|
|
371
|
+
title: 'Skills experience (accessibility functions)',
|
|
372
|
+
translations: accessibilityTranslations,
|
|
373
|
+
unit: 'XP',
|
|
374
|
+
},
|
|
375
|
+
};
|
|
Binary file
|
|
@@ -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} />
|
|
@@ -1,31 +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: 'Grid',
|
|
9
|
-
subtitle: 'Grid specific properties',
|
|
10
|
-
status: 'current',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
<Meta title="Foundations/System/Props/Grid" />
|
|
14
|
-
|
|
15
|
-
<AboutHeader {...parameters} />
|
|
16
|
-
|
|
17
|
-
Grid props give you powerful control over CSS Grid layouts. Define grid templates, control auto-placement behavior, and set gaps between grid items. These properties make it straightforward to create complex, responsive grid layouts with precise control over both container and item positioning.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import styled from '@emotion/styled';
|
|
21
|
-
import { system } from '@codecademy/gamut-styles';
|
|
22
|
-
|
|
23
|
-
const GridExample = styled.div(system.grid);
|
|
24
|
-
|
|
25
|
-
<GridExample
|
|
26
|
-
gridTemplateColumns="max-content 1fr max-content"
|
|
27
|
-
columnGap={32}
|
|
28
|
-
/>;
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
<TokenTable rows={getPropRows('grid')} columns={defaultColumns} />
|
|
@@ -1,34 +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: 'Layout',
|
|
9
|
-
subtitle:
|
|
10
|
-
'Props for handling dimensions and other layout specific properties.',
|
|
11
|
-
status: 'updating',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
<Meta title="Foundations/System/Props/Layout" />
|
|
15
|
-
|
|
16
|
-
<AboutHeader {...parameters} />
|
|
17
|
-
|
|
18
|
-
Layout props control the visual structure and dimensions of elements. These properties determine how components take up space, their display behavior, and how they align within their containers. Use these props to set widths, heights, overflow behavior, and container types for responsive layouts.
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
import styled from '@emotion/styled';
|
|
22
|
-
import { system } from '@codecademy/gamut-styles';
|
|
23
|
-
|
|
24
|
-
const LayoutExample = styled.div(system.layout);
|
|
25
|
-
|
|
26
|
-
<LayoutExample
|
|
27
|
-
display="flex"
|
|
28
|
-
width="50%"
|
|
29
|
-
height="300px"
|
|
30
|
-
verticalAlign="middle"
|
|
31
|
-
/>;
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
<TokenTable rows={getPropRows('layout')} columns={defaultColumns} />
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/blocks';
|
|
2
|
-
|
|
3
|
-
import { AboutHeader, LinkTo, TokenTable } from '~styleguide/blocks';
|
|
4
|
-
|
|
5
|
-
import { defaultColumns, getPropRows } from '../../shared/elements';
|
|
6
|
-
|
|
7
|
-
export const parameters = {
|
|
8
|
-
title: 'List',
|
|
9
|
-
subtitle:
|
|
10
|
-
'Props for adjusting list styles when rendering a component as a `ul` or `ol`',
|
|
11
|
-
status: 'current',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
<Meta title="Foundations/System/Props/List" />
|
|
15
|
-
|
|
16
|
-
<AboutHeader {...parameters} />
|
|
17
|
-
|
|
18
|
-
List props control the appearance of ordered and unordered lists when components are rendered as `ul` or `ol` elements. These properties let you customize bullet styles, list positioning, and even use custom images as list markers, giving you full control over list presentation.
|
|
19
|
-
|
|
20
|
-
For more advanced list features, refer to the <LinkTo id="Organisms/Lists & Tables/List">List component</LinkTo>.
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
import styled from '@emotion/styled';
|
|
24
|
-
import { system } from '@codecademy/gamut-styles';
|
|
25
|
-
|
|
26
|
-
const ListExample = styled.div(system.list);
|
|
27
|
-
|
|
28
|
-
<ListExample
|
|
29
|
-
as="ul"
|
|
30
|
-
listStyleType="square"
|
|
31
|
-
listStylePosition="inside"
|
|
32
|
-
listStyleImage="none"
|
|
33
|
-
>
|
|
34
|
-
<ListExample as="li">a list item</ListExample>
|
|
35
|
-
</ListExample>;
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
<TokenTable rows={getPropRows('list')} columns={defaultColumns} />
|