@codecademy/styleguide 79.2.5-alpha.a33c0b.0 → 79.3.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 +2 -2
- package/.storybook/components/Elements/StorySource.tsx +2 -2
- package/.storybook/components/Headers/ComponentHeader.tsx +1 -1
- package/.storybook/components/ImageWrapper.tsx +4 -2
- package/.storybook/main.ts +3 -20
- package/.storybook/manager.ts +1 -1
- package/.storybook/preview.ts +11 -9
- package/.storybook/theming/GamutTheme.ts +1 -1
- package/CHANGELOG.md +3 -4
- package/package.json +2 -2
- package/project.json +0 -9
- package/src/lib/About.mdx +1 -1
- package/src/lib/Atoms/About.mdx +1 -1
- package/src/lib/Atoms/Animations/About.mdx +1 -1
- package/src/lib/Atoms/Animations/ExpandInCollapseOut/ExpandInCollapseOut.mdx +1 -1
- package/src/lib/Atoms/Animations/FadeInSlideOut/FadeInSlideOut.mdx +1 -1
- package/src/lib/Atoms/Animations/Rotation/Rotation.mdx +1 -1
- package/src/lib/Atoms/Badge/Badge.mdx +1 -1
- package/src/lib/Atoms/Buttons/About.mdx +1 -1
- package/src/lib/Atoms/Buttons/Button/Button.mdx +1 -1
- package/src/lib/Atoms/Buttons/CTAButton/CTAButton.mdx +1 -1
- package/src/lib/Atoms/Buttons/FillButton/FillButton.mdx +1 -1
- package/src/lib/Atoms/Buttons/IconButton/IconButton.mdx +1 -1
- package/src/lib/Atoms/Buttons/StrokeButton/StrokeButton.mdx +1 -1
- package/src/lib/Atoms/Buttons/TextButton/TextButton.mdx +1 -1
- package/src/lib/Atoms/Card/Card.mdx +1 -1
- package/src/lib/Atoms/Drawer/Drawer.mdx +1 -1
- package/src/lib/Atoms/FeatureShimmer/FeatureShimmer.mdx +1 -1
- package/src/lib/Atoms/FormElements/About.mdx +1 -1
- package/src/lib/Atoms/FormElements/Form/Form.mdx +1 -1
- package/src/lib/Atoms/FormElements/FormGroup/FormGroup.mdx +1 -1
- package/src/lib/Atoms/FormElements/FormGroupDescription/FormGroupDescription.mdx +1 -1
- package/src/lib/Atoms/FormElements/FormGroupLabel/FormGroupLabel.mdx +1 -1
- package/src/lib/Atoms/FormElements/FormRequiredText/FormRequiredText.mdx +1 -1
- package/src/lib/Atoms/FormInputs/About.mdx +1 -1
- package/src/lib/Atoms/FormInputs/Checkbox/Checkbox.mdx +1 -1
- package/src/lib/Atoms/FormInputs/Input/Input.mdx +1 -1
- package/src/lib/Atoms/FormInputs/Radio/Radio.mdx +1 -1
- package/src/lib/Atoms/FormInputs/Select/Select.mdx +1 -1
- package/src/lib/Atoms/FormInputs/SelectDropdown/SelectDropdown.mdx +1 -1
- package/src/lib/Atoms/FormInputs/TextArea/TextArea.mdx +1 -1
- package/src/lib/Atoms/Icons/About.mdx +1 -1
- package/src/lib/Atoms/Icons/Mini/Mini.mdx +1 -1
- package/src/lib/Atoms/Icons/Regular/Regular.mdx +1 -1
- package/src/lib/Atoms/Illustrations/Illustrations.mdx +1 -1
- package/src/lib/Atoms/InternalFloatingCard/InternalFloatingCard.mdx +1 -1
- package/src/lib/Atoms/Loaders/About.mdx +1 -1
- package/src/lib/Atoms/Loaders/Shimmer/Shimmer.mdx +1 -1
- package/src/lib/Atoms/Loaders/Spinner/Spinner.mdx +1 -1
- package/src/lib/Atoms/Patterns/Patterns.mdx +1 -1
- package/src/lib/Atoms/PopoverContainer/PopoverContainer.mdx +1 -1
- package/src/lib/Atoms/ProgressBar/ProgressBar.mdx +1 -1
- package/src/lib/Atoms/RadialProgress/RadialProgress.mdx +1 -1
- package/src/lib/Atoms/SkipToContent/SkipToContent.mdx +1 -1
- package/src/lib/Atoms/Tag/Tag.mdx +1 -1
- package/src/lib/Atoms/Toggle/Toggle.mdx +1 -1
- package/src/lib/Atoms/UtilityComponents/About.mdx +1 -1
- package/src/lib/Atoms/UtilityComponents/DelayedRenderWrapper/DelayedRenderWrapper.mdx +1 -1
- package/src/lib/Atoms/UtilityComponents/FocusTrap/FocusTrap.mdx +1 -1
- package/src/lib/Foundations/About.mdx +1 -1
- package/src/lib/Foundations/ColorMode/ColorMode.mdx +1 -1
- package/src/lib/Foundations/Layout.mdx +1 -1
- package/src/lib/Foundations/System/About.mdx +1 -1
- package/src/lib/Foundations/System/Compose.mdx +1 -1
- package/src/lib/Foundations/System/Props/About.mdx +1 -1
- package/src/lib/Foundations/System/Props/Background.mdx +1 -1
- package/src/lib/Foundations/System/Props/Border.mdx +1 -1
- package/src/lib/Foundations/System/Props/Color.mdx +1 -1
- package/src/lib/Foundations/System/Props/Flex.mdx +1 -1
- package/src/lib/Foundations/System/Props/Grid.mdx +1 -1
- package/src/lib/Foundations/System/Props/Layout.mdx +1 -1
- package/src/lib/Foundations/System/Props/List.mdx +1 -1
- package/src/lib/Foundations/System/Props/Positioning.mdx +1 -1
- package/src/lib/Foundations/System/Props/Shadow.mdx +1 -1
- package/src/lib/Foundations/System/Props/Space.mdx +1 -1
- package/src/lib/Foundations/System/Props/Typography.mdx +1 -1
- package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.mdx +1 -1
- package/src/lib/Foundations/System/Variants.mdx +1 -1
- package/src/lib/Foundations/Theme/About.mdx +1 -1
- package/src/lib/Foundations/Theme/AdminTheme.mdx +1 -1
- package/src/lib/Foundations/Theme/CoreTheme.mdx +1 -1
- package/src/lib/Foundations/Theme/CreatingThemes.mdx +1 -1
- package/src/lib/Foundations/Theme/LXStudioTheme.mdx +1 -1
- package/src/lib/Foundations/Theme/PercipioTheme.mdx +1 -1
- package/src/lib/Foundations/Theme/PlatformTheme.mdx +1 -1
- package/src/lib/Foundations/Typography.mdx +1 -1
- package/src/lib/Foundations/Utilities/Utilities.mdx +1 -1
- package/src/lib/Layouts/About.mdx +1 -1
- package/src/lib/Layouts/Boxes/About.mdx +1 -1
- package/src/lib/Layouts/Boxes/Box/Box.mdx +1 -1
- package/src/lib/Layouts/Boxes/FlexBox/FlexBox.mdx +1 -1
- package/src/lib/Layouts/Boxes/GridBox/GridBox.mdx +1 -1
- package/src/lib/Layouts/ContentContainer/ContentContainer.mdx +1 -1
- package/src/lib/Layouts/LayoutGrid/LayoutGrid.mdx +1 -1
- package/src/lib/Meta/About.mdx +1 -1
- package/src/lib/Meta/Best practices.mdx +1 -1
- package/src/lib/Meta/Brand.mdx +1 -1
- package/src/lib/Meta/Contributing.mdx +1 -1
- package/src/lib/Meta/Deep Controls add-on.mdx +1 -1
- package/src/lib/Meta/ESLint rules.mdx +1 -1
- package/src/lib/Meta/FAQs.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/About.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Documentation in code.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Formatting.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/General principles.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Language and grammar.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Linking.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Referencing code.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Stories/About pages.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Stories/About.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Stories/Component code examples.mdx +1 -1
- package/src/lib/Meta/Gamut writing guide/Stories/Component story documentation.mdx +3 -3
- package/src/lib/Meta/Installation.mdx +1 -1
- package/src/lib/Meta/Logical and physical CSS properties.mdx +1 -1
- package/src/lib/Meta/MCP/About.mdx +1 -1
- package/src/lib/Meta/MCP/Code Connect.mdx +1 -1
- package/src/lib/Meta/MCP/Figma MCP.mdx +1 -1
- package/src/lib/Meta/Usage guide.mdx +1 -1
- package/src/lib/Molecules/About.mdx +1 -1
- package/src/lib/Molecules/AccordionButtonDeprecated/AccordionButtonDeprecated.mdx +1 -1
- package/src/lib/Molecules/AccordionDeprecated/AccordionDeprecated.mdx +1 -1
- package/src/lib/Molecules/Alert/Alert.mdx +1 -1
- package/src/lib/Molecules/Breadcrumbs/Breadcrumbs.mdx +1 -1
- package/src/lib/Molecules/Coachmark/Coachmark.mdx +1 -1
- package/src/lib/Molecules/Disclosure/Disclosure.mdx +1 -1
- package/src/lib/Molecules/Flyout/Flyout.mdx +1 -1
- package/src/lib/Molecules/Menu/Menu.mdx +1 -1
- package/src/lib/Molecules/Modals/About.mdx +1 -1
- package/src/lib/Molecules/Modals/Dialog/Dialog.mdx +1 -1
- package/src/lib/Molecules/Modals/Modal/Modal.mdx +1 -1
- package/src/lib/Molecules/Modals/Overlay/Overlay.mdx +1 -1
- package/src/lib/Molecules/Pagination/Pagination.mdx +1 -1
- package/src/lib/Molecules/Popover/Popover.mdx +1 -1
- package/src/lib/Molecules/Tabs/Tabs.mdx +1 -1
- package/src/lib/Molecules/Tips/About.mdx +1 -1
- package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +2 -2
- package/src/lib/Molecules/Tips/PreviewTip/PreviewTip.mdx +1 -1
- package/src/lib/Molecules/Tips/ToolTip/ToolTip.mdx +1 -1
- package/src/lib/Molecules/Toasts/About.mdx +1 -1
- package/src/lib/Molecules/Toasts/Toast/Toast.mdx +1 -1
- package/src/lib/Molecules/Toasts/Toaster/Toaster.mdx +1 -1
- package/src/lib/Molecules/Video/Video.mdx +1 -1
- package/src/lib/Organisms/About.mdx +1 -1
- package/src/lib/Organisms/BarChart/BarChart.mdx +463 -0
- package/src/lib/Organisms/BarChart/BarChart.stories.tsx +352 -0
- package/src/lib/Organisms/ConnectedForm/About.mdx +1 -1
- package/src/lib/Organisms/ConnectedForm/ConnectedForm/ConnectedForm.mdx +1 -1
- package/src/lib/Organisms/ConnectedForm/ConnectedForm/ConnectedForm.stories.tsx +1 -1
- package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.mdx +1 -1
- package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.stories.tsx +1 -1
- package/src/lib/Organisms/ConnectedForm/ConnectedFormInputs/ConnectedFormInputs.mdx +1 -1
- package/src/lib/Organisms/ConnectedForm/SubmitButton/SubmitButton.mdx +1 -1
- package/src/lib/Organisms/ConnectedForm/SubmitButton/SubmitButton.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/About.mdx +1 -1
- package/src/lib/Organisms/GridForm/Buttons.mdx +1 -1
- package/src/lib/Organisms/GridForm/Buttons.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/Fields.mdx +1 -1
- package/src/lib/Organisms/GridForm/Fields.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/Layout.mdx +1 -1
- package/src/lib/Organisms/GridForm/Layout.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/States.mdx +1 -1
- package/src/lib/Organisms/GridForm/States.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/Usage.mdx +1 -1
- package/src/lib/Organisms/GridForm/Usage.stories.tsx +1 -1
- package/src/lib/Organisms/GridForm/Validation.mdx +1 -1
- package/src/lib/Organisms/Lists & Tables/About.mdx +1 -1
- package/src/lib/Organisms/Lists & Tables/DataList/DataList.mdx +1 -1
- package/src/lib/Organisms/Lists & Tables/DataTable/DataTable.mdx +1 -1
- package/src/lib/Organisms/Lists & Tables/List/List.mdx +1 -1
- package/src/lib/Organisms/Markdown/Markdown.mdx +1 -1
- package/src/lib/Typography/About.mdx +1 -1
- package/src/lib/Typography/Anchor/Anchor.mdx +1 -1
- package/src/lib/Typography/HiddenText/HiddenText.mdx +1 -1
- package/src/lib/Typography/Text/Text.mdx +1 -1
- package/src/lib/UX Writing/About.mdx +1 -1
- package/src/lib/UX Writing/Accessibility guidelines.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/About.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Alerts.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Alternative text.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Buttons.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Confirmation dialogs.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Error messages.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Notifications.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Toasts.mdx +1 -1
- package/src/lib/UX Writing/Component guidelines/Tooltips.mdx +1 -1
- package/src/lib/UX Writing/DIY UX writing in 8 steps.mdx +1 -1
- package/src/static/organisms/barchart.png +0 -0
|
@@ -0,0 +1,352 @@
|
|
|
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
|
+
maxScaleValue: 2000,
|
|
20
|
+
title: 'Skills experience chart',
|
|
21
|
+
unit: 'XP',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof BarChart>;
|
|
27
|
+
|
|
28
|
+
const simpleBarData: BarProps[] = [
|
|
29
|
+
{ categoryLabel: 'Python', seriesOneValue: 1500 },
|
|
30
|
+
{ categoryLabel: 'JavaScript', seriesOneValue: 2000 },
|
|
31
|
+
{ categoryLabel: 'HTML/CSS', seriesOneValue: 800 },
|
|
32
|
+
{ categoryLabel: 'SQL', seriesOneValue: 600 },
|
|
33
|
+
{ categoryLabel: 'React', seriesOneValue: 450 },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const stackedBarData: BarProps[] = [
|
|
37
|
+
{ categoryLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
|
|
38
|
+
{
|
|
39
|
+
categoryLabel: 'JavaScript',
|
|
40
|
+
icon: TerminalIcon,
|
|
41
|
+
seriesOneValue: 1800,
|
|
42
|
+
seriesTwoValue: 2000,
|
|
43
|
+
},
|
|
44
|
+
{ categoryLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
|
|
45
|
+
{ categoryLabel: 'SQL', seriesOneValue: 550, seriesTwoValue: 600 },
|
|
46
|
+
{ categoryLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const accessibilityBarData: BarProps[] = [
|
|
50
|
+
{ categoryLabel: 'Python', seriesOneValue: 200, seriesTwoValue: 1500 },
|
|
51
|
+
{
|
|
52
|
+
categoryLabel: 'JavaScript',
|
|
53
|
+
seriesOneValue: 1800,
|
|
54
|
+
seriesTwoValue: 2000,
|
|
55
|
+
href: '/javascript',
|
|
56
|
+
},
|
|
57
|
+
{ categoryLabel: 'HTML/CSS', seriesOneValue: 600, seriesTwoValue: 800 },
|
|
58
|
+
{ categoryLabel: 'SQL', seriesOneValue: 550, href: '/sql' },
|
|
59
|
+
{ categoryLabel: 'Rust', seriesOneValue: 400 },
|
|
60
|
+
{ categoryLabel: 'React', seriesOneValue: 300, seriesTwoValue: 450 },
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const accessibilityTranslations: PartialBarChartTranslations = {
|
|
64
|
+
accessibility: {
|
|
65
|
+
stackedBarSummary: (ctx) =>
|
|
66
|
+
`${ctx.seriesOneValue} ${ctx.unit} gained — now at ${ctx.seriesTwoValue} ${ctx.unit} in ${ctx.categoryLabel}`,
|
|
67
|
+
singleValueBarSummary: (ctx) =>
|
|
68
|
+
`${ctx.value} ${ctx.unit} in ${ctx.categoryLabel}`,
|
|
69
|
+
},
|
|
70
|
+
locale: 'en',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const barDataWithIcons: BarProps[] = [
|
|
74
|
+
{
|
|
75
|
+
categoryLabel: 'Python',
|
|
76
|
+
seriesOneValue: 200,
|
|
77
|
+
seriesTwoValue: 1500,
|
|
78
|
+
icon: TerminalIcon,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
categoryLabel: 'JavaScript',
|
|
82
|
+
seriesOneValue: 150,
|
|
83
|
+
seriesTwoValue: 2000,
|
|
84
|
+
icon: TerminalIcon,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
categoryLabel: 'Data Science',
|
|
88
|
+
seriesOneValue: 100,
|
|
89
|
+
seriesTwoValue: 800,
|
|
90
|
+
icon: DataScienceIcon,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
categoryLabel: 'Backend',
|
|
94
|
+
seriesOneValue: 50,
|
|
95
|
+
seriesTwoValue: 600,
|
|
96
|
+
icon: TerminalIcon,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
categoryLabel: 'Reading',
|
|
100
|
+
seriesOneValue: 75,
|
|
101
|
+
seriesTwoValue: 450,
|
|
102
|
+
icon: BookFlipPageIcon,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export const Default: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
barValues: simpleBarData,
|
|
109
|
+
title: 'Skills experience chart',
|
|
110
|
+
description: 'Chart showing programming language experience levels',
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const Stacked: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
barValues: stackedBarData,
|
|
117
|
+
title: 'Skills progress chart',
|
|
118
|
+
description: 'Progress toward total goals for each programming language',
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithIcons: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
barValues: barDataWithIcons,
|
|
125
|
+
title: 'Skills progress with icons',
|
|
126
|
+
description: 'Skills progress with visual icons for each category',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const Animated: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
barValues: stackedBarData,
|
|
133
|
+
animate: true,
|
|
134
|
+
title: 'Animated skills chart',
|
|
135
|
+
description: 'Animated chart showing progress with entrance animations',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const Interactive: Story = {
|
|
140
|
+
args: {
|
|
141
|
+
barValues: simpleBarData.map((bar) => ({
|
|
142
|
+
...bar,
|
|
143
|
+
onClick: action(`Clicked ${bar.categoryLabel}`),
|
|
144
|
+
})),
|
|
145
|
+
title: 'Interactive skills chart',
|
|
146
|
+
description: 'Click on any row to view detailed course information',
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const WithLinks: Story = {
|
|
151
|
+
args: {
|
|
152
|
+
barValues: simpleBarData.map((bar) => ({
|
|
153
|
+
...bar,
|
|
154
|
+
href: `#${bar.categoryLabel.toLowerCase().replace(/\s+/g, '-')}`,
|
|
155
|
+
})),
|
|
156
|
+
title: 'Skills chart with links',
|
|
157
|
+
description: 'Each row links to its corresponding course page',
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const WithVisualTitleAndDescription: Story = {
|
|
162
|
+
args: {
|
|
163
|
+
barValues: simpleBarData,
|
|
164
|
+
title: 'Programming Skills Overview',
|
|
165
|
+
description:
|
|
166
|
+
'Experience points earned across different programming languages',
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const WithHiddenTitleAndDescription: Story = {
|
|
171
|
+
render: () => {
|
|
172
|
+
return (
|
|
173
|
+
<BarChart
|
|
174
|
+
barValues={simpleBarData}
|
|
175
|
+
description="Experience points earned across different programming languages"
|
|
176
|
+
hideDescription
|
|
177
|
+
hideTitle
|
|
178
|
+
maxScaleValue={2000}
|
|
179
|
+
title="Programming Skills Overview"
|
|
180
|
+
unit="XP"
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const WithExternalTitle: Story = {
|
|
187
|
+
render: () => {
|
|
188
|
+
return (
|
|
189
|
+
<>
|
|
190
|
+
<Box
|
|
191
|
+
as="h2"
|
|
192
|
+
bg="background-selected"
|
|
193
|
+
border={1}
|
|
194
|
+
borderRadius="lg"
|
|
195
|
+
id="external-chart-title"
|
|
196
|
+
p={16}
|
|
197
|
+
textAlign="right"
|
|
198
|
+
>
|
|
199
|
+
Programming Skills Overview
|
|
200
|
+
</Box>
|
|
201
|
+
<BarChart
|
|
202
|
+
aria-labelledby="external-chart-title"
|
|
203
|
+
barValues={simpleBarData}
|
|
204
|
+
description="Experience points earned across different programming languages"
|
|
205
|
+
hideDescription={false}
|
|
206
|
+
maxScaleValue={2000}
|
|
207
|
+
unit="XP"
|
|
208
|
+
/>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const WithSorting: Story = {
|
|
215
|
+
args: {
|
|
216
|
+
barValues: simpleBarData,
|
|
217
|
+
sortFns: ['alphabetically', 'numerically', 'none'],
|
|
218
|
+
title: 'Skills experience chart',
|
|
219
|
+
description: 'Use the dropdown to sort bars by different criteria',
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const customSortingBarValues = [
|
|
224
|
+
{
|
|
225
|
+
categoryLabel: 'Python',
|
|
226
|
+
seriesOneValue: 1500,
|
|
227
|
+
dateAdded: new Date('2023-01-15'),
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
categoryLabel: 'JavaScript',
|
|
231
|
+
seriesOneValue: 2000,
|
|
232
|
+
dateAdded: new Date('2023-03-20'),
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
categoryLabel: 'React',
|
|
236
|
+
seriesOneValue: 450,
|
|
237
|
+
dateAdded: new Date('2023-06-10'),
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
categoryLabel: 'TypeScript',
|
|
241
|
+
seriesOneValue: 300,
|
|
242
|
+
dateAdded: new Date('2023-08-05'),
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
categoryLabel: 'SQL',
|
|
246
|
+
seriesOneValue: 600,
|
|
247
|
+
dateAdded: new Date('2023-02-28'),
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
|
|
251
|
+
export const WithCustomSorting: Story = {
|
|
252
|
+
args: {
|
|
253
|
+
barValues: customSortingBarValues,
|
|
254
|
+
sortFns: [
|
|
255
|
+
'none',
|
|
256
|
+
{
|
|
257
|
+
label: 'Recently Added',
|
|
258
|
+
value: 'recent',
|
|
259
|
+
sortFn: (bars) => {
|
|
260
|
+
return [...bars].sort((a, b) => {
|
|
261
|
+
const aDate = a.dateAdded as Date | undefined;
|
|
262
|
+
const bDate = b.dateAdded as Date | undefined;
|
|
263
|
+
if (!aDate && !bDate) return 0;
|
|
264
|
+
if (!aDate) return 1;
|
|
265
|
+
if (!bDate) return -1;
|
|
266
|
+
return bDate.getTime() - aDate.getTime();
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
label: 'Oldest First',
|
|
272
|
+
value: 'oldest',
|
|
273
|
+
sortFn: (bars) => {
|
|
274
|
+
return [...bars].sort((a, b) => {
|
|
275
|
+
const aDate = a.dateAdded as Date | undefined;
|
|
276
|
+
const bDate = b.dateAdded as Date | undefined;
|
|
277
|
+
if (!aDate && !bDate) return 0;
|
|
278
|
+
if (!aDate) return 1;
|
|
279
|
+
if (!bDate) return -1;
|
|
280
|
+
return aDate.getTime() - bDate.getTime();
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
title: 'Skills chart with date sorting',
|
|
286
|
+
description:
|
|
287
|
+
'Custom sort functions can access additional properties on BarProps, such as dates',
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export const CustomStyles: Story = {
|
|
292
|
+
args: {
|
|
293
|
+
barValues: stackedBarData,
|
|
294
|
+
styleConfig: {
|
|
295
|
+
seriesTwoBarColor: 'text',
|
|
296
|
+
seriesOneBarColor: 'primary',
|
|
297
|
+
textColor: 'primary',
|
|
298
|
+
seriesOneLabel: 'feedback-error',
|
|
299
|
+
seriesTwoLabel: 'feedback-success',
|
|
300
|
+
},
|
|
301
|
+
title: 'Custom styled skills chart',
|
|
302
|
+
description: 'Custom color scheme applied to chart elements',
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export const CustomScale: Story = {
|
|
307
|
+
args: {
|
|
308
|
+
barValues: simpleBarData,
|
|
309
|
+
maxScaleValue: 2000,
|
|
310
|
+
scaleInterval: 250,
|
|
311
|
+
title: 'Skills chart with custom scale',
|
|
312
|
+
description: 'Custom scale intervals for more granular value display',
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export const WithStringTranslations: Story = {
|
|
317
|
+
args: {
|
|
318
|
+
barValues: stackedBarData,
|
|
319
|
+
sortFns: ['alphabetically', 'numerically', 'none'],
|
|
320
|
+
title: 'Gráfico de habilidades',
|
|
321
|
+
description: 'Progreso hacia los objetivos totales por lenguaje',
|
|
322
|
+
unit: 'XP',
|
|
323
|
+
translations: {
|
|
324
|
+
locale: 'es',
|
|
325
|
+
sortLabel: 'Ordenar por:',
|
|
326
|
+
sortOptions: {
|
|
327
|
+
none: 'Ninguno',
|
|
328
|
+
labelAsc: 'Etiqueta (A-Z)',
|
|
329
|
+
labelDesc: 'Etiqueta (Z-A)',
|
|
330
|
+
valueAsc: 'Valor (Bajo-Alto)',
|
|
331
|
+
valueDesc: 'Valor (Alto-Bajo)',
|
|
332
|
+
},
|
|
333
|
+
accessibility: {
|
|
334
|
+
stackedBarSummary: (ctx) =>
|
|
335
|
+
`Valor inicial - ${ctx.seriesOneValue} ${ctx.unit}. ${ctx.gained} ${ctx.unit} ganado - ahora en ${ctx.seriesTwoValue} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
336
|
+
singleValueBarSummary: (ctx) =>
|
|
337
|
+
`${ctx.value} ${ctx.unit} en ${ctx.categoryLabel}`,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const WithFunctionTranslations: Story = {
|
|
344
|
+
args: {
|
|
345
|
+
barValues: accessibilityBarData,
|
|
346
|
+
description:
|
|
347
|
+
'Custom aria-label summaries via translation functions (stacked, link, and non-interactive bars)',
|
|
348
|
+
title: 'Skills experience (accessibility functions)',
|
|
349
|
+
translations: accessibilityTranslations,
|
|
350
|
+
unit: 'XP',
|
|
351
|
+
},
|
|
352
|
+
};
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
useConnectedForm,
|
|
13
13
|
} from '@codecademy/gamut';
|
|
14
14
|
import { MiniArrowRightIcon, TerminalIcon } from '@codecademy/gamut-icons';
|
|
15
|
+
import { action } from '@storybook/addon-actions';
|
|
15
16
|
import type { Meta } from '@storybook/react';
|
|
16
17
|
import { useState } from 'react';
|
|
17
|
-
import { action } from 'storybook/actions';
|
|
18
18
|
|
|
19
19
|
const meta: Meta<typeof ConnectedForm> = {
|
|
20
20
|
component: ConnectedForm,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
useConnectedForm,
|
|
9
9
|
} from '@codecademy/gamut';
|
|
10
|
+
import { action } from '@storybook/addon-actions';
|
|
10
11
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
11
|
-
import { action } from 'storybook/actions';
|
|
12
12
|
import type { TypeWithDeepControls } from 'storybook-addon-deep-controls';
|
|
13
13
|
|
|
14
14
|
import { infotipNestedArgTypes } from '~styleguide/argTypes';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectedForm, FlexBox, SubmitButton, Text } from '@codecademy/gamut';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { action } from 'storybook/actions';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof SubmitButton> = {
|
|
6
6
|
component: SubmitButton,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormGroup, GridForm, Input, Text } from '@codecademy/gamut';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { action } from 'storybook/actions';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof GridForm> = {
|
|
6
6
|
component: GridForm,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridForm, Markdown } from '@codecademy/gamut';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { action } from 'storybook/actions';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof GridForm> = {
|
|
6
6
|
component: GridForm,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GridForm } from '@codecademy/gamut';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
4
|
import { useState } from 'react';
|
|
4
|
-
import { action } from 'storybook/actions';
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof GridForm> = {
|
|
7
7
|
component: GridForm,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridForm } from '@codecademy/gamut';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
2
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { action } from 'storybook/actions';
|
|
4
4
|
import type { TypeWithDeepControls } from 'storybook-addon-deep-controls';
|
|
5
5
|
|
|
6
6
|
const meta: TypeWithDeepControls<Meta<typeof GridForm>> = {
|