@codecademy/styleguide 79.0.1-alpha.4fa3a1.0 → 79.0.1-alpha.5b7e3d.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 (32) 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/Foundations/System/About.mdx +1 -1
  8. package/src/lib/Foundations/System/Props/About.mdx +81 -0
  9. package/src/lib/Foundations/System/Props/Background.mdx +30 -0
  10. package/src/lib/Foundations/System/Props/Border.mdx +53 -0
  11. package/src/lib/Foundations/System/Props/Border.stories.tsx +138 -0
  12. package/src/lib/Foundations/System/Props/Color.mdx +42 -0
  13. package/src/lib/Foundations/System/Props/Color.stories.tsx +47 -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/static/meta/toolbar.png +0 -0
  30. package/src/lib/Foundations/System/Props.mdx +0 -230
  31. package/src/lib/Organisms/BarChart/BarChart.mdx +0 -455
  32. package/src/lib/Organisms/BarChart/BarChart.stories.tsx +0 -296
@@ -1,296 +0,0 @@
1
- import { BarChart, BarProps, Box } from '@codecademy/gamut';
2
- import {
3
- BookFlipPageIcon,
4
- DataScienceIcon,
5
- TerminalIcon,
6
- } from '@codecademy/gamut-icons';
7
- import { action } from '@storybook/addon-actions';
8
- import type { Meta, StoryObj } from '@storybook/react';
9
-
10
- const meta: Meta<typeof BarChart> = {
11
- component: BarChart,
12
- args: {
13
- title: 'Skills experience chart',
14
- description: 'Chart showing programming language experience levels',
15
- minRange: 0,
16
- maxRange: 2000,
17
- unit: 'XP',
18
- },
19
- };
20
-
21
- export default meta;
22
- type Story = StoryObj<typeof BarChart>;
23
-
24
- const simpleBarData: BarProps[] = [
25
- { yLabel: 'Python', seriesOneValue: 1500 },
26
- { yLabel: 'JavaScript', seriesOneValue: 2000 },
27
- { yLabel: 'HTML/CSS', seriesOneValue: 800 },
28
- { yLabel: 'SQL', seriesOneValue: 600 },
29
- { yLabel: 'React', seriesOneValue: 450 },
30
- ];
31
-
32
- const stackedBarData: BarProps[] = [
33
- { yLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
34
- {
35
- yLabel: 'JavaScript',
36
- icon: TerminalIcon,
37
- seriesOneValue: 1800,
38
- seriesTwoValue: 2000,
39
- },
40
- { yLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
41
- { yLabel: 'SQL', seriesOneValue: 550, seriesTwoValue: 600 },
42
- { yLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
43
- ];
44
-
45
- const barDataWithIcons: BarProps[] = [
46
- {
47
- yLabel: 'Python',
48
- seriesOneValue: 200,
49
- seriesTwoValue: 1500,
50
- icon: TerminalIcon,
51
- },
52
- {
53
- yLabel: 'JavaScript',
54
- seriesOneValue: 150,
55
- seriesTwoValue: 2000,
56
- icon: TerminalIcon,
57
- },
58
- {
59
- yLabel: 'Data Science',
60
- seriesOneValue: 100,
61
- seriesTwoValue: 800,
62
- icon: DataScienceIcon,
63
- },
64
- {
65
- yLabel: 'Backend',
66
- seriesOneValue: 50,
67
- seriesTwoValue: 600,
68
- icon: TerminalIcon,
69
- },
70
- {
71
- yLabel: 'Reading',
72
- seriesOneValue: 75,
73
- seriesTwoValue: 450,
74
- icon: BookFlipPageIcon,
75
- },
76
- ];
77
-
78
- export const Default: Story = {
79
- args: {
80
- barValues: simpleBarData,
81
- title: 'Skills experience chart',
82
- description: 'Chart showing programming language experience levels',
83
- },
84
- };
85
-
86
- export const Stacked: Story = {
87
- args: {
88
- barValues: stackedBarData,
89
- title: 'Skills progress chart',
90
- description: 'Progress toward total goals for each programming language',
91
- },
92
- };
93
-
94
- export const WithIcons: Story = {
95
- args: {
96
- barValues: barDataWithIcons,
97
- title: 'Skills progress with icons',
98
- description: 'Skills progress with visual icons for each category',
99
- },
100
- };
101
-
102
- export const Animated: Story = {
103
- args: {
104
- barValues: stackedBarData,
105
- animate: true,
106
- title: 'Animated skills chart',
107
- description: 'Animated chart showing progress with entrance animations',
108
- },
109
- };
110
-
111
- export const Interactive: Story = {
112
- args: {
113
- barValues: simpleBarData.map((bar) => ({
114
- ...bar,
115
- onClick: action(`Clicked ${bar.yLabel}`),
116
- })),
117
- title: 'Interactive skills chart',
118
- description: 'Click on any row to view detailed course information',
119
- },
120
- };
121
-
122
- export const WithLinks: Story = {
123
- args: {
124
- barValues: simpleBarData.map((bar) => ({
125
- ...bar,
126
- href: `#${bar.yLabel.toLowerCase().replace(/\s+/g, '-')}`,
127
- })),
128
- title: 'Skills chart with links',
129
- description: 'Each row links to its corresponding course page',
130
- },
131
- };
132
-
133
- export const WithVisualTitleAndDescription: Story = {
134
- args: {
135
- barValues: simpleBarData,
136
- title: 'Programming Skills Overview',
137
- description:
138
- 'Experience points earned across different programming languages',
139
- },
140
- };
141
-
142
- export const WithHiddenTitleAndDescription: Story = {
143
- render: () => {
144
- return (
145
- <BarChart
146
- barValues={simpleBarData}
147
- description="Experience points earned across different programming languages"
148
- hideDescription
149
- hideTitle
150
- maxRange={2000}
151
- minRange={0}
152
- title="Programming Skills Overview"
153
- unit="XP"
154
- />
155
- );
156
- },
157
- };
158
-
159
- export const WithExternalTitle: Story = {
160
- render: () => {
161
- return (
162
- <>
163
- <Box
164
- as="h2"
165
- bg="paleBlue"
166
- border={1}
167
- borderRadius="lg"
168
- id="external-chart-title"
169
- p={16}
170
- textAlign="right"
171
- >
172
- Programming Skills Overview
173
- </Box>
174
- <BarChart
175
- aria-labelledby="external-title"
176
- barValues={simpleBarData}
177
- description="Experience points earned across different programming languages"
178
- hideDescription={false}
179
- maxRange={2000}
180
- minRange={0}
181
- unit="XP"
182
- />
183
- </>
184
- );
185
- },
186
- };
187
-
188
- export const WithSorting: Story = {
189
- args: {
190
- barValues: simpleBarData,
191
- sortFns: ['alphabetically', 'numerically', 'none'],
192
- title: 'Skills experience chart',
193
- description: 'Use the dropdown to sort bars by different criteria',
194
- },
195
- };
196
-
197
- const customSortingBarValues = [
198
- {
199
- yLabel: 'Python',
200
- seriesOneValue: 1500,
201
- dateAdded: new Date('2023-01-15'),
202
- },
203
- {
204
- yLabel: 'JavaScript',
205
- seriesOneValue: 2000,
206
- dateAdded: new Date('2023-03-20'),
207
- },
208
- {
209
- yLabel: 'React',
210
- seriesOneValue: 450,
211
- dateAdded: new Date('2023-06-10'),
212
- },
213
- {
214
- yLabel: 'TypeScript',
215
- seriesOneValue: 300,
216
- dateAdded: new Date('2023-08-05'),
217
- },
218
- {
219
- yLabel: 'SQL',
220
- seriesOneValue: 600,
221
- dateAdded: new Date('2023-02-28'),
222
- },
223
- ];
224
-
225
- export const WithCustomSorting: Story = {
226
- args: {
227
- barValues: customSortingBarValues,
228
- sortFns: [
229
- 'none',
230
- {
231
- label: 'Recently Added',
232
- value: 'recent',
233
- sortFn: (bars) => {
234
- return [...bars].sort((a, b) => {
235
- // TypeScript infers the type from barValues, so dateAdded is properly typed
236
- const aDate = a.dateAdded as Date | undefined;
237
- const bDate = b.dateAdded as Date | undefined;
238
- if (!aDate && !bDate) return 0;
239
- if (!aDate) return 1;
240
- if (!bDate) return -1;
241
- return bDate.getTime() - aDate.getTime();
242
- });
243
- },
244
- },
245
- {
246
- label: 'Oldest First',
247
- value: 'oldest',
248
- sortFn: (bars) => {
249
- return [...bars].sort((a, b) => {
250
- // TypeScript infers the type from barValues, so dateAdded is properly typed
251
- const aDate = a.dateAdded as Date | undefined;
252
- const bDate = b.dateAdded as Date | undefined;
253
- if (!aDate && !bDate) return 0;
254
- if (!aDate) return 1;
255
- if (!bDate) return -1;
256
- return aDate.getTime() - bDate.getTime();
257
- });
258
- },
259
- },
260
- ],
261
- title: 'Skills chart with date sorting',
262
- description:
263
- 'Custom sort functions can access additional properties on BarProps, such as dates',
264
- },
265
- };
266
-
267
- /**
268
- * Bar chart with custom styling
269
- */
270
- export const CustomStyles: Story = {
271
- args: {
272
- barValues: stackedBarData,
273
- styleConfig: {
274
- backgroundBarColor: 'text',
275
- foregroundBarColor: 'primary',
276
- textColor: 'primary',
277
- seriesOneLabel: 'feedback-error',
278
- seriesTwoLabel: 'feedback-success',
279
- },
280
- title: 'Custom styled skills chart',
281
- description: 'Custom color scheme applied to chart elements',
282
- },
283
- };
284
-
285
- /**
286
- * Bar chart with custom xScale interval
287
- */
288
- export const CustomScale: Story = {
289
- args: {
290
- barValues: simpleBarData,
291
- maxRange: 2000,
292
- xScale: 250,
293
- title: 'Skills chart with custom scale',
294
- description: 'Custom scale intervals for more granular value display',
295
- },
296
- };