@codecademy/styleguide 79.1.0 → 79.1.1-alpha.0165b9.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.
@@ -45,15 +45,33 @@ const preview: Preview = {
45
45
  'Meta',
46
46
  [
47
47
  'About',
48
- 'Best Practices',
48
+ 'Brand',
49
+ 'Best practices',
49
50
  'Contributing',
51
+ 'Deep Controls add-on',
50
52
  'ESLint rules',
51
53
  'FAQs',
52
- 'Stories',
53
- 'Brand',
54
54
  'Installation',
55
- 'Usage Guide',
55
+ 'Stories',
56
+ 'Usage guide',
56
57
  'MCP',
58
+ 'Gamut writing guide',
59
+ [
60
+ 'About',
61
+ 'General principles',
62
+ 'Documentation in code',
63
+ 'Formatting',
64
+ 'Language and grammar',
65
+ 'Linking',
66
+ 'Referencing code',
67
+ 'Stories',
68
+ [
69
+ 'About',
70
+ 'About pages',
71
+ 'Component story documentation',
72
+ 'Component code examples',
73
+ ],
74
+ ],
57
75
  ],
58
76
  'Foundations',
59
77
  'Layouts',
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [79.1.1-alpha.0165b9.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.0...@codecademy/styleguide@79.1.1-alpha.0165b9.0) (2026-02-11)
7
+
8
+ **Note:** Version bump only for package @codecademy/styleguide
9
+
6
10
  ## [79.1.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.0.0...@codecademy/styleguide@79.1.0) (2026-02-09)
7
11
 
8
12
  ### Features
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@codecademy/styleguide",
3
3
  "description": "Styleguide & Component library for codecademy.com",
4
- "version": "79.1.0",
4
+ "version": "79.1.1-alpha.0165b9.0",
5
5
  "author": "Codecademy Engineering",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "repository": "git@github.com:Codecademy/gamut.git",
11
- "gitHead": "d7c3a3fce650a3746f208c8e59aef7a5e49e9ec7"
11
+ "gitHead": "36a5b43d98d0c4bc396b0abaa56bcfb52b757904"
12
12
  }
@@ -6,16 +6,16 @@ import {
6
6
  TableOfContents,
7
7
  } from '~styleguide/blocks';
8
8
 
9
- import { parameters as bestPracticesParameters } from './Best Practices.mdx';
9
+ import { parameters as bestPracticesParameters } from './Best practices.mdx';
10
10
  import { parameters as brandParameters } from './Brand.mdx';
11
11
  import { parameters as contributingParameters } from './Contributing.mdx';
12
- import { parameters as deepControlsParameters } from './Deep Controls Add-On.mdx';
12
+ import { parameters as deepControlsParameters } from './Deep Controls add-on.mdx';
13
13
  import { parameters as eslintRulesParameters } from './ESLint rules.mdx';
14
14
  import { parameters as faqsParameters } from './FAQs.mdx';
15
+ import { parameters as gamutWritingGuideParameters } from './Gamut writing guide/About.mdx';
15
16
  import { parameters as installationParameters } from './Installation.mdx';
16
17
  import { parameters as mcpAboutParameters } from './MCP/About.mdx';
17
- import { parameters as storiesParameters } from './Stories.mdx';
18
- import { parameters as usageGuideParameters } from './Usage Guide.mdx';
18
+ import { parameters as usageGuideParameters } from './Usage guide.mdx';
19
19
 
