Skip to content

Commit d440c1e

Browse files
authored
feat: add documentation guidelines and new docs (#706)
1 parent 4f4bacb commit d440c1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+9608
-1518
lines changed

.changeset/unlucky-candles-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Add more documentations for various components and concepts.

.storybook/preview.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DocsContainer } from '@storybook/addon-docs';
22
import { configure } from '@storybook/test';
33
import isChromatic from 'chromatic/isChromatic';
44
import { config } from 'react-transition-group';
5+
56
import { Root } from '../src';
67

78
configure({ testIdAttribute: 'data-qa', asyncUtilTimeout: 10000 });
@@ -12,6 +13,30 @@ if (isChromatic()) {
1213
}
1314

1415
export const parameters = {
16+
options: {
17+
storySort: (a, b) => {
18+
// Get story titles/kinds for comparison
19+
const aTitle = a.title || a.kind || '';
20+
const bTitle = b.title || b.kind || '';
21+
22+
// Check if either story is in the 'tasty' section
23+
const aIsTasty =
24+
aTitle.toLowerCase().includes('tasty') || aTitle.startsWith('Tasty');
25+
const bIsTasty =
26+
bTitle.toLowerCase().includes('tasty') || bTitle.startsWith('Tasty');
27+
28+
// Always put 'tasty' section at the top
29+
if (aIsTasty && !bIsTasty) {
30+
return -1;
31+
}
32+
if (bIsTasty && !aIsTasty) {
33+
return 1;
34+
}
35+
36+
// For all other stories, sort alphabetically
37+
return aTitle.localeCompare(bTitle, undefined, { numeric: true });
38+
},
39+
},
1540
docs: {
1641
container: ({ children, context }) => (
1742
<DocsContainer context={context}>
@@ -26,6 +51,10 @@ export const parameters = {
2651
{ name: 'gray', value: 'rgba(243,243,250, 1)' },
2752
],
2853
},
54+
actions: {
55+
// Disable only while the test runner is active
56+
disable: isChromatic() || process.env.NODE_ENV === 'test',
57+
},
2958
};
3059

3160
export const decorators = [

DOCUMENTATION_GUIDELINES.md

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# Component Documentation Guidelines
2+
3+
This guide outlines the standards and structure for documenting components in the Cube UI Kit. Following these guidelines ensures consistency, clarity, and comprehensive coverage of component features.
4+
5+
## Overview
6+
7+
Our component documentation serves multiple purposes:
8+
- Provides clear usage instructions for developers
9+
- Ensures accessibility best practices are communicated
10+
- Documents styling capabilities through the `tasty` style system
11+
- Maintains consistency across all component documentation
12+
13+
## Key Principles
14+
15+
1. **Accessibility First**: Components use React Aria Hooks and documentation should emphasize accessibility features
16+
2. **Style System Integration**: Document `tasty` styling capabilities thoroughly
17+
3. **Practical Examples**: Include real-world usage examples, not just API references
18+
4. **Clear Structure**: Follow the prescribed documentation structure for consistency
19+
20+
## Documentation Structure
21+
22+
Every component documentation file should follow this structure:
23+
24+
```mdx
25+
import { Meta, Canvas, Story, Controls } from '@storybook/blocks';
26+
import { ComponentName } from './ComponentName';
27+
import * as ComponentStories from './ComponentName.stories';
28+
29+
<Meta of={ComponentStories} />
30+
31+
# ComponentName
32+
33+
Brief description of what the component is and its primary purpose.
34+
35+
## When to Use
36+
37+
- Scenario 1 where this component is appropriate
38+
- Scenario 2 where this component is appropriate
39+
- Scenario 3 where this component is appropriate
40+
41+
## Component
42+
43+
<Story of={ComponentStories.Default} />
44+
45+
### Properties
46+
47+
<Controls of={componentStories.Default} />
48+
49+
### Base Properties
50+
51+
Supports [Base properties](/BaseProperties)
52+
53+
### Styling Properties
54+
55+
#### styles
56+
57+
Customizes the root element of the component.
58+
59+
**Sub-elements:**
60+
- `ElementName` - Description of what this element represents
61+
62+
#### [additionalStyles] (if applicable)
63+
64+
Customizes the [specific part] of the component.
65+
66+
**Sub-elements:**
67+
- `SubElementName` - Description of what this sub-element represents
68+
69+
### Style Properties
70+
71+
These properties allow direct style application without using the `styles` prop: `width`, `height`.
72+
73+
### Modifiers
74+
75+
The `mods` property accepts the following modifiers you can override:
76+
77+
| Modifier | Type | Description |
78+
|----------|------|-------------|
79+
| modifierName | `boolean` | Description of what this modifier does |
80+
81+
## Variants
82+
83+
### Types
84+
85+
- `primary` - Description of primary type
86+
- `secondary` - Description of secondary type
87+
88+
### Themes
89+
90+
- `default` - Standard appearance
91+
- `danger` - Used for destructive actions
92+
93+
### Sizes
94+
95+
- `small` - Compact size for dense interfaces
96+
- `medium` - Default size
97+
- `large` - Emphasized size for important actions
98+
99+
## Examples
100+
101+
### Basic Usage
102+
103+
```jsx
104+
<ComponentName arg="something" />
105+
```
106+
107+
### [Additional Examples as needed]
108+
109+
## Accessibility
110+
111+
### Keyboard Navigation
112+
113+
- `Tab` - Moves focus to the component
114+
- `Space/Enter` - Activates the component
115+
- [Additional keyboard shortcuts]
116+
117+
### Screen Reader Support
118+
119+
- Component announces as "[role]" to screen readers
120+
- State changes are announced (e.g., "pressed", "expanded")
121+
- [Additional screen reader considerations]
122+
123+
### ARIA Properties
124+
125+
- `aria-label` - Provides accessible label when no visible label exists
126+
- [Additional ARIA properties]
127+
128+
## Best Practices
129+
130+
1. **Do**: Best practice example
131+
```jsx
132+
<ComponentName label="Clear Label">Content</ComponentName>
133+
```
134+
135+
2. **Don't**: Anti-pattern example
136+
```jsx
137+
<ComponentName>Unclear usage</ComponentName>
138+
```
139+
140+
3. **Accessibility**: Always provide meaningful labels
141+
4. **Performance**: Consider performance implications for specific use cases
142+
143+
## Integration with Forms
144+
145+
[For input components only]
146+
This component supports all [Field properties](/field-properties.md) when used within a Form.
147+
148+
## Suggested Improvements
149+
150+
- Improvement 1: Description of potential enhancement
151+
- Improvement 2: Description of potential enhancement
152+
- Improvement 3: Description of potential enhancement
153+
154+
## Related Components
155+
156+
- [RelatedComponent1](/components/RelatedComponent1) - When to use instead
157+
- [RelatedComponent2](/components/RelatedComponent2) - Complementary component
158+
```
159+
160+
## Specific Guidelines
161+
162+
### 1. Component Description
163+
164+
- Start with a clear, concise description of what the component is
165+
- Follow with scenarios where the component should be used
166+
- Avoid technical implementation details in the introduction
167+
168+
### 2. Properties Documentation
169+
170+
#### Base Properties
171+
- If the component uses `filterBaseProps`, don't list base properties individually
172+
- Instead, include the link: `Supports [Base properties](/base-properties.md)`
173+
- Exception: Always document the `qa` property if it has special behavior
174+
175+
#### Styling Properties
176+
- Document each `styles` or `*Styles` property separately
177+
- For each styling property, list all available tasty sub-elements with descriptions. Count only those sub-elements that are mentioned in tasty styles in the root element inside component and can be overrided by passing an object with a specific key (sub-element name) to `styles` property
178+
- Format: `ElementName` - Description of what this element represents
179+
180+
#### Style Properties
181+
- List all properties that can be used for direct styling (e.g., `width`, `height`, `padding`)
182+
- These are properties that map to `tasty` styles without using the `styles` prop
183+
- Use `src/tasty/styles/list.ts` file to understand how it works.
184+
185+
#### React Aria Properties
186+
- Document all React Aria properties with clear descriptions
187+
- It's acceptable to rewrite React Aria descriptions for clarity
188+
- Focus on practical usage rather than technical implementation
189+
190+
### 3. Examples
191+
192+
- Provide practical, real-world examples written in `jsx` code
193+
- Avoid styling examples unless it demonstrates essential capabilities
194+
- Each example should have a clear purpose and title
195+
- Do not use Storybook's Canvas and Story components for interactive examples
196+
- Each story should describe a usage case
197+
- The more sophisticated component, the more stories we need to cover all cases
198+
199+
### 4. Modifiers
200+
201+
- Document all available modifiers that can be passed via the `mods` property
202+
- Explain how each modifier affects the component's appearance or behavior
203+
- Include any modifier combinations that have special behavior
204+
205+
### 5. Accessibility Section
206+
207+
- Include keyboard navigation patterns
208+
- Document screen reader behavior
209+
- List relevant ARIA properties and their usage
210+
- Provide guidance on ensuring accessible implementations
211+
212+
### 6. Form Integration
213+
214+
For input components (TextInput, Select, DatePicker, etc.):
215+
- Don't duplicate field property documentation
216+
- Include: "This component supports all [Field properties](/field-properties.md) when used within a Form."
217+
218+
### 7. File Naming and Location
219+
220+
- Documentation files use `.docs.mdx` extension
221+
- Place in the same directory as the component
222+
- Naming convention: `ComponentName.tsx``ComponentName.docs.mdx`
223+
224+
## Review Checklist
225+
226+
Before submitting component documentation, ensure:
227+
228+
- [ ] Follows the prescribed structure
229+
- [ ] Includes practical examples with Storybook Stories
230+
- [ ] Documents all styling properties and sub-elements
231+
- [ ] Lists all modifiers with descriptions
232+
- [ ] Includes accessibility information
233+
- [ ] Contains best practices section
234+
- [ ] Has "Suggested Improvements" section
235+
- [ ] Uses correct file naming and location
236+
- [ ] All links use provided placeholder format
237+
- [ ] Style properties are documented separately from styling properties
238+
- [ ] Form integration mentioned for input components
239+
- [ ] Base properties linked, not listed (except `qa`)
240+
- [ ] Tabler (`@tabler/icons-react`) or UI Kit icons are used in examples

0 commit comments

Comments
 (0)