mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-11 08:00:21 +00:00
<img width="373" height="535" alt="스크린샷 2026-03-09 오후 2 48 10" src="https://github.com/user-attachments/assets/7fea3fd4-0d90-4022-ad78-c53e3d5be887" /> ## Summary - Reorganize Select-related stories under `Components/Select/` hierarchy (SingleSelect, MultiSelect, Select) - Add `size` prop (`lg`/`md`) to SingleSelect, MultiSelect, SelectTrigger for Figma Large (40px) / Medium (32px) variants - Add `invalid` prop (red border) to SingleSelect and SelectTrigger - Add `loading` prop (spinner) to SingleSelect - Add `hover:bg-secondary-background-hover` to all select triggers - Align disabled opacity to 30% per Figma spec - Add new stories: Disabled, Invalid, Loading, MediumSize, AllStates ## Test plan - [ ] Verify Storybook renders all stories under `Components/Select/` - [ ] Check hover state visually on all select triggers - [ ] Verify Medium size (32px) renders correctly - [ ] Verify Invalid state shows red border - [ ] Verify Loading state shows spinner - [ ] Verify Disabled state has 30% opacity and no hover effect ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9639-refactor-reorganize-Select-stories-and-add-size-state-variants-31e6d73d36508142b835f04ab6bdaefe) by [Unito](https://www.unito.io) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
220 lines
6.3 KiB
TypeScript
220 lines
6.3 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
import { ref } from 'vue'
|
|
|
|
import MultiSelect from './MultiSelect.vue'
|
|
import SingleSelect from './SingleSelect.vue'
|
|
import type { SelectOption } from './types'
|
|
|
|
const meta: Meta = {
|
|
title: 'Components/Select/SelectDropdown',
|
|
tags: ['autodocs'],
|
|
parameters: { layout: 'padded' },
|
|
decorators: [
|
|
() => ({
|
|
template: '<div class="pt-4"><story /></div>'
|
|
})
|
|
]
|
|
}
|
|
|
|
export default meta
|
|
type Story = StoryObj<typeof meta>
|
|
|
|
const modelOptions: SelectOption[] = [
|
|
{ name: 'ACE-Step', value: 'ace-step' },
|
|
{ name: 'Anima', value: 'anima' },
|
|
{ name: 'BRIA', value: 'bria' },
|
|
{ name: 'ByteDance', value: 'bytedance' },
|
|
{ name: 'Capybara', value: 'capybara' },
|
|
{ name: 'Chatter Box', value: 'chatter-box' },
|
|
{ name: 'Chroma', value: 'chroma' },
|
|
{ name: 'ChronoEdit', value: 'chronoedit' },
|
|
{ name: 'DWPose', value: 'dwpose' },
|
|
{ name: 'Depth Anything v2', value: 'depth-anything-v2' },
|
|
{ name: 'ElevenLabs', value: 'elevenlabs' },
|
|
{ name: 'Flux', value: 'flux' },
|
|
{ name: 'HunyuanVideo', value: 'hunyuan-video' },
|
|
{ name: 'Stable Diffusion', value: 'stable-diffusion' },
|
|
{ name: 'SDXL', value: 'sdxl' }
|
|
]
|
|
|
|
const useCaseOptions: SelectOption[] = [
|
|
{ name: 'Text to Image', value: 'text-to-image' },
|
|
{ name: 'Image to Image', value: 'image-to-image' },
|
|
{ name: 'Inpainting', value: 'inpainting' },
|
|
{ name: 'Upscaling', value: 'upscaling' },
|
|
{ name: 'Video Generation', value: 'video-generation' },
|
|
{ name: 'Audio Generation', value: 'audio-generation' },
|
|
{ name: '3D Generation', value: '3d-generation' }
|
|
]
|
|
|
|
const sortOptions: SelectOption[] = [
|
|
{ name: 'Default', value: 'default' },
|
|
{ name: 'Recommended', value: 'recommended' },
|
|
{ name: 'Popular', value: 'popular' },
|
|
{ name: 'Newest', value: 'newest' },
|
|
{ name: 'VRAM Usage (Low to High)', value: 'vram-low-to-high' },
|
|
{ name: 'Model Size (Low to High)', value: 'model-size-low-to-high' },
|
|
{ name: 'Alphabetical (A-Z)', value: 'alphabetical' }
|
|
]
|
|
|
|
export const ModelFilter: Story = {
|
|
render: () => ({
|
|
components: { MultiSelect },
|
|
setup() {
|
|
const selected = ref<SelectOption[]>([
|
|
modelOptions[1],
|
|
modelOptions[2],
|
|
modelOptions[3]
|
|
])
|
|
return { selected, modelOptions }
|
|
},
|
|
template: `
|
|
<MultiSelect
|
|
v-model="selected"
|
|
:options="modelOptions"
|
|
:label="selected.length === 0 ? 'Models' : selected.length === 1 ? selected[0].name : selected.length + ' Models'"
|
|
show-search-box
|
|
show-selected-count
|
|
show-clear-button
|
|
class="w-[250px]"
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--cpu]" />
|
|
</template>
|
|
</MultiSelect>
|
|
`
|
|
}),
|
|
parameters: { controls: { disable: true } }
|
|
}
|
|
|
|
export const UseCaseFilter: Story = {
|
|
render: () => ({
|
|
components: { MultiSelect },
|
|
setup() {
|
|
const selected = ref<SelectOption[]>([])
|
|
return { selected, useCaseOptions }
|
|
},
|
|
template: `
|
|
<MultiSelect
|
|
v-model="selected"
|
|
:options="useCaseOptions"
|
|
:label="selected.length === 0 ? 'Use Case' : selected.length === 1 ? selected[0].name : selected.length + ' Use Cases'"
|
|
show-search-box
|
|
show-selected-count
|
|
show-clear-button
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--target]" />
|
|
</template>
|
|
</MultiSelect>
|
|
`
|
|
}),
|
|
parameters: { controls: { disable: true } }
|
|
}
|
|
|
|
export const SortDropdown: Story = {
|
|
render: () => ({
|
|
components: { SingleSelect },
|
|
setup() {
|
|
const selected = ref<string | undefined>('default')
|
|
return { selected, sortOptions }
|
|
},
|
|
template: `
|
|
<SingleSelect
|
|
v-model="selected"
|
|
:options="sortOptions"
|
|
label="Sort by"
|
|
class="w-62.5"
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--arrow-up-down] text-muted-foreground" />
|
|
</template>
|
|
</SingleSelect>
|
|
`
|
|
}),
|
|
parameters: { controls: { disable: true } }
|
|
}
|
|
|
|
export const TemplateFilterBar: Story = {
|
|
render: () => ({
|
|
components: { MultiSelect, SingleSelect },
|
|
setup() {
|
|
const selectedModels = ref<SelectOption[]>([
|
|
modelOptions[1],
|
|
modelOptions[2],
|
|
modelOptions[3]
|
|
])
|
|
const selectedUseCases = ref<SelectOption[]>([])
|
|
const sortBy = ref<string | undefined>('default')
|
|
|
|
const modelLabel = () => {
|
|
if (selectedModels.value.length === 0) return 'Models'
|
|
if (selectedModels.value.length === 1)
|
|
return selectedModels.value[0].name
|
|
return selectedModels.value.length + ' Models'
|
|
}
|
|
const useCaseLabel = () => {
|
|
if (selectedUseCases.value.length === 0) return 'Use Case'
|
|
if (selectedUseCases.value.length === 1)
|
|
return selectedUseCases.value[0].name
|
|
return selectedUseCases.value.length + ' Use Cases'
|
|
}
|
|
|
|
return {
|
|
selectedModels,
|
|
selectedUseCases,
|
|
sortBy,
|
|
modelOptions,
|
|
useCaseOptions,
|
|
sortOptions,
|
|
modelLabel,
|
|
useCaseLabel
|
|
}
|
|
},
|
|
template: `
|
|
<div class="flex flex-wrap items-center justify-between gap-2" style="min-width: 700px;">
|
|
<div class="flex flex-wrap gap-2">
|
|
<MultiSelect
|
|
v-model="selectedModels"
|
|
:options="modelOptions"
|
|
:label="modelLabel()"
|
|
show-search-box
|
|
show-selected-count
|
|
show-clear-button
|
|
class="w-[250px]"
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--cpu]" />
|
|
</template>
|
|
</MultiSelect>
|
|
|
|
<MultiSelect
|
|
v-model="selectedUseCases"
|
|
:options="useCaseOptions"
|
|
:label="useCaseLabel()"
|
|
show-search-box
|
|
show-selected-count
|
|
show-clear-button
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--target]" />
|
|
</template>
|
|
</MultiSelect>
|
|
</div>
|
|
|
|
<SingleSelect
|
|
v-model="sortBy"
|
|
:options="sortOptions"
|
|
label="Sort by"
|
|
class="w-62.5"
|
|
>
|
|
<template #icon>
|
|
<i class="icon-[lucide--arrow-up-down] text-muted-foreground" />
|
|
</template>
|
|
</SingleSelect>
|
|
</div>
|
|
`
|
|
}),
|
|
parameters: { controls: { disable: true } }
|
|
}
|