@codecademy/styleguide 79.2.4-alpha.ee1acd.0 → 79.2.4

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 (183) hide show
  1. package/.storybook/components/Elements/DocsContainer.tsx +2 -2
  2. package/.storybook/components/Elements/StorySource.tsx +2 -2
  3. package/.storybook/components/Headers/ComponentHeader.tsx +1 -1
  4. package/.storybook/main.ts +3 -20
  5. package/.storybook/manager.ts +1 -1
  6. package/.storybook/preview.ts +33 -11
  7. package/.storybook/theming/GamutTheme.ts +1 -1
  8. package/CHANGELOG.md +2 -5
  9. package/package.json +2 -2
  10. package/project.json +0 -9
  11. package/src/lib/About.mdx +1 -1
  12. package/src/lib/Atoms/About.mdx +1 -1
  13. package/src/lib/Atoms/Animations/About.mdx +1 -1
  14. package/src/lib/Atoms/Animations/ExpandInCollapseOut/ExpandInCollapseOut.mdx +1 -1
  15. package/src/lib/Atoms/Animations/FadeInSlideOut/FadeInSlideOut.mdx +1 -1
  16. package/src/lib/Atoms/Animations/Rotation/Rotation.mdx +1 -1
  17. package/src/lib/Atoms/Badge/Badge.mdx +1 -1
  18. package/src/lib/Atoms/Buttons/About.mdx +1 -1
  19. package/src/lib/Atoms/Buttons/Button/Button.mdx +1 -1
  20. package/src/lib/Atoms/Buttons/CTAButton/CTAButton.mdx +1 -1
  21. package/src/lib/Atoms/Buttons/FillButton/FillButton.mdx +1 -1
  22. package/src/lib/Atoms/Buttons/IconButton/IconButton.mdx +1 -1
  23. package/src/lib/Atoms/Buttons/StrokeButton/StrokeButton.mdx +1 -1
  24. package/src/lib/Atoms/Buttons/TextButton/TextButton.mdx +1 -1
  25. package/src/lib/Atoms/Card/Card.mdx +1 -1
  26. package/src/lib/Atoms/Drawer/Drawer.mdx +1 -1
  27. package/src/lib/Atoms/FeatureShimmer/FeatureShimmer.mdx +1 -1
  28. package/src/lib/Atoms/FormElements/About.mdx +1 -1
  29. package/src/lib/Atoms/FormElements/Form/Form.mdx +1 -1
  30. package/src/lib/Atoms/FormElements/FormGroup/FormGroup.mdx +1 -1
  31. package/src/lib/Atoms/FormElements/FormGroupDescription/FormGroupDescription.mdx +1 -1
  32. package/src/lib/Atoms/FormElements/FormGroupLabel/FormGroupLabel.mdx +1 -1
  33. package/src/lib/Atoms/FormElements/FormRequiredText/FormRequiredText.mdx +1 -1
  34. package/src/lib/Atoms/FormInputs/About.mdx +1 -1
  35. package/src/lib/Atoms/FormInputs/Checkbox/Checkbox.mdx +1 -1
  36. package/src/lib/Atoms/FormInputs/Input/Input.mdx +1 -1
  37. package/src/lib/Atoms/FormInputs/Radio/Radio.mdx +1 -1
  38. package/src/lib/Atoms/FormInputs/Select/Select.mdx +1 -1
  39. package/src/lib/Atoms/FormInputs/SelectDropdown/SelectDropdown.mdx +1 -1
  40. package/src/lib/Atoms/FormInputs/TextArea/TextArea.mdx +1 -1
  41. package/src/lib/Atoms/Icons/About.mdx +1 -1
  42. package/src/lib/Atoms/Icons/Mini/Mini.mdx +1 -1
  43. package/src/lib/Atoms/Icons/Regular/Regular.mdx +1 -1
  44. package/src/lib/Atoms/Illustrations/Illustrations.mdx +1 -1
  45. package/src/lib/Atoms/InternalFloatingCard/InternalFloatingCard.mdx +1 -1
  46. package/src/lib/Atoms/Loaders/About.mdx +1 -1
  47. package/src/lib/Atoms/Loaders/Shimmer/Shimmer.mdx +1 -1
  48. package/src/lib/Atoms/Loaders/Spinner/Spinner.mdx +1 -1
  49. package/src/lib/Atoms/Patterns/Patterns.mdx +1 -1
  50. package/src/lib/Atoms/PopoverContainer/PopoverContainer.mdx +1 -1
  51. package/src/lib/Atoms/ProgressBar/ProgressBar.mdx +1 -1
  52. package/src/lib/Atoms/RadialProgress/RadialProgress.mdx +1 -1
  53. package/src/lib/Atoms/SkipToContent/SkipToContent.mdx +1 -1
  54. package/src/lib/Atoms/Tag/Tag.mdx +1 -1
  55. package/src/lib/Atoms/Toggle/Toggle.mdx +1 -1
  56. package/src/lib/Atoms/UtilityComponents/About.mdx +1 -1
  57. package/src/lib/Atoms/UtilityComponents/DelayedRenderWrapper/DelayedRenderWrapper.mdx +1 -1
  58. package/src/lib/Atoms/UtilityComponents/FocusTrap/FocusTrap.mdx +1 -1
  59. package/src/lib/Foundations/About.mdx +1 -1
  60. package/src/lib/Foundations/ColorMode/ColorMode.mdx +1 -1
  61. package/src/lib/Foundations/Layout.mdx +1 -1
  62. package/src/lib/Foundations/System/About.mdx +1 -1
  63. package/src/lib/Foundations/System/Compose.mdx +1 -1
  64. package/src/lib/Foundations/System/Props/About.mdx +1 -1
  65. package/src/lib/Foundations/System/Props/Background.mdx +1 -1
  66. package/src/lib/Foundations/System/Props/Border.mdx +1 -1
  67. package/src/lib/Foundations/System/Props/Color.mdx +1 -1
  68. package/src/lib/Foundations/System/Props/Flex.mdx +1 -1
  69. package/src/lib/Foundations/System/Props/Grid.mdx +1 -1
  70. package/src/lib/Foundations/System/Props/Layout.mdx +1 -1
  71. package/src/lib/Foundations/System/Props/List.mdx +1 -1
  72. package/src/lib/Foundations/System/Props/Positioning.mdx +1 -1
  73. package/src/lib/Foundations/System/Props/Shadow.mdx +1 -1
  74. package/src/lib/Foundations/System/Props/Space.mdx +1 -1
  75. package/src/lib/Foundations/System/Props/Typography.mdx +1 -1
  76. package/src/lib/Foundations/System/ResponsiveProperties/ResponsiveProperties.mdx +1 -1
  77. package/src/lib/Foundations/System/Variants.mdx +1 -1
  78. package/src/lib/Foundations/Theme/About.mdx +1 -1
  79. package/src/lib/Foundations/Theme/AdminTheme.mdx +1 -1
  80. package/src/lib/Foundations/Theme/CoreTheme.mdx +1 -1
  81. package/src/lib/Foundations/Theme/CreatingThemes.mdx +1 -1
  82. package/src/lib/Foundations/Theme/LXStudioTheme.mdx +1 -1
  83. package/src/lib/Foundations/Theme/PercipioTheme.mdx +1 -1
  84. package/src/lib/Foundations/Theme/PlatformTheme.mdx +1 -1
  85. package/src/lib/Foundations/Typography.mdx +1 -1
  86. package/src/lib/Foundations/Utilities/Utilities.mdx +1 -1
  87. package/src/lib/Layouts/About.mdx +1 -1
  88. package/src/lib/Layouts/Boxes/About.mdx +1 -1
  89. package/src/lib/Layouts/Boxes/Box/Box.mdx +1 -1
  90. package/src/lib/Layouts/Boxes/FlexBox/FlexBox.mdx +1 -1
  91. package/src/lib/Layouts/Boxes/GridBox/GridBox.mdx +1 -1
  92. package/src/lib/Layouts/ContentContainer/ContentContainer.mdx +1 -1
  93. package/src/lib/Layouts/LayoutGrid/LayoutGrid.mdx +1 -1
  94. package/src/lib/Meta/About.mdx +6 -6
  95. package/src/lib/Meta/{Best Practices.mdx → Best practices.mdx } +4 -4
  96. package/src/lib/Meta/Brand.mdx +1 -1
  97. package/src/lib/Meta/Contributing.mdx +1 -1
  98. package/src/lib/Meta/{Deep Controls Add-On.mdx → Deep Controls add-on.mdx } +1 -1
  99. package/src/lib/Meta/ESLint rules.mdx +1 -1
  100. package/src/lib/Meta/FAQs.mdx +1 -1
  101. package/src/lib/Meta/Gamut writing guide/About.mdx +43 -0
  102. package/src/lib/Meta/Gamut writing guide/Documentation in code.mdx +134 -0
  103. package/src/lib/Meta/Gamut writing guide/Formatting.mdx +69 -0
  104. package/src/lib/Meta/Gamut writing guide/General principles.mdx +46 -0
  105. package/src/lib/Meta/Gamut writing guide/Language and grammar.mdx +54 -0
  106. package/src/lib/Meta/Gamut writing guide/Linking.mdx +60 -0
  107. package/src/lib/Meta/Gamut writing guide/Referencing code.mdx +86 -0
  108. package/src/lib/Meta/Gamut writing guide/Stories/About pages.mdx +49 -0
  109. package/src/lib/Meta/Gamut writing guide/Stories/About.mdx +57 -0
  110. package/src/lib/Meta/Gamut writing guide/Stories/Component code examples.mdx +79 -0
  111. package/src/lib/Meta/{Stories.mdx → Gamut writing guide/Stories/Component story documentation.mdx } +22 -88
  112. package/src/lib/Meta/Installation.mdx +1 -1
  113. package/src/lib/Meta/Logical and physical CSS properties.mdx +1 -1
  114. package/src/lib/Meta/MCP/About.mdx +1 -1
  115. package/src/lib/Meta/MCP/Code Connect.mdx +1 -1
  116. package/src/lib/Meta/MCP/Figma MCP.mdx +1 -1
  117. package/src/lib/Meta/{Usage Guide.mdx → Usage guide.mdx } +4 -4
  118. package/src/lib/Molecules/About.mdx +1 -1
  119. package/src/lib/Molecules/AccordionButtonDeprecated/AccordionButtonDeprecated.mdx +1 -1
  120. package/src/lib/Molecules/AccordionDeprecated/AccordionDeprecated.mdx +1 -1
  121. package/src/lib/Molecules/Alert/Alert.mdx +1 -1
  122. package/src/lib/Molecules/Breadcrumbs/Breadcrumbs.mdx +1 -1
  123. package/src/lib/Molecules/Coachmark/Coachmark.mdx +1 -1
  124. package/src/lib/Molecules/Disclosure/Disclosure.mdx +1 -1
  125. package/src/lib/Molecules/Flyout/Flyout.mdx +1 -1
  126. package/src/lib/Molecules/Menu/Menu.mdx +1 -1
  127. package/src/lib/Molecules/Modals/About.mdx +1 -1
  128. package/src/lib/Molecules/Modals/Dialog/Dialog.mdx +1 -1
  129. package/src/lib/Molecules/Modals/Modal/Modal.mdx +1 -1
  130. package/src/lib/Molecules/Modals/Overlay/Overlay.mdx +1 -1
  131. package/src/lib/Molecules/Pagination/Pagination.mdx +1 -1
  132. package/src/lib/Molecules/Popover/Popover.mdx +1 -1
  133. package/src/lib/Molecules/Tabs/Tabs.mdx +1 -1
  134. package/src/lib/Molecules/Tips/About.mdx +1 -1
  135. package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +1 -1
  136. package/src/lib/Molecules/Tips/PreviewTip/PreviewTip.mdx +1 -1
  137. package/src/lib/Molecules/Tips/ToolTip/ToolTip.mdx +1 -1
  138. package/src/lib/Molecules/Toasts/About.mdx +1 -1
  139. package/src/lib/Molecules/Toasts/Toast/Toast.mdx +1 -1
  140. package/src/lib/Molecules/Toasts/Toaster/Toaster.mdx +1 -1
  141. package/src/lib/Molecules/Video/Video.mdx +1 -1
  142. package/src/lib/Organisms/About.mdx +1 -1
  143. package/src/lib/Organisms/ConnectedForm/About.mdx +1 -1
  144. package/src/lib/Organisms/ConnectedForm/ConnectedForm/ConnectedForm.mdx +1 -1
  145. package/src/lib/Organisms/ConnectedForm/ConnectedForm/ConnectedForm.stories.tsx +1 -1
  146. package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.mdx +1 -1
  147. package/src/lib/Organisms/ConnectedForm/ConnectedFormGroup/ConnectedFormGroup.stories.tsx +1 -1
  148. package/src/lib/Organisms/ConnectedForm/ConnectedFormInputs/ConnectedFormInputs.mdx +1 -1
  149. package/src/lib/Organisms/ConnectedForm/SubmitButton/SubmitButton.mdx +1 -1
  150. package/src/lib/Organisms/ConnectedForm/SubmitButton/SubmitButton.stories.tsx +1 -1
  151. package/src/lib/Organisms/GridForm/About.mdx +1 -1
  152. package/src/lib/Organisms/GridForm/Buttons.mdx +1 -1
  153. package/src/lib/Organisms/GridForm/Buttons.stories.tsx +1 -1
  154. package/src/lib/Organisms/GridForm/Fields.mdx +1 -1
  155. package/src/lib/Organisms/GridForm/Fields.stories.tsx +1 -1
  156. package/src/lib/Organisms/GridForm/Layout.mdx +1 -1
  157. package/src/lib/Organisms/GridForm/Layout.stories.tsx +1 -1
  158. package/src/lib/Organisms/GridForm/States.mdx +1 -1
  159. package/src/lib/Organisms/GridForm/States.stories.tsx +1 -1
  160. package/src/lib/Organisms/GridForm/Usage.mdx +1 -1
  161. package/src/lib/Organisms/GridForm/Usage.stories.tsx +1 -1
  162. package/src/lib/Organisms/GridForm/Validation.mdx +1 -1
  163. package/src/lib/Organisms/Lists & Tables/About.mdx +1 -1
  164. package/src/lib/Organisms/Lists & Tables/DataList/DataList.mdx +1 -1
  165. package/src/lib/Organisms/Lists & Tables/DataTable/DataTable.mdx +1 -1
  166. package/src/lib/Organisms/Lists & Tables/List/List.mdx +1 -1
  167. package/src/lib/Organisms/Markdown/Markdown.mdx +1 -1
  168. package/src/lib/Typography/About.mdx +1 -1
  169. package/src/lib/Typography/Anchor/Anchor.mdx +1 -1
  170. package/src/lib/Typography/HiddenText/HiddenText.mdx +1 -1
  171. package/src/lib/Typography/Text/Text.mdx +1 -1
  172. package/src/lib/UX Writing/About.mdx +1 -1
  173. package/src/lib/UX Writing/Accessibility guidelines.mdx +1 -1
  174. package/src/lib/UX Writing/Component guidelines/About.mdx +1 -1
  175. package/src/lib/UX Writing/Component guidelines/Alerts.mdx +1 -1
  176. package/src/lib/UX Writing/Component guidelines/Alternative text.mdx +1 -1
  177. package/src/lib/UX Writing/Component guidelines/Buttons.mdx +1 -1
  178. package/src/lib/UX Writing/Component guidelines/Confirmation dialogs.mdx +1 -1
  179. package/src/lib/UX Writing/Component guidelines/Error messages.mdx +1 -1
  180. package/src/lib/UX Writing/Component guidelines/Notifications.mdx +1 -1
  181. package/src/lib/UX Writing/Component guidelines/Toasts.mdx +1 -1
  182. package/src/lib/UX Writing/Component guidelines/Tooltips.mdx +1 -1
  183. package/src/lib/UX Writing/DIY UX writing in 8 steps.mdx +1 -1
@@ -0,0 +1,60 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader, Callout } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'Linking',
7
+ title: 'Linking',
8
+ subtitle: 'Best practices for linking within documentation',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Linking" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ Use links to help users navigate between related components and resources. This guide covers linking within Storybook, to external sites, and writing clear link text.
17
+
18
+ ## Internal Links
19
+
20
+ Use the `LinkTo` component from `~styleguide/blocks` and set the id prop as the story's id value.
21
+
22
+ ```tsx
23
+ import { LinkTo } from '~styleguide/blocks';
24
+ <LinkTo id="Meta/Stories">Stories</LinkTo>
25
+ <LinkTo id="Atoms/Animations/About">Animation</LinkTo>
26
+ ```
27
+
28
+ ### Guidelines:
29
+
30
+ - Link text describes the destination, not the action: "See the [Stories page](#)" not "[See the Stories page](#)"
31
+ - Use descriptive link text that makes sense out of context: "[Stories page](#)" not "[Click here](#)"
32
+ - Link component names to their documentation
33
+ - Verify that the link works correctly
34
+ - 2-3 words minimum for easy clicking
35
+ - Unique link text when multiple links on page
36
+ - Meaningful and descriptive: conveys destination
37
+ - Action-oriented when appropriate: "View the component"
38
+
39
+ ## External Links
40
+
41
+ When linking to external resources like official documentation or tools, use the following guidelines.
42
+
43
+ ### Markdown Links:
44
+
45
+ Use Markdown for external links. The examples below will open in a new tab:
46
+
47
+ ```markdown
48
+ [GitHub Repository](https://github.com/Codecademy/gamut)
49
+ [React Documentation](https://react.dev)
50
+ ```
51
+
52
+ ### Anchor Component:
53
+
54
+ For more control over the link, use the `Anchor` component. The example below will open in the current tab:
55
+
56
+ ```tsx
57
+ <Anchor href="https://github.com/Codecademy/gamut">Gamut Repository</Anchor>
58
+ ```
59
+
60
+ <Callout text='To open external links in new tabs, use `target="_blank" rel="noreferrer"` together for security. However, avoid forcing this behavior unless necessary — users can choose to open links in new tabs themselves.' />
@@ -0,0 +1,86 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'Referencing code',
7
+ title: 'Referencing code',
8
+ subtitle: 'Guidelines for referencing code and UI Elements',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Referencing code" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ This guide covers how to reference code elements, UI components, file paths, and commands consistently throughout documentation. Following these conventions ensures clarity and maintains a professional, accessible tone across all Gamut documentation.
17
+
18
+ ## Code in Text
19
+
20
+ - Use backticks for inline code: `onClick`, `flex-direction`, `Box`, `StrokeButton`, `variant`, `backgroundColor`, etc.
21
+ - File and package names: `Button.tsx`, `package.json`, `@codecademy/gamut`
22
+ - When linking to stories, use Storybook's `<LinkTo />` component
23
+ - Values assigned for props or variables: `true`, `16px`, `null`
24
+ - "The `Box` component" (first mention) → "the component" (subsequent mentions)
25
+ - When plural, the component should stay singular and the “component” is the pluralized, e.g
26
+ - ✅ “These `Box` components are…”
27
+ - ❌ “These `Boxes` are…”
28
+
29
+ ## Code samples
30
+
31
+ Code samples help developers understand how to implement components and patterns. Use them to demonstrate real-world usage, not just syntax.
32
+
33
+ ### Format:
34
+
35
+ ```tsx
36
+ import { StrokeButton } from '@codecademy/gamut';
37
+ export const SimpleButtonExample: React.FC = () => (
38
+ <StrokeButton variant="primary">Click me</StrokeButton>
39
+ );
40
+ ```
41
+
42
+ ### Guidelines:
43
+
44
+ - Include necessary imports
45
+ - Use realistic, working examples
46
+ - Add comments for complex logic
47
+ - Keep examples focused on one concept
48
+ - Use TypeScript types
49
+
50
+ ## Command-Line syntax
51
+
52
+ When documenting commands, use consistent formatting to make them easy to copy and execute. Commands should be ready to run without modification.
53
+
54
+ ### Format:
55
+
56
+ ```bash
57
+ yarn add @codecademy/gamut-kit
58
+ ```
59
+
60
+ ### Guidelines:
61
+
62
+ - Use shell (`sh`) syntax highlighting for commands
63
+ - Don't include command prompt symbols ($, #)
64
+ - Show one command per block unless related
65
+
66
+ ## File Paths
67
+
68
+ - Use backticks for file paths: `packages/gamut/src/Button/index.tsx`
69
+ - Use relative paths when contextual (e.g., `./types.ts`)
70
+ - Use paths from workspace root when further clarity is needed (e.g., `packages/gamut/src/Button/index.tsx`)
71
+ - Use "in" for code locations: "in the `componentName.mdx` file"
72
+
73
+ ## UI element references
74
+
75
+ When instructing users to interact with the interface, clearly identify what the UI elements are, where to find them, and how to interact with them.
76
+
77
+ ### Format:
78
+
79
+ - Bold for UI labels: **Next**, **Back**, **Close**
80
+ - Describe location: "Click the **Theme Switcher** (paintbrush icon)"
81
+ - Use sentence case: "the **Show code** button"
82
+ - Prefer words that aren't specific to input devices
83
+ - Use "click" as a device agnostic verb
84
+ - Avoid directional language:
85
+ - ✅ "the following/adjacent form" or "in the previous section"
86
+ - ❌ "the form on the right" or "in the section above"
@@ -0,0 +1,49 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader, LinkTo } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'About pages',
7
+ title: 'About pages',
8
+ subtitle: 'How to create table of contents pages for component folders',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Stories/About pages" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ An `About.mdx` file serves as a landing page for folders containing multiple related components or stories. Write a clear overview explaining what the folder contains and how components relate. Organize components logically by importance or usage frequency, use descriptive subtitles, and keep it concise—these are entry points, not detailed documentation.
17
+
18
+ ## When to create an About page
19
+
20
+ Create an `About.mdx` file when multiple stories are presented in a folder. For example, the <LinkTo id="Atoms/Icons/About">Icons</LinkTo> folder contains an `About.mdx` file with a table of contents that links to more specific information about the icons — in this case, <LinkTo id="Atoms/Icons/Mini">Mini icons</LinkTo> and <LinkTo id="Atoms/Icons/Regular">Regular icons</LinkTo>.
21
+
22
+ ## Basic structure
23
+
24
+ Inside the `About.mdx` file, use the `toc-story` snippet to generate a template. Import the `parameters` object from the respective component's `<ComponentName>.mdx` file and pass it to the `<TableOfContents />` component.
25
+
26
+ ```tsx
27
+ import { parameters as componentNameParameters } from './ComponentName.mdx';
28
+ import { parameters as anotherComponentParameters } from './AnotherComponent.mdx';
29
+
30
+
31
+ export const parameters = {
32
+ id: 'ParentDir/FolderName',
33
+ title: 'FolderName',
34
+ subtitle: 'Overview of the components in this folder.',
35
+ };
36
+
37
+ ...
38
+
39
+ <TableOfContents links={addParentPath(parameters.id, [componentNameParameters, anotherComponentParameters]))} />
40
+ ```
41
+
42
+ ## The addParentPath function
43
+
44
+ The `addParentPath()` function is used to ensure that the links in the table of contents have the correct IDs, which are derived from the parent path and the component's ID or title.
45
+
46
+ This function takes two arguments:
47
+
48
+ 1. The parent path (`parameters.id`) - defines the folder hierarchy
49
+ 2. An array of parameter objects from child components/pages
@@ -0,0 +1,57 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import {
4
+ AboutHeader,
5
+ addParentPath,
6
+ TableOfContents,
7
+ } from '~styleguide/blocks';
8
+
9
+ import { parameters as aboutPagesParameters } from './About pages.mdx';
10
+ import { parameters as componentCodeExamplesParameters } from './Component code examples.mdx';
11
+ import { parameters as componentStoryDocumentationParameters } from './Component story documentation.mdx';
12
+
13
+ export const parameters = {
14
+ id: 'Meta/Gamut writing guide/Stories',
15
+ title: 'Stories',
16
+ subtitle: 'Guidelines and tooling for writing Storybook stories and docs.',
17
+ status: 'static',
18
+ };
19
+
20
+ <Meta title="Meta/Gamut writing guide/Stories/About" />
21
+
22
+ <AboutHeader {...parameters} />
23
+
24
+ This guide covers how to write and organize Storybook stories for Gamut components. Use it when creating new component documentation or updating existing stories.
25
+
26
+ ## Quick start
27
+
28
+ We've provided a few helpful vscode snippets to help get through boilerplate. To use these start to type these strings in the editor and pick the template and fill out the tab targets.
29
+
30
+ - `component-story`: The default TSX story template for code examples.
31
+ - `component-doc`: The default component documentation template for a component's MDX file.
32
+ - `toc-story`: A simple template for a Table of Contents category page.
33
+
34
+ ## File structure and naming
35
+
36
+ When making a new story, there are a few things to keep in mind:
37
+
38
+ - The folder structure is indicative of our flavor of atomic design.
39
+ - The folder struture is identical to the storybook hierarchy generated.
40
+ - For non-component related file names with more than one word, use a space between the words and use sentence case.
41
+ - Example: `General principles.mdx`
42
+ - Component-related files should use kebab-case: `RadialProgress.mdx`
43
+
44
+ First find the right folder for the story in `packages/styleguide/stories` (e.g. `Atoms`, `Molecules`, `Organisms`, etc...).
45
+ After finding it, create a new folder with two new files `#{COMPONENT_NAME}.stories.tsx` and `#{COMPONENT_NAME}.mdx`. This folder can also contain examples or other associated utility files.
46
+
47
+ ## Learn more
48
+
49
+ Explore the pages below for detailed guidelines on each part of the story structure:
50
+
51
+ <TableOfContents
52
+ links={addParentPath(parameters.id, [
53
+ aboutPagesParameters,
54
+ componentStoryDocumentationParameters,
55
+ componentCodeExamplesParameters,
56
+ ])}
57
+ />
@@ -0,0 +1,79 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'Component code examples',
7
+ title: 'Component code examples',
8
+ subtitle: 'How to write .stories.tsx files for Gamut components',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Stories/Component code examples" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ The `.stories.tsx` file defines the interactive examples and variations of the component. These stories power the Storybook UI and provide developers with working code examples. Use concrete, realistic values in self-contained stories that are easy to copy and paste. Each story should demonstrate one clear variation or behavior.
17
+
18
+ Our guidelines stem from the Storybook, specifically the [Component Story Format (CSF)](https://storybook.js.org/docs/8/api/csf) and [Writing stories in TypeScript](https://storybook.js.org/docs/writing-stories/typescript) documentation. We recommend using these resources for more detailed information.
19
+
20
+ ## Basic structure
21
+
22
+ Each component should have a `ComponentName.stories.tsx` file that can use the `component-story` snippet to generate a template that resembles the following:
23
+
24
+ ```tsx
25
+ // For ComponentName.stories.tsx
26
+
27
+ import { ComponentName } from '@codecademy/gamut';
28
+ import type { Meta, StoryObj } from '@storybook/react';
29
+
30
+ const meta: Meta<typeof ComponentName> = {
31
+ component: ComponentName,
32
+ args: {
33
+ variant: 'default',
34
+ },
35
+ };
36
+
37
+ export default meta;
38
+ type Story = StoryObj<typeof ComponentName>;
39
+
40
+ export const Default: Story = {
41
+ args: {
42
+ children: <img src="./cinna.jpg" alt="jpeg" />,
43
+ },
44
+ };
45
+
46
+ export const Secondary: Story = {
47
+ args: {
48
+ children: 'Pro Content',
49
+ variant: 'secondary',
50
+ },
51
+ };
52
+ ```
53
+
54
+ ## Rendered code examples
55
+
56
+ Examples rendered via `<Canvas of={componentName.example} />` are stored in the `componentName.stories.tsx` file.
57
+
58
+ When providing an example, use concretely applicable values. Avoid naming things like foo or bar, instead be opt for values that could be used in a practical setting, e.g. if deciding on the name of a boolean variable, don't use isBar — instead, consider the setting the example could be used, isModalOpen.
59
+
60
+ When a user clicks **Show Code**, Storybook tries to show the underlying code, but Storybook is not good with abstractions. Instead of opting to be DRY, each example should contain all the code to render and when a user clicks on **Show Code**, they should be able to copy the code provided and render in their own project.
61
+
62
+ ```tsx
63
+ // ❌ Don't abstract the logic into an InfoTipExample
64
+ export const Default: Story = {
65
+ render: (args) => <InfoTipExample {...args} />,
66
+ };
67
+ ```
68
+
69
+ ```tsx
70
+ // ✅ Provide the actual code
71
+ export const Default: Story = {
72
+ render: (args) => (
73
+ <FlexBox center m={24} py={64}>
74
+ <Text mr={4}>Some text that needs info</Text>
75
+ <InfoTip {...args} />
76
+ </FlexBox>
77
+ ),
78
+ };
79
+ ```
@@ -1,72 +1,37 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
- import { AboutHeader, LinkTo } from '~styleguide/blocks';
3
+ import { AboutHeader } from '~styleguide/blocks';
4
4
 
5
5
  export const parameters = {
6
- id: 'Stories',
7
- title: 'Stories',
8
- subtitle: 'Guidelines and tooling for writing Storybook stories and docs.',
6
+ id: 'Component story documentation',
7
+ title: 'Component story documentation',
8
+ subtitle: 'How to write .mdx documentation files for Gamut components',
9
9
  status: 'static',
10
10
  };
11
11
 
12
- <Meta title="Meta/Stories" />
12
+ <Meta title="Meta/Gamut writing guide/Stories/Component story documentation" />
13
13
 
14
14
  <AboutHeader {...parameters} />
15
15
 
16
- ## Quick start
16
+ The `.mdx` file provides the documentation structure and context for the component. It combines the interactive stories from the `.stories.tsx` file with written documentation, usage guidelines, and metadata.
17
17
 
18
- We've provided a few helpful vscode snippets to help you get through boilerplate. To use these start to type these strings in your editor and pick the template and fill out the tab targets.
19
-
20
- - `component-story`: The default TSX story template.
21
- - `component-doc`: The default component documentation template - each component should have a `.tsx` and `.mdx` file.
22
- - `toc-story`: A simple template for a Table of Contents category page.
23
-
24
- ## File structure and naming
25
-
26
- When you make a new story theres a few things to keep in mind:
27
-
28
- - The folder structure is indicative of our flavor of atomic design.
29
- - The folder struture is identical to the storybook hierarchy generated.
30
-
31
- First find the right folder for your story in `packages/styleguide/stories` (e.g. `Atoms` | `Molecules` | `Organisms`).
32
- Once you've found it create a new folder with two new files `#{COMPONENT_NAME}.stories.tsx` and `#{COMPONENT_NAME}.mdx`. You can also store examples or other associated utility files in this folder.
33
-
34
- In your new files you can use the above snippets to set up your component add:
35
-
36
- ```tsx
37
- // For ComponentName.stories.tsx
38
-
39
- import { ComponentName } from '@codecademy/gamut';
40
- import type { Meta, StoryObj } from '@storybook/react';
18
+ ## Story structure
41
19
 
42
- const meta: Meta<typeof ComponentName> = {
43
- component: ComponentName,
44
- args: {
45
- variant: 'default',
46
- },
47
- };
20
+ In our opinion, a good component story page consists of:
48
21
 
49
- export default meta;
50
- type Story = StoryObj<typeof ComponentName>;
22
+ 1. **General Information:** Each component should define some key information on the `<Meta />` component
23
+ 2. **Flagship Story + Props:** A single default story showing the default state of the component with a connected props table right below it.
24
+ 3. **Variation Stories:** Granular subsections that show the discrete varaitions of the component and describe their use cases
25
+ 4. **Usage instructions and Guidelines:** A section that describes how to use the component should and shouldn't be used, and any guidelines that should be followed.
51
26
 
52
- export const Default: Story = {
53
- args: {
54
- children: <img src="./cinna.jpg" alt="jpeg" />,
55
- },
56
- };
27
+ ## Basic structure
57
28
 
58
- export const Secondary: Story = {
59
- args: {
60
- children: 'Pro Content',
61
- variant: 'secondary',
62
- },
63
- };
64
- ```
29
+ Each component should have a `ComponentName.mdx` file that can use the `component-doc` snippet to generate a template that resembles the following:
65
30
 
66
31
  ```tsx
67
32
  // For ComponentName.mdx, more details in the component-doc code snippet
68
33
 
69
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
34
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
70
35
 
71
36
  import { ComponentHeader } from '~styleguide/blocks';
72
37
 
@@ -97,16 +62,9 @@ export const parameters = {
97
62
  Etc...
98
63
  ```
99
64
 
100
- ## Story structure
65
+ ## General information
101
66
 
102
- In our opinion, a good component story page consists of:
103
-
104
- 1. **General Information:** Each component should define some key information on the `<Meta />` component
105
- 2. **Flagship Story + Props:** A single default story showing the default state of the component with a connected props table right below it.
106
- 3. **Variation Stories:** Granular subsections that show the discrete varaitions of the component and describe their use cases
107
- 4. **Usage instructions and Guidelines:** A section that describes how to use the component should and shouldn't be used, and any guidelines that should be followed.
108
-
109
- ### General information
67
+ Each component should define key metadata in the `parameters` object:
110
68
 
111
69
  1. `title`: The name of the component, this helps with linking to the story.
112
70
  2. `subtitle`: What the component does, and what the component would typically be used for.
@@ -115,7 +73,7 @@ In our opinion, a good component story page consists of:
115
73
  5. `design`: A link to the Figma file that is associated with the component.
116
74
 
117
75
  ```tsx
118
- import { Meta } from '@storybook/addon-docs/blocks';
76
+ import { Meta } from '@storybook/blocks';
119
77
 
120
78
  import { ComponentHeader } from '~styleguide/blocks';
121
79
 
@@ -141,9 +99,9 @@ export const parameters = {
141
99
 
142
100
  ```
143
101
 
144
- ### Flagship story
102
+ ## Flagship story
145
103
 
146
- The Flagship story for a component should be intended to give the reader a broad overview of its high-level functionality. Its `Canvas` should automatically display the story's code by setting the prop sourceState="shown".
104
+ The Flagship story for a component should be intended to give the reader a broad overview of its high-level functionality. Its `Canvas` should automatically display the story's code by setting the prop `sourceState="shown"`.
147
105
 
148
106
  Try to include the major behaviors for the component that most readers would need to understand its uses.
149
107
 
@@ -156,7 +114,7 @@ Try to include the major behaviors for the component that most readers would nee
156
114
  <Controls />
157
115
  ```
158
116
 
159
- ### Granular stories
117
+ ## Granular stories
160
118
 
161
119
  Each subsequent story should elaborate on an important behavioral feature of the component.
162
120
  Try to show a single use of the behavior configurable with args.
@@ -169,27 +127,3 @@ A short description should go here, as well as any variant specific usage guidel
169
127
  <Canvas of={AnchorStories.Variant} />
170
128
 
171
129
  ```
172
-
173
- ### About pages
174
-
175
- An `About.mdx` file should be be included when multiple stories are presented in a folder. E.g. the <LinkTo id="Atoms/Animations/About">Animation</LinkTo> folder which contains an `About.mdx` file with a table of contents that link to specific components -- in this case, the <LinkTo id="Atoms/Animations/ExpandInCollapseOut">ExpandInCollapseOut</LinkTo> component and the <LinkTo id="Atoms/Animations/Rotation">Rotation</LinkTo> component.
176
-
177
- Inside the `About.mdx` file, import the `parameters` object from the respective component's `<ComponentName>.mdx` file and pass it to the `<TableOfContents />` component.
178
-
179
- ```tsx
180
- import { parameters as componentNameParameters } from './ComponentName.mdx';
181
- import { parameters as anotherComponentParameters } from './AnotherComponent.mdx';
182
-
183
-
184
- export const parameters = {
185
- id: 'ParentDir/FolderName',
186
- title: 'FolderName',
187
- subtitle: 'Overview of the components in this folder.',
188
- };
189
-
190
- ...
191
-
192
- <TableOfContents links={addParentPath(parameters.id, [componentNameParameters, anotherComponentParameters]))} />
193
- ```
194
-
195
- The `addParentPath` function is used to ensure that the links in the table of contents have the correct IDs, which are derived from the parent path and the component's ID or title.
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import { AboutHeader } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import {
4
4
  AboutHeader,
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import {
4
4
  AboutHeader,
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import { AboutHeader, Callout, ImageWrapper } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import { AboutHeader, Callout } from '~styleguide/blocks';
4
4
 
@@ -1,16 +1,16 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import { AboutHeader, Callout, ImageWrapper, LinkTo } from '~styleguide/blocks';
4
4
 
5
5
  export const parameters = {
6
- id: 'Usage Guide',
7
- title: 'Usage Guide',
6
+ id: 'Usage guide',
7
+ title: 'Usage guide',
8
8
  subtitle:
9
9
  'Tips and tricks to using the Gamut Storybook as a user and developer.',
10
10
  status: 'static',
11
11
  };
12
12
 
13
- <Meta title="Meta/Usage Guide" />
13
+ <Meta title="Meta/Usage guide" />
14
14
 
15
15
  <AboutHeader {...parameters} />
16
16
 
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import { AboutHeader } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { Callout, ComponentHeader, LinkTo } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { Callout, ComponentHeader, LinkTo } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader, ImageWrapper } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader, LinkTo } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader, KeyboardKey, LinkTo } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import {
4
4
  Callout,
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
1
+ import { Meta } from '@storybook/blocks';
2
2
 
3
3
  import {
4
4
  AboutHeader,
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader, LinkTo } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader, KeyboardKey } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader } from '~styleguide/blocks';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
1
+ import { Canvas, Controls, Meta } from '@storybook/blocks';
2
2
 
3
3
  import { ComponentHeader } from '~styleguide/blocks';
4
4