20
20
  export const parameters = {
21
21
  id: 'Meta',
@@ -35,7 +35,7 @@ export const parameters = {
35
35
  deepControlsParameters,
36
36
  eslintRulesParameters,
37
37
  faqsParameters,
38
- storiesParameters,
38
+ gamutWritingGuideParameters,
39
39
  brandParameters,
40
40
  installationParameters,
41
41
  usageGuideParameters,
@@ -3,13 +3,13 @@ import { Meta } from '@storybook/blocks';
3
3
  import { AboutHeader, Callout } from '~styleguide/blocks';
4
4
 
5
5
  export const parameters = {
6
- id: 'Best Practices',
7
- title: 'Best Practices',
6
+ id: 'Best practices',
7
+ title: 'Best practices',
8
8
  subtitle: 'Current best practices for using the Gamut Design System',
9
9
  status: 'current',
10
10
  };
11
11
 
12
- <Meta title="Meta/Best Practices" />
12
+ <Meta title="Meta/Best practices" />
13
13
 
14
14
  <AboutHeader {...parameters} />
15
15
 
@@ -0,0 +1,43 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import {
4
+ AboutHeader,
5
+ addParentPath,
6
+ LinkTo,
7
+ TableOfContents,
8
+ } from '~styleguide/blocks';
9
+
10
+ import { parameters as documentationInCodeParameters } from './Documentation in code.mdx';
11
+ import { parameters as formattingParameters } from './Formatting.mdx';
12
+ import { parameters as generalPrinciplesParameters } from './General principles.mdx';
13
+ import { parameters as languageAndGrammarParameters } from './Language and grammar.mdx';
14
+ import { parameters as linkingParameters } from './Linking.mdx';
15
+ import { parameters as referencingCodeParameters } from './Referencing code.mdx';
16
+ import { parameters as storiesParameters } from './Stories/About.mdx';
17
+
18
+ export const parameters = {
19
+ id: 'Meta/Gamut writing guide',
20
+ title: 'Gamut writing guide',
21
+ subtitle:
22
+ 'Guidelines and standards for creating consistent, clear, and effective documentation.',
23
+ };
24
+
25
+ <Meta title="Meta/Gamut writing guide/About" />
26
+
27
+ <AboutHeader {...parameters} />
28
+
29
+ Welcome to the Gamut writing guide! Thanks for taking the time to learn about our documentation standards. This guide helps keep our documentation clear, consistent, and useful across the Gamut design system.
30
+
31
+ The <LinkTo id="Meta/Gamut writing guide/General principles">General principles</LinkTo> is a great place to get an overview of our documentation philosophy and best practices. For specific topics like formatting, code documentation, or writing Storybook stories, check out the other pages below.
32
+
33
+ <TableOfContents
34
+ links={addParentPath(parameters.id, [
35
+ generalPrinciplesParameters,
36
+ documentationInCodeParameters,
37
+ formattingParameters,
38
+ languageAndGrammarParameters,
39
+ linkingParameters,
40
+ referencingCodeParameters,
41
+ storiesParameters,
42
+ ])}
43
+ />
@@ -0,0 +1,134 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { ComponentHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ title: 'Documentation in code',
7
+ subtitle: `Guidelines for documenting code in Gamut component files`,
8
+ status: 'current',
9
+ };
10
+
11
+ <Meta title="Meta/Gamut writing guide/Documentation in code" />
12
+
13
+ <ComponentHeader {...parameters} />
14
+
15
+ Good documentation starts in the code itself. By documenting components, props, and functions directly in source files, we create a single source of truth that stays synchronized with the implementation and surfaces automatically in developer tools and Storybook.
16
+
17
+ ## Naming conventions
18
+
19
+ Clear, descriptive names reduce the need for comments and make code self-documenting. Choose names that reveal intent and follow established patterns.
20
+
21
+ ### Variables and constants
22
+
23
+ - Use `camelCase` for variables: `userName`, `isLoading`, `itemCount`
24
+ - Use descriptive names that reveal purpose: `filteredResults` not `arr`
25
+ - Boolean variables should use `is`, `has`, `should`, or `can` prefixes: `isVisible`, `hasError`, `shouldRender`
26
+ - Use `SCREAMING_SNAKE_CASE` for true constants: `MAX_RETRY_COUNT`, `DEFAULT_TIMEOUT`
27
+ - Avoid single-letter names except for short loops or mathematical operations
28
+ - Use plural names for arrays and collections: `users`, `menuItems`
29
+
30
+ ### Functions and methods
31
+
32
+ - Use `camelCase` for function names: `getUserData`, `calculateTotal`, `handleClick`
33
+ - Start with verbs that describe the action: `get`, `set`, `fetch`, `handle`, `render`, `calculate`
34
+ - Event handlers should use `handle` prefix: `handleSubmit`, `handleClickOutside`
35
+ - Boolean-returning functions should ask a question: `isValidEmail`, `canAccessResource`, `hasPermission`
36
+ - Keep names concise but descriptive: `fetchUserProfile` not `getUserProfileDataFromAPI`
37
+
38
+ ### Components
39
+
40
+ - Use `PascalCase` for component names: `Button`, `UserProfile`, `NavigationMenu`
41
+ - Name folders to match the component: `Button`, `UserProfile`
42
+ - Subsequently, name files within the folder to match the component: `Button.tsx`, `UserProfile.tsx`
43
+ - Use descriptive names that indicate purpose: `SkipToContent`, `RadialProgress`, `Toggle`
44
+ - Avoid generic names like `Component`, `Container`, `Wrapper` without context
45
+
46
+ ## Code comments
47
+
48
+ Comments should explain _why_ code exists, not _what_ it does. Well-named variables and functions handle the "what." Reserve comments for non-obvious decisions, complex logic, and important context.
49
+
50
+ ### When to comment
51
+
52
+ - **Complex logic**: Explain algorithms or non-obvious implementations
53
+
54
+ ```tsx
55
+ // Use binary search for O(log n) performance on sorted arrays
56
+ const index = binarySearch(sortedArray, target);
57
+ ```
58
+
59
+ - **Business logic**: Document requirements or constraints
60
+
61
+ ```tsx
62
+ // Per WCAG 2.2, focus must return to trigger element on close
63
+ previousFocusRef.current?.focus();
64
+ ```
65
+
66
+ - **Workarounds**: Explain temporary fixes or browser-specific code
67
+
68
+ ```tsx
69
+ // Safari doesn't support :focus-visible, fallback to :focus
70
+ // TODO: Remove when Safari 15+ is minimum supported version
71
+ ```
72
+
73
+ - **Non-obvious decisions**: Clarify choices that might seem strange
74
+ ```tsx
75
+ // Delay state update to avoid race condition with async validation
76
+ setTimeout(() => setIsValid(true), 0);
77
+ ```
78
+
79
+ ### When NOT to comment
80
+
81
+ - **Self-explanatory code**: Good names eliminate the need
82
+
83
+ ```tsx
84
+ // ❌ Bad: Comment restates the code
85
+ // Set loading to true
86
+ setIsLoading(true);
87
+
88
+ // ✅ Good: Code is self-documenting
89
+ setIsLoading(true);
90
+ ```
91
+
92
+ - **Commented-out code**: Delete it; Git tracks history
93
+ ```tsx
94
+ // ❌ Bad: Dead code clutters the file
95
+ // const oldImplementation = () => { ... };
96
+ ```
97
+
98
+ ### Comment style
99
+
100
+ - Use `//` for single-line comments, add a space after the `//` before commenting
101
+ - Use `/** */` for JSDoc comments on exports (functions, types, components)
102
+ - Write complete sentences with proper punctuation
103
+ - Keep comments up-to-date when code changes
104
+
105
+ ## API reference
106
+
107
+ Well-documented APIs make components easier to use and understand. Clear prop descriptions and type information help developers implement components correctly without needing to read the source code.
108
+
109
+ ### Props documentation:
110
+
111
+ Add [JSDoc](https://jsdoc.app/) comments to the props to provide additional clarity for what these props do — these comments is used by TypeScript when hovering over a prop, additional it also shows up in the props table of a component's story in Storybook.
112
+
113
+ ```tsx
114
+ export type ButtonProps = {
115
+ /**
116
+ * The visual style variant of the button.
117
+ */
118
+ variant: 'primary' | 'secondary';
119
+
120
+ /**
121
+ * Whether the button is disabled.
122
+ */
123
+ disabled?: boolean;
124
+ };
125
+ ```
126
+
127
+ ### Guidelines:
128
+
129
+ - Full sentence descriptions
130
+ - Start boolean descriptions with "Whether"
131
+ - Document required vs. optional props
132
+ - Include type information
133
+ - Use discretion for whether a comment is needed or not
134
+ - If unsure, include a comment
@@ -0,0 +1,69 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'Formatting',
7
+ title: 'Formatting',
8
+ subtitle: 'Standards for formatting text and content in documentation',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Formatting" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ Consistent formatting makes documentation easier to scan, understand, and implement. These standards ensure our content is predictable and professional across all Gamut components.
17
+
18
+ ## Numbers
19
+
20
+ - Use numerals for all numbers
21
+ - Use commas for thousands: 1,000
22
+
23
+ ## Units of Measurement
24
+
25
+ - Use standard units: px, rem, em, %
26
+ - Include space between number and unit in prose: "16 pixels"
27
+ - No space in code: `16px`, `2rem`
28
+
29
+ ## Lists
30
+
31
+ Lists help break down complex information into digestible pieces. Use them to organize features, steps, or related concepts.
32
+
33
+ ### Bulleted lists:
34
+
35
+ - Use for unordered items
36
+ - Use parallel structure
37
+ - End with periods if items are complete sentences
38
+ - No periods if items are fragments
39
+
40
+ ### Numbered lists:
41
+
42
+ - Use for sequential steps or prioritized items
43
+ - Start each item with a capital letter
44
+
45
+ ## Code Blocks
46
+
47
+ - Use triple backticks (` ``` `) with language identifier (e.g., `tsx`, `javascript`, `css`)
48
+ - Include comments for complex examples
49
+ - Keep examples concise and focused
50
+
51
+ Example:
52
+
53
+ ````
54
+ ```tsx
55
+ <TextButton onClick={handleClick}> Click me </TextButton>
56
+ ```
57
+ ````
58
+
59
+ ## Headings Hierarchy
60
+
61
+ - Start with second-level headings (`<h2>` in HTML, `##` in Markdown). The first level heading is automatically set by the title parameter.
62
+ - Don't skip heading levels. This ensures a logical reading order.
63
+
64
+ ## Whitespace
65
+
66
+ - Use blank lines to separate sections
67
+ - Don't use multiple consecutive blank lines
68
+ - Indent code consistently (2 spaces for TypeScript/TSX)
69
+ - When using tabs, set them to 2 spaces
@@ -0,0 +1,46 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'General principles',
7
+ title: 'General principles',
8
+ subtitle: 'Core principles for writing effective documentation',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/General principles" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ Good documentation does more than describe — it helps people succeed. These principles guide how we write about Gamut components, with a focus on clarity, accessibility, and usefulness. Whether documenting a new component or updating existing content, prioritize being clear about what something does, honest about its limitations, and helpful in showing how to use it effectively. We want to remove barriers and make it easier for designers and developers to do great work. Like our design system itself, this guide is a living document — it will continue to evolve as we add new features and learn from our users.
17
+
18
+ ## Voice and tone
19
+
20
+ - Friendly and conversational: Write as if explaining to a colleague
21
+ - Prefer "we" when a pronoun is needed
22
+ - "You" is acceptable when necessary, e.g., "Use your best judgement"
23
+ - Encouraging without overpromising: Be supportive but realistic
24
+ - Global audience awareness: Avoid idioms, slang, and culturally-specific references
25
+
26
+ ## Inclusivity
27
+
28
+ - Use inclusive language that makes all contributors feel welcome
29
+ - Define terms when first introduced
30
+ - Consider contributors of varying experience levels and roles (designers and developers)
31
+
32
+ ## Transparency
33
+
34
+ - Clearly indicate component status:
35
+ - `current`: Stable, recommended for use
36
+ - `updating`: In progress, API may change
37
+ - `deprecated`: Still supported but slated for deletion — do not use for new work
38
+ - `static`: Reference material, no active development
39
+ - Link to source code and design files (GitHub, Figma)
40
+
41
+ ## Consistency
42
+
43
+ - Use a single term for the same concept, including how it's referred to between the heading, body copy, and code examples.
44
+ - Do not use the same term for 2 different concepts.
45
+ - Maintain consistent component naming across packages
46
+ - Follow established patterns from existing components
@@ -0,0 +1,54 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ import { AboutHeader } from '~styleguide/blocks';
4
+
5
+ export const parameters = {
6
+ id: 'Language and grammar',
7
+ title: 'Language and grammar',
8
+ subtitle: 'Guidelines for language usage and grammar in documentation',
9
+ status: 'static',
10
+ };
11
+
12
+ <Meta title="Meta/Gamut writing guide/Language and grammar" />
13
+
14
+ <AboutHeader {...parameters} />
15
+
16
+ ## Voice
17
+
18
+ Use active voice rather than passive voice — it makes clear who should do what and eliminates ambiguity about responsibilities. Passive voice obscures who handles what and makes documentation harder to follow. E.g. "The component renders..." not "The component is rendered by..."
19
+
20
+ Use imperative mood for instructions: "Add the component" not "You should add the component"
21
+
22
+ ## Tense
23
+
24
+ Use present tense for current functionality — it's the simplest and most direct form of a verb, making writing more clearer. The more conditional or future tense is used, the harder the audience has to work to understand the meaning. E.g. "The `StrokeButton` component accepts a `variant` prop."
25
+
26
+ - Use future tense sparingly, only for confirmed features
27
+ - Avoid past tense except in changelogs or historical context
28
+
29
+ ## Pronouns
30
+
31
+ With active voice and imperative mood, we can often forgo pronouns entirely. However, if a pronoun is still necessary, consider these rules:
32
+
33
+ - Prefer "we" when a pronoun is needed
34
+ - "You" is acceptable when necessary, e.g., "Use your best judgement"
35
+ - Avoid "I/my/me" entirely
36
+
37
+ ## Articles
38
+
39
+ - Use articles (a, an, the) for clarity
40
+ - Omit articles in lists when appropriate for brevity
41
+
42
+ ## Abbreviations and Acronyms
43
+
44
+ - Spell out on first use: "Web Content Accessibility Guidelines (WCAG)"
45
+ - Use abbreviations for common terms in the domain of web design and development:
46
+ - HTML, CSS, API, UI, UX, etc.
47
+ - Avoid uncommon abbreviations without definition
48
+
49
+ ## Capitalization
50
+
51
+ - Sentence case for all headings, buttons, and UI text
52
+ - PascalCase for component names: `MyComponent`, `ButtonGroup`
53
+ - camelCase for props and variables: `onClick`, `backgroundColor`
54
+ - Capitalize proper nouns: Codecademy, Storybook, Figma, GitHub
@@ -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: 'Refencing code',
7
+ title: 'Refencing 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 them, use permalinks instead
23
+ - Values assigned for props or variables: `true`, `15px`, `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 { Button } from '@codecademy/gamut';
37
+ export const Example: React.FC = () => (
38
+ <Button variant="primary">Click me</Button>
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/Animations/About">Animation</LinkTo> folder contains an `About.mdx` file with a table of contents that links 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.
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`).
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,67 +1,32 @@
1
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
@@ -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.
@@ -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.
@@ -3,14 +3,14 @@ import { Meta } from '@storybook/blocks';
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