@codecademy/styleguide 79.2.4-alpha.b2bca8.0 → 79.2.4-alpha.be71e3.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/ImageWrapper.tsx +2 -4
- package/.storybook/preview.ts +22 -2
- package/CHANGELOG.md +1 -1
- package/package.json +2 -2
- package/src/lib/Meta/About.mdx +5 -5
- package/src/lib/Meta/{Best Practices.mdx → Best practices.mdx } +3 -3
- package/src/lib/Meta/Gamut writing guide/About.mdx +43 -0
- package/src/lib/Meta/Gamut writing guide/Documentation in code.mdx +134 -0
- package/src/lib/Meta/Gamut writing guide/Formatting.mdx +69 -0
- package/src/lib/Meta/Gamut writing guide/General principles.mdx +46 -0
- package/src/lib/Meta/Gamut writing guide/Language and grammar.mdx +54 -0
- package/src/lib/Meta/Gamut writing guide/Linking.mdx +60 -0
- package/src/lib/Meta/Gamut writing guide/Referencing code.mdx +86 -0
- package/src/lib/Meta/Gamut writing guide/Stories/About pages.mdx +49 -0
- package/src/lib/Meta/Gamut writing guide/Stories/About.mdx +57 -0
- package/src/lib/Meta/Gamut writing guide/Stories/Component code examples.mdx +79 -0
- package/src/lib/Meta/{Stories.mdx → Gamut writing guide/Stories/Component story documentation.mdx } +19 -85
- package/src/lib/Meta/{Usage Guide.mdx → Usage guide.mdx } +3 -3
- package/src/lib/Molecules/Tips/InfoTip/InfoTip.mdx +1 -1
- package/src/lib/Organisms/BarChart/BarChart.mdx +0 -463
- package/src/lib/Organisms/BarChart/BarChart.stories.tsx +0 -352
- package/src/static/organisms/barchart.png +0 -0
- /package/src/lib/Meta/{Deep Controls Add-On.mdx → Deep Controls add-on.mdx} +0 -0
|
@@ -3,9 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
|
|
5
5
|
interface ImageWrapperProps {
|
|
6
|
-
alt: string;
|
|
7
|
-
height: number | string;
|
|
8
6
|
src: string;
|
|
7
|
+
alt: string;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
const StyledImage = styled.img`
|
|
@@ -16,13 +15,12 @@ const StyledImage = styled.img`
|
|
|
16
15
|
export const ImageWrapper: React.FC<ImageWrapperProps & BoxProps> = ({
|
|
17
16
|
src,
|
|
18
17
|
alt,
|
|
19
|
-
height = '216px',
|
|
20
18
|
...props
|
|
21
19
|
}) => {
|
|
22
20
|
return (
|
|
23
21
|
<Box
|
|
24
22
|
width={'100%'}
|
|
25
|
-
height=
|
|
23
|
+
height="216px"
|
|
26
24
|
display="flex"
|
|
27
25
|
justifyContent={'center'}
|
|
28
26
|
alignItems="center"
|
package/.storybook/preview.ts
CHANGED
|
@@ -45,15 +45,35 @@ const preview: Preview = {
|
|
|
45
45
|
'Meta',
|
|
46
46
|
[
|
|
47
47
|
'About',
|
|
48
|
-
'
|
|
48
|
+
'Brand',
|
|
49
|
+
'Best practices',
|
|
49
50
|
'Contributing',
|
|
51
|
+
'Deep Controls add-on',
|
|
50
52
|
'ESLint rules',
|
|
51
53
|
'FAQs',
|
|
52
54
|
'Logical and physical CSS properties',
|
|
53
55
|
'Stories',
|
|
54
56
|
'Brand',
|
|
55
57
|
'Installation',
|
|
56
|
-
'
|
|
58
|
+
'Stories',
|
|
59
|
+
'Usage guide',
|
|
60
|
+
'Gamut writing guide',
|
|
61
|
+
[
|
|
62
|
+
'About',
|
|
63
|
+
'General principles',
|
|
64
|
+
'Documentation in code',
|
|
65
|
+
'Formatting',
|
|
66
|
+
'Language and grammar',
|
|
67
|
+
'Linking',
|
|
68
|
+
'Referencing code',
|
|
69
|
+
'Stories',
|
|
70
|
+
[
|
|
71
|
+
'About',
|
|
72
|
+
'About pages',
|
|
73
|
+
'Component story documentation',
|
|
74
|
+
'Component code examples',
|
|
75
|
+
],
|
|
76
|
+
],
|
|
57
77
|
'MCP',
|
|
58
78
|
],
|
|
59
79
|
'Foundations',
|
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.2.4-alpha.
|
|
6
|
+
### [79.2.4-alpha.be71e3.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.2.3...@codecademy/styleguide@79.2.4-alpha.be71e3.0) (2026-03-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @codecademy/styleguide
|
|
9
9
|
|
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.2.4-alpha.
|
|
4
|
+
"version": "79.2.4-alpha.be71e3.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": "
|
|
11
|
+
"gitHead": "2e9c68bed64860f8e8bf8961128a6d6e1a7f5376"
|
|
12
12
|
}
|
package/src/lib/Meta/About.mdx
CHANGED
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
TableOfContents,
|
|
7
7
|
} from '~styleguide/blocks';
|
|
8
8
|
|
|
9
|
-
import { parameters as bestPracticesParameters } from './Best
|
|
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
|
|
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 logicalPhysicalParameters } from './Logical and physical CSS properties.mdx';
|
|
17
18
|
import { parameters as mcpAboutParameters } from './MCP/About.mdx';
|
|
18
|
-
import { parameters as
|
|
19
|
-
import { parameters as usageGuideParameters } from './Usage Guide.mdx';
|
|
19
|
+
import { parameters as usageGuideParameters } from './Usage guide.mdx';
|
|
20
20
|
|
|
21
21
|
export const parameters = {
|
|
22
22
|
id: 'Meta',
|
|
@@ -36,9 +36,9 @@ export const parameters = {
|
|
|
36
36
|
deepControlsParameters,
|
|
37
37
|
eslintRulesParameters,
|
|
38
38
|
faqsParameters,
|
|
39
|
+
gamutWritingGuideParameters,
|
|
39
40
|
installationParameters,
|
|
40
41
|
logicalPhysicalParameters,
|
|
41
|
-
storiesParameters,
|
|
42
42
|
brandParameters,
|
|
43
43
|
usageGuideParameters,
|
|
44
44
|
mcpAboutParameters,
|
|
@@ -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
|
|
7
|
-
title: 'Best
|
|
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
|
|
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 { AboutHeader } 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: 'static',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
<Meta title="Meta/Gamut writing guide/Documentation in code" />
|
|
12
|
+
|
|
13
|
+
<AboutHeader {...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 helpfulness. Whether documenting a new component or updating existing content, prioritize being clear about what something does and honest about its limitations, accessible to the users who will interact with it, 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: '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 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"
|