Skip to content

Commit fa55b78

Browse files
committed
feat(DisplayTransition): add helper
1 parent 2d38183 commit fa55b78

File tree

14 files changed

+1515
-59
lines changed

14 files changed

+1515
-59
lines changed

.changeset/clever-crabs-cover.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 DisplayTransition helper component.

.cursor/rules/coding.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ alwaysApply: true
1313
# Coding rules
1414

1515
- Use named imports from react (like `useCallback`) instead of using the `React` instance. Avoid: `React.useCallback`.
16+
- Prefer stable `useEvent` callbacks when it's possible.

DOCUMENTATION_GUIDELINES.md renamed to .cursor/rules/documentation.mdc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
globs: *.docs.mdx
3+
alwaysApply: false
4+
---
5+
16
# Component Documentation Guidelines
27

38
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.

.cursor/rules/guidelines.mdc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ Specific test: `$ pnpm test -- {TestFileName}`
192192

193193
# Recomendations
194194

195-
- Use `DOCUMENTATION_GUIDELINES.md` for writing documentation for components.
196195
- Use icons from `/src/icons` if they have a required one. If not - use `tabler/icons-react`. If we need to customize the size or color of the icon, then wrap it with `<Icon/>` component and pass all required props there. Do not add any props to the tabler icons directly.
197196

198197
## Form System

.cursor/rules/storybook.mdc

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
globs: *.stories.tsx,*.docs.mdx
3+
alwaysApply: false
4+
---
5+
## Imports
6+
7+
### Stories Files (.stories.tsx)
8+
- Import types: `import type { Meta, StoryObj } from '@storybook/react-vite';`
9+
- Import `StoryFn` for custom template functions
10+
- For interactive tests: `import { within, userEvent } from '@testing-library/react';` or `import { userEvent, within } from 'storybook/test';`
11+
12+
### Documentation Files (.docs.mdx)
13+
- `import { Meta, Canvas, Story, Controls } from '@storybook/addon-docs/blocks';`
14+
- `Meta` - Define meta information with `<Meta of={StoriesImport} />`
15+
- `Canvas` - Display story with code panel
16+
- `Story` - Reference specific story with `<Story of={StoriesImport.StoryName} />`
17+
- `Controls` - Display interactive controls table with `<Controls of={StoriesImport.StoryName} />`
18+
- `ArgTypes` - Display argument types documentation
19+
- `Source` - Show code examples
20+
- Import stories: `import * as ComponentStories from './Component.stories';`
21+
22+
## Meta Configuration
23+
24+
Use `satisfies Meta<typeof Component>` or `as Meta<typeof Component>`:
25+
26+
```tsx
27+
const meta = {
28+
title: 'Category/ComponentName',
29+
component: ComponentName,
30+
subcomponents: { Item: Component.Item }, // For compound components
31+
args: { /* common default args */ },
32+
parameters: { controls: { exclude: baseProps } }, // Exclude base design system props
33+
argTypes: { /* ... */ }
34+
} satisfies Meta<typeof Component>;
35+
36+
export default meta;
37+
```
38+
39+
## ArgTypes Structure
40+
41+
Group by categories with comments:
42+
- `/* Content */` - children, labels, placeholders, icons
43+
- `/* Selection */` - selectedKey, defaultSelectedKey
44+
- `/* Behavior */` - filter, trigger modes, loading states
45+
- `/* Presentation */` - type, theme, size, direction
46+
- `/* State */` - isDisabled, isRequired, isReadOnly, validationState, autoFocus
47+
- `/* Events */` - onPress, onChange, onSelectionChange, onBlur, onFocus
48+
49+
### ArgType Format
50+
51+
```tsx
52+
propName: {
53+
control: { type: 'radio' | 'boolean' | 'text' | 'number' | null },
54+
options: ['option1', 'option2'], // For radio/select
55+
description: 'Clear description',
56+
table: {
57+
defaultValue: { summary: 'value' },
58+
type: { summary: 'string' }
59+
}
60+
}
61+
```
62+
63+
- Use `control: { type: null }` to disable controls (for functions, complex types)
64+
- Use `action: 'event-name'` for event handlers
65+
- Use `action: (e) => ({ type: 'event', data })` for custom action logging
66+
67+
## Stories
68+
69+
### Named Exports (Preferred)
70+
```tsx
71+
export const StoryName = (args) => <Component {...args} />;
72+
```
73+
74+
### Story Objects with CSF3
75+
```tsx
76+
export const StoryName: StoryObj<typeof Component> = {
77+
render: (args) => <Component {...args} />,
78+
args: { /* story-specific args */ },
79+
play: async ({ canvasElement }) => {
80+
// Interactive test
81+
}
82+
};
83+
```
84+
85+
### Templates (Legacy Pattern)
86+
```tsx
87+
const Template: StoryFn<ComponentProps> = (args) => <Component {...args} />;
88+
89+
export const Story = Template.bind({});
90+
Story.args = { /* ... */ };
91+
```
92+
93+
## Testing with Play Functions
94+
95+
```tsx
96+
export const Interactive: StoryObj = {
97+
render: () => { /* ... */ },
98+
play: async ({ canvasElement }) => {
99+
const canvas = within(canvasElement);
100+
const element = canvas.getByRole('button');
101+
await userEvent.click(element);
102+
}
103+
};
104+
```
105+
106+
## MDX Documentation Structure
107+
108+
```mdx
109+
import { Meta, Canvas, Story, Controls } from '@storybook/addon-docs/blocks';
110+
import * as ComponentStories from './Component.stories';
111+
112+
<Meta of={ComponentStories} />
113+
114+
# ComponentName
115+
116+
Component description
117+
118+
## When to Use
119+
- Use case 1
120+
- Use case 2
121+
122+
## Component
123+
124+
<Story of={ComponentStories.Default} />
125+
126+
---
127+
128+
### Properties
129+
130+
<Controls of={ComponentStories.Default} />
131+
132+
### Base Properties
133+
134+
Reference base properties support here.
135+
136+
## Examples
137+
138+
### Example Section
139+
140+
<Story of={ComponentStories.ExampleStory} />
141+
```
142+
143+
## Common Patterns
144+
145+
- Use `baseProps` exclusion for design system props
146+
- Define default `width` in meta `args` for form components
147+
- Create size/state matrix stories to show all variants
148+
- Use `Space` component for layout in template functions
149+
- Export type: `type Story = StoryObj<typeof meta>;`

0 commit comments

Comments
 (0)