mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
* migration: npm to pnpm Step 1, package and lockfile * migration: npm to pnpm Step 2: docs / LLM instructions * migration: npm to pnpm Step 3: More documentation updates * migration: npm to pnpm Step 4: Even more documentation * migration: npm to pnpm Step 5: GitHub Actions * migration: npm to pnpm Step 6: PNPM installation in actions. This merge is going to be painful. * migration: npm to pnpm Unignore and add pnpm lockfile. * migration: npm to pnpm package-lock.json -> pnpm-lock.yaml * migration: explicit @primeuix/styled, move glob to prod deps * migration: more explicit deps required by the importmap plugin and vite * fix: missed merge artifact * fix: Make sure pnpm is available to install wrangler * migration: pnpm for dev-release.yaml * migration: new setup action version Won't work until that is updated and a new release is cut. * migration: Playwright needs uuid * migration: Add explicit deps for lobehub * chore(version-bump.yaml): change cache from npm to pnpm to optimize package management and improve build performance * migration: install pnpm in version-bump action --------- Co-authored-by: snomiao <snomiao@gmail.com>
4.9 KiB
4.9 KiB
Storybook Development Guidelines for Claude
Quick Commands
pnpm storybook: Start Storybook development serverpnpm build-storybook: Build static Storybookpnpm test:component: Run component tests (includes Storybook components)
Development Workflow for Storybook
-
Creating New Stories:
- Place
*.stories.tsfiles alongside components - Follow the naming pattern:
ComponentName.stories.ts - Use realistic mock data that matches ComfyUI schemas
- Place
-
Testing Stories:
- Verify stories render correctly in Storybook UI
- Test different component states and edge cases
- Ensure proper theming and styling
-
Code Quality:
- Run
pnpm typecheckto verify TypeScript - Run
pnpm lintto check for linting issues - Follow existing story patterns and conventions
- Run
Story Creation Guidelines
Basic Story Structure
import type { Meta, StoryObj } from '@storybook/vue3'
import ComponentName from './ComponentName.vue'
const meta: Meta<typeof ComponentName> = {
title: 'Category/ComponentName',
component: ComponentName,
parameters: {
layout: 'centered' // or 'fullscreen', 'padded'
}
}
export default meta
type Story = StoryObj<typeof meta>
export const Default: Story = {
args: {
// Component props
}
}
Mock Data Patterns
For ComfyUI components, use realistic mock data:
// Node definition mock
const mockNodeDef = {
input: {
required: {
prompt: ["STRING", { multiline: true }]
}
},
output: ["CONDITIONING"],
output_is_list: [false],
category: "conditioning"
}
// Component instance mock
const mockComponent = {
id: "1",
type: "CLIPTextEncode",
// ... other properties
}
Common Story Variants
Always include these story variants when applicable:
- Default: Basic component with minimal props
- WithData: Component with realistic data
- Loading: Component in loading state
- Error: Component with error state
- LongContent: Component with edge case content
- Empty: Component with no data
Storybook-Specific Code Patterns
Store Access
// In stories, access stores through the setup function
export const WithStore: Story = {
render: () => ({
setup() {
const store = useMyStore()
return { store }
},
template: '<MyComponent :data="store.data" />'
})
}
Event Testing
export const WithEvents: Story = {
args: {
onUpdate: fn() // Use Storybook's fn() for action logging
}
}
Configuration Notes
Vue App Setup
The Storybook preview is configured with:
- Pinia stores initialized
- PrimeVue with ComfyUI theme
- i18n internationalization
- All necessary CSS imports
Build Configuration
- Vite integration with proper alias resolution
- Manual chunking for better performance
- TypeScript support with strict checking
- CSS processing for Vue components
Troubleshooting
Common Issues
- Import Errors: Verify
@/alias is working correctly - Missing Styles: Ensure CSS imports are in
preview.ts - Store Errors: Check store initialization in setup
- Type Errors: Use proper TypeScript types for story args
Debug Commands
# Check TypeScript issues
pnpm typecheck
# Lint Storybook files
pnpm lint .storybook/
# Build to check for production issues
pnpm build-storybook
File Organization
.storybook/
├── main.ts # Core configuration
├── preview.ts # Global setup and decorators
├── README.md # User documentation
└── CLAUDE.md # This file - Claude guidelines
src/
├── components/
│ └── MyComponent/
│ ├── MyComponent.vue
│ └── MyComponent.stories.ts
Integration with ComfyUI
Available Context
Stories have access to:
- All ComfyUI stores (widgetStore, colorPaletteStore, etc.)
- PrimeVue components with ComfyUI theming
- Internationalization system
- ComfyUI CSS variables and styling
Testing Components
When testing ComfyUI-specific components:
- Use realistic node definitions and data structures
- Test with different node types (sampling, conditioning, etc.)
- Verify proper CSS theming and dark/light modes
- Check component behavior with various input combinations
Performance Considerations
- Use manual chunking for large dependencies
- Minimize bundle size by avoiding unnecessary imports
- Leverage Storybook's lazy loading capabilities
- Profile build times and optimize as needed
Best Practices
- Keep Stories Focused: Each story should demonstrate one specific use case
- Use Descriptive Names: Story names should clearly indicate what they show
- Document Complex Props: Use JSDoc comments for complex prop types
- Test Edge Cases: Create stories for unusual but valid use cases
- Maintain Consistency: Follow established patterns in existing stories