Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a2ef92b
started foundation for style guide
LinKCoding Oct 24, 2025
be93a53
round out docs
LinKCoding Oct 27, 2025
6acf546
QA'd
LinKCoding Oct 27, 2025
41ac0da
formatted
LinKCoding Oct 27, 2025
5637dea
Update packages/styleguide/src/lib/Meta/Style Guide/Component Pages.mdx
LinKCoding Oct 29, 2025
60f0a66
Update packages/styleguide/src/lib/Meta/Style Guide/Component Pages.mdx
LinKCoding Oct 29, 2025
d094255
Update packages/styleguide/src/lib/Meta/Style Guide/Computer Interfac…
LinKCoding Oct 29, 2025
5a55840
Merge branch 'main' into kl-gmt-157
LinKCoding Oct 29, 2025
70901b8
apply Amy's and Cass's feedback
LinKCoding Oct 29, 2025
bc10713
renaming files
LinKCoding Oct 29, 2025
369bdca
Merge branch 'main' into kl-gmt-157
LinKCoding Nov 10, 2025
94530ee
applied some feedback
LinKCoding Nov 11, 2025
459414b
more feedback
LinKCoding Nov 12, 2025
fe22d3d
more feedback
LinKCoding Nov 12, 2025
2d59049
more feedback and re-org some pages
LinKCoding Nov 13, 2025
e657bb2
re-orged Stories.mdx
LinKCoding Nov 13, 2025
13c5f17
more feedback
LinKCoding Nov 13, 2025
b6ce364
formatted
LinKCoding Nov 13, 2025
14d8a28
more feedback
LinKCoding Nov 13, 2025
fa9464d
more touch ups
LinKCoding Nov 13, 2025
b2b51d2
more clean up
LinKCoding Nov 13, 2025
818c26d
one more sentence casing
LinKCoding Nov 13, 2025
06aa6b0
merged main
LinKCoding Dec 2, 2025
9e5ab02
Merge branch 'main' into kl-gmt-157
LinKCoding Dec 3, 2025
277ac2e
address Cass's feedback
LinKCoding Dec 3, 2025
caa65a9
updated writing guide docs according to feedback and edited sentences…
LinKCoding Dec 4, 2025
78cb3ac
Merge branch 'main' into kl-gmt-157
LinKCoding Dec 4, 2025
ddf2113
Merge branch 'main' into kl-gmt-157
LinKCoding Dec 5, 2025
91f4726
fix import
LinKCoding Dec 5, 2025
dbb5e09
Merge branch 'main' into kl-gmt-157
LinKCoding Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packages/styleguide/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,32 @@ const preview: Preview = {
'Meta',
[
'About',
'Best Practices',
'ESLint rules',
'Brand',
'Best practices',
'Contributing',
'Deep Controls add-on',
'ESLint rules',
'FAQs',
'Installation',
'Stories',
'Usage guide',
'Gamut writing guide',
[
'About',
'General principles',
'Documentation in code',
'Formatting',
'Language and grammar',
'Linking',
'Referencing code',
'Stories',
[
'About',
'About pages',
'Component story documentation',
'Component code examples',
],
],
],
'Foundations',
'Layouts',
Expand Down
10 changes: 5 additions & 5 deletions packages/styleguide/src/lib/Meta/About.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
TableOfContents,
} from '~styleguide/blocks';

import { parameters as bestPracticesParameters } from './Best Practices.mdx';
import { parameters as bestPracticesParameters } from './Best practices.mdx';
import { parameters as brandParameters } from './Brand.mdx';
import { parameters as contributingParameters } from './Contributing.mdx';
import { parameters as deepControlsParameters } from './Deep Controls Add-On.mdx';
import { parameters as deepControlsParameters } from './Deep Controls add-on.mdx';
import { parameters as eslintRulesParameters } from './ESLint rules.mdx';
import { parameters as faqsParameters } from './FAQs.mdx';
import { parameters as gamutWritingGuideParameters } from './Gamut writing guide/About.mdx';
import { parameters as installationParameters } from './Installation.mdx';
import { parameters as storiesParameters } from './Stories.mdx';
import { parameters as usageGuideParameters } from './Usage Guide.mdx';
import { parameters as usageGuideParameters } from './Usage guide.mdx';

export const parameters = {
id: 'Meta',
Expand All @@ -34,7 +34,7 @@ export const parameters = {
deepControlsParameters,
eslintRulesParameters,
faqsParameters,
storiesParameters,
gamutWritingGuideParameters,
brandParameters,
installationParameters,
usageGuideParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Meta } from '@storybook/blocks';
import { AboutHeader, Callout } from '~styleguide/blocks';

export const parameters = {
id: 'Best Practices',
title: 'Best Practices',
id: 'Best practices',
title: 'Best practices',
subtitle: 'Current best practices for using the Gamut Design System',
status: 'current',
};

<Meta title="Meta/Best Practices" />
<Meta title="Meta/Best practices" />

<AboutHeader {...parameters} />

Expand Down
43 changes: 43 additions & 0 deletions packages/styleguide/src/lib/Meta/Gamut writing guide/About.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Meta } from '@storybook/blocks';

import {
AboutHeader,
addParentPath,
LinkTo,
TableOfContents,
} from '~styleguide/blocks';

import { parameters as documentationInCodeParameters } from './Documentation in code.mdx';
import { parameters as formattingParameters } from './Formatting.mdx';
import { parameters as generalPrinciplesParameters } from './General principles.mdx';
import { parameters as languageAndGrammarParameters } from './Language and grammar.mdx';
import { parameters as linkingParameters } from './Linking.mdx';
import { parameters as referencingCodeParameters } from './Referencing code.mdx';
import { parameters as storiesParameters } from './Stories/About.mdx';

export const parameters = {
id: 'Meta/Gamut writing guide',
title: 'Gamut writing guide',
subtitle:
'Guidelines and standards for creating consistent, clear, and effective documentation.',
};

<Meta title="Meta/Gamut writing guide/About" />

<AboutHeader {...parameters} />

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.

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.

<TableOfContents
links={addParentPath(parameters.id, [
generalPrinciplesParameters,
documentationInCodeParameters,
formattingParameters,
languageAndGrammarParameters,
linkingParameters,
referencingCodeParameters,
storiesParameters,
])}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { Meta } from '@storybook/blocks';

import { ComponentHeader } from '~styleguide/blocks';

export const parameters = {
title: 'Documentation in code',
subtitle: `Guidelines for documenting code in Gamut component files`,
status: 'current',
};

<Meta title="Meta/Gamut writing guide/Documentation in code" />

<ComponentHeader {...parameters} />

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.

## Naming conventions

Clear, descriptive names reduce the need for comments and make code self-documenting. Choose names that reveal intent and follow established patterns.

### Variables and constants

- Use `camelCase` for variables: `userName`, `isLoading`, `itemCount`
- Use descriptive names that reveal purpose: `filteredResults` not `arr`
- Boolean variables should use `is`, `has`, `should`, or `can` prefixes: `isVisible`, `hasError`, `shouldRender`
- Use `SCREAMING_SNAKE_CASE` for true constants: `MAX_RETRY_COUNT`, `DEFAULT_TIMEOUT`
- Avoid single-letter names except for short loops or mathematical operations
- Use plural names for arrays and collections: `users`, `menuItems`

### Functions and methods

- Use `camelCase` for function names: `getUserData`, `calculateTotal`, `handleClick`
- Start with verbs that describe the action: `get`, `set`, `fetch`, `handle`, `render`, `calculate`
- Event handlers should use `handle` prefix: `handleSubmit`, `handleClickOutside`
- Boolean-returning functions should ask a question: `isValidEmail`, `canAccessResource`, `hasPermission`
- Keep names concise but descriptive: `fetchUserProfile` not `getUserProfileDataFromAPI`

### Components

- Use `PascalCase` for component names: `Button`, `UserProfile`, `NavigationMenu`
- Name folders to match the component: `Button`, `UserProfile`
- Subsequently, name files within the folder to match the component: `Button.tsx`, `UserProfile.tsx`
- Use descriptive names that indicate purpose: `SkipToContent`, `RadialProgress`, `Toggle`
- Avoid generic names like `Component`, `Container`, `Wrapper` without context

## Code comments

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.

### When to comment

- **Complex logic**: Explain algorithms or non-obvious implementations

```tsx
// Use binary search for O(log n) performance on sorted arrays
const index = binarySearch(sortedArray, target);
```

- **Business logic**: Document requirements or constraints

```tsx
// Per WCAG 2.2, focus must return to trigger element on close
previousFocusRef.current?.focus();
```

- **Workarounds**: Explain temporary fixes or browser-specific code

```tsx
// Safari doesn't support :focus-visible, fallback to :focus
// TODO: Remove when Safari 15+ is minimum supported version
```

- **Non-obvious decisions**: Clarify choices that might seem strange
```tsx
// Delay state update to avoid race condition with async validation
setTimeout(() => setIsValid(true), 0);
```

### When NOT to comment

- **Self-explanatory code**: Good names eliminate the need

```tsx
// ❌ Bad: Comment restates the code
// Set loading to true
setIsLoading(true);

// ✅ Good: Code is self-documenting
setIsLoading(true);
```

- **Commented-out code**: Delete it; Git tracks history
```tsx
// ❌ Bad: Dead code clutters the file
// const oldImplementation = () => { ... };
```

### Comment style

- Use `//` for single-line comments, add a space after the `//` before commenting
- Use `/** */` for JSDoc comments on exports (functions, types, components)
- Write complete sentences with proper punctuation
- Keep comments up-to-date when code changes

## API reference

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.

### Props documentation:

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.

```tsx
export type ButtonProps = {
/**
* The visual style variant of the button.
*/
variant: 'primary' | 'secondary';

/**
* Whether the button is disabled.
*/
disabled?: boolean;
};
```

### Guidelines:

- Full sentence descriptions
- Start boolean descriptions with "Whether"
- Document required vs. optional props
- Include type information
- Use discretion for whether a comment is needed or not
- If unsure, include a comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Meta } from '@storybook/blocks';

import { AboutHeader } from '~styleguide/blocks';

export const parameters = {
id: 'Formatting',
title: 'Formatting',
subtitle: 'Standards for formatting text and content in documentation',
status: 'static',
};

<Meta title="Meta/Gamut writing guide/Formatting" />

<AboutHeader {...parameters} />

Consistent formatting makes documentation easier to scan, understand, and implement. These standards ensure our content is predictable and professional across all Gamut components.

## Numbers

- Use numerals for all numbers
- Use commas for thousands: 1,000

## Units of Measurement

- Use standard units: px, rem, em, %
- Include space between number and unit in prose: "16 pixels"
- No space in code: `16px`, `2rem`

## Lists

Lists help break down complex information into digestible pieces. Use them to organize features, steps, or related concepts.

### Bulleted lists:

- Use for unordered items
- Use parallel structure
- End with periods if items are complete sentences
- No periods if items are fragments

### Numbered lists:

- Use for sequential steps or prioritized items
- Start each item with a capital letter

## Code Blocks

- Use triple backticks (` ``` `) with language identifier (e.g., `tsx`, `javascript`, `css`)
- Include comments for complex examples
- Keep examples concise and focused

Example:

````
```tsx
<TextButton onClick={handleClick}> Click me </TextButton>
```
````

## Headings Hierarchy

- Start with second-level headings (`<h2>` in HTML, `##` in Markdown). The first level heading is automatically set by the title parameter.
- Don't skip heading levels. This ensures a logical reading order.

## Whitespace

- Use blank lines to separate sections
- Don't use multiple consecutive blank lines
- Indent code consistently (2 spaces for TypeScript/TSX)
- When using tabs, set them to 2 spaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Meta } from '@storybook/blocks';

import { AboutHeader } from '~styleguide/blocks';

export const parameters = {
id: 'General principles',
title: 'General principles',
subtitle: 'Core principles for writing effective documentation',
status: 'static',
};

<Meta title="Meta/Gamut writing guide/General principles" />

<AboutHeader {...parameters} />

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.

## Voice and tone

- Friendly and conversational: Write as if explaining to a colleague
- Prefer "we" when a pronoun is needed
- "You" is acceptable when necessary, e.g., "Use your best judgement"
- Encouraging without overpromising: Be supportive but realistic
- Global audience awareness: Avoid idioms, slang, and culturally-specific references

## Inclusivity

- Use inclusive language that makes all contributors feel welcome
- Define terms when first introduced
- Consider contributors of varying experience levels and roles (designers and developers)

## Transparency

- Clearly indicate component status:
- `current`: Stable, recommended for use
- `updating`: In progress, API may change
- `deprecated`: Still supported but slated for deletion — do not use for new work
- `static`: Reference material, no active development
- Link to source code and design files (GitHub, Figma)

## Consistency

- Use a single term for the same concept, including how it's referred to between the heading, body copy, and code examples.
- Do not use the same term for 2 different concepts.
- Maintain consistent component naming across packages
- Follow established patterns from existing components
Loading
Loading