mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
2.1 KiB
2.1 KiB
Create a Vue Widget for ComfyUI
Your task is to create a new Vue widget for ComfyUI based on the widget specification: $ARGUMENTS
Instructions
Follow the comprehensive guide in vue-widget-conversion/vue-widget-guide.md to create the widget. This guide contains step-by-step instructions, examples from actual PRs, and best practices.
Key Steps to Follow:
-
Understand the Widget Type
- Analyze what type of widget is needed: $ARGUMENTS
- Identify the data type (string, number, array, object, etc.)
- Determine if it needs special behaviors (execution state awareness, dynamic management, etc.)
-
Component Creation
- Create Vue component in
src/components/graph/widgets/ - REQUIRED: Use PrimeVue components (reference
vue-widget-conversion/primevue-components.md) - Use Composition API with
<script setup> - Implement proper v-model binding with
defineModel
- Create Vue component in
-
Composable Pattern
- Always create widget constructor composable in
src/composables/widgets/ - Only create node-level composable in
src/composables/node/if the widget needs dynamic management - Follow the dual composable pattern explained in the guide
- Always create widget constructor composable in
-
Registration
- Register in
src/scripts/widgets.ts - Use appropriate widget type name
- Register in
-
Testing
- Create unit tests for composables
- Test with actual nodes that use the widget
Important Requirements:
- Always use PrimeVue components - Check
vue-widget-conversion/primevue-components.mdfor available components - Use TypeScript with proper types
- Follow Vue 3 Composition API patterns
- Use Tailwind CSS for styling (no custom CSS unless absolutely necessary)
- Implement proper error handling and validation
- Consider performance (use v-show vs v-if appropriately)
Before Starting:
- First read through the entire guide at
vue-widget-conversion/vue-widget-guide.md - Check existing widget implementations for similar patterns
- Identify which PrimeVue component(s) best fit the widget requirements
Widget Specification to Implement:
$ARGUMENTS
Begin by analyzing the widget requirements and proposing an implementation plan based on the guide.