-
Notifications
You must be signed in to change notification settings - Fork 440
Asset Browser Modal Component #5607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
294bba0
e8b9693
534ae71
d36999b
8165ec3
e8bc614
2806aa1
5e761d4
c1b5e00
f7fe476
143f9e1
81a0046
de5bb01
d7a9f59
878b2ed
4f26b3f
5243ef3
c896a4e
a969147
cb82c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <template> | ||
| <div class="absolute bottom-2 right-2 flex flex-wrap justify-end gap-1"> | ||
| <span | ||
| v-for="badge in badges" | ||
| :key="badge.label" | ||
| :class=" | ||
| cn( | ||
| 'px-2 py-1 rounded text-xs font-medium uppercase tracking-wider text-white', | ||
| getBadgeColor(badge.type) | ||
| ) | ||
| " | ||
| > | ||
| {{ badge.label }} | ||
| </span> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { cn } from '@/utils/tailwindUtil' | ||
|
|
||
| type AssetBadge = { | ||
| label: string | ||
| type: 'type' | 'base' | 'size' | ||
| } | ||
|
|
||
| defineProps<{ | ||
| badges: AssetBadge[] | ||
| }>() | ||
|
|
||
| function getBadgeColor(type: AssetBadge['type']): string { | ||
| switch (type) { | ||
| case 'type': | ||
| return 'bg-blue-100/90 dark-theme:bg-blue-100/80' | ||
| case 'base': | ||
| return 'bg-success-100/90 dark-theme:bg-success-100/80' | ||
| case 'size': | ||
| return 'bg-stone-100/90 dark-theme:bg-charcoal-700/80' | ||
| default: | ||
| return 'bg-stone-100/90 dark-theme:bg-charcoal-700/80' | ||
| } | ||
| } | ||
| </script> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,178 @@ | ||||||
| import type { Meta, StoryObj } from '@storybook/vue3-vite' | ||||||
|
|
||||||
| import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue' | ||||||
| import { | ||||||
| createMockAssets, | ||||||
| mockAssets | ||||||
| } from '@/platform/assets/fixtures/ui-mock-assets' | ||||||
|
|
||||||
| // Story arguments interface | ||||||
| interface StoryArgs { | ||||||
| nodeType: string | ||||||
| inputName: string | ||||||
| currentValue: string | ||||||
| showLeftPanel?: boolean | ||||||
| } | ||||||
|
|
||||||
| const meta: Meta<StoryArgs> = { | ||||||
| title: 'Platform/Assets/AssetBrowserModal', | ||||||
| component: AssetBrowserModal, | ||||||
| parameters: { | ||||||
| layout: 'fullscreen' | ||||||
| }, | ||||||
| argTypes: { | ||||||
| nodeType: { | ||||||
| control: 'select', | ||||||
| options: ['CheckpointLoaderSimple', 'VAELoader', 'ControlNetLoader'], | ||||||
| description: 'ComfyUI node type for context' | ||||||
| }, | ||||||
| inputName: { | ||||||
| control: 'select', | ||||||
| options: ['ckpt_name', 'vae_name', 'control_net_name'], | ||||||
| description: 'Widget input name' | ||||||
| }, | ||||||
| currentValue: { | ||||||
| control: 'text', | ||||||
| description: 'Current selected asset value' | ||||||
| }, | ||||||
| showLeftPanel: { | ||||||
| control: 'boolean', | ||||||
| description: 'Whether to show the left panel with categories' | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| export default meta | ||||||
| type Story = StoryObj<typeof meta> | ||||||
|
|
||||||
| // Modal Layout Stories | ||||||
| export const Default: Story = { | ||||||
| args: { | ||||||
| nodeType: 'CheckpointLoaderSimple', | ||||||
| inputName: 'ckpt_name', | ||||||
| currentValue: '', | ||||||
| showLeftPanel: false | ||||||
| }, | ||||||
| render: (args) => ({ | ||||||
| components: { AssetBrowserModal }, | ||||||
| setup() { | ||||||
| const onAssetSelect = (asset: any) => { | ||||||
| console.log('Selected asset:', asset) | ||||||
| } | ||||||
| const onClose = () => { | ||||||
| console.log('Modal closed') | ||||||
| } | ||||||
|
|
||||||
| return { | ||||||
| ...args, | ||||||
| onAssetSelect, | ||||||
| onClose, | ||||||
| assets: mockAssets | ||||||
| } | ||||||
| }, | ||||||
| template: ` | ||||||
| <div class="flex items-center justify-center min-h-screen bg-stone-200 dark-theme:bg-stone-200 p-4"> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <AssetBrowserModal | ||||||
| :node-type="nodeType" | ||||||
| :input-name="inputName" | ||||||
| :show-left-panel="showLeftPanel" | ||||||
| :assets="assets" | ||||||
| @asset-select="onAssetSelect" | ||||||
| @close="onClose" | ||||||
| /> | ||||||
| </div> | ||||||
| ` | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| // Story demonstrating single asset type (auto-hides left panel) | ||||||
| export const SingleAssetType: Story = { | ||||||
| args: { | ||||||
| nodeType: 'CheckpointLoaderSimple', | ||||||
| inputName: 'ckpt_name', | ||||||
| currentValue: '', | ||||||
| showLeftPanel: false | ||||||
| }, | ||||||
| render: (args) => ({ | ||||||
| components: { AssetBrowserModal }, | ||||||
| setup() { | ||||||
| const onAssetSelect = (asset: any) => { | ||||||
| console.log('Selected asset:', asset) | ||||||
| } | ||||||
| const onClose = () => { | ||||||
| console.log('Modal closed') | ||||||
| } | ||||||
|
|
||||||
| // Create assets with only one type (checkpoints) | ||||||
| const singleTypeAssets = createMockAssets(15).map((asset) => ({ | ||||||
| ...asset, | ||||||
| type: 'checkpoint' | ||||||
| })) | ||||||
|
|
||||||
| return { ...args, onAssetSelect, onClose, assets: singleTypeAssets } | ||||||
| }, | ||||||
| template: ` | ||||||
| <div class="flex items-center justify-center min-h-screen bg-stone-200 dark-theme:bg-stone-200 p-4"> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and elsewhere. Don't want to confuse the robots with this pattern. |
||||||
| <AssetBrowserModal | ||||||
| :node-type="nodeType" | ||||||
| :input-name="inputName" | ||||||
| :show-left-panel="showLeftPanel" | ||||||
| :assets="assets" | ||||||
| @asset-select="onAssetSelect" | ||||||
| @close="onClose" | ||||||
| /> | ||||||
| </div> | ||||||
| ` | ||||||
| }), | ||||||
| parameters: { | ||||||
| docs: { | ||||||
| description: { | ||||||
| story: | ||||||
| 'Modal with assets of only one type (checkpoint) - left panel auto-hidden.' | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Story with left panel explicitly hidden | ||||||
| export const NoLeftPanel: Story = { | ||||||
| args: { | ||||||
| nodeType: 'CheckpointLoaderSimple', | ||||||
| inputName: 'ckpt_name', | ||||||
| currentValue: '', | ||||||
| showLeftPanel: false | ||||||
| }, | ||||||
| render: (args) => ({ | ||||||
| components: { AssetBrowserModal }, | ||||||
| setup() { | ||||||
| const onAssetSelect = (asset: any) => { | ||||||
| console.log('Selected asset:', asset) | ||||||
| } | ||||||
| const onClose = () => { | ||||||
| console.log('Modal closed') | ||||||
| } | ||||||
|
|
||||||
| return { ...args, onAssetSelect, onClose, assets: mockAssets } | ||||||
| }, | ||||||
| template: ` | ||||||
| <div class="flex items-center justify-center min-h-screen bg-stone-200 dark-theme:bg-stone-200 p-4"> | ||||||
| <AssetBrowserModal | ||||||
| :node-type="nodeType" | ||||||
| :input-name="inputName" | ||||||
| :show-left-panel="showLeftPanel" | ||||||
| :assets="assets" | ||||||
| @asset-select="onAssetSelect" | ||||||
| @close="onClose" | ||||||
| /> | ||||||
| </div> | ||||||
| ` | ||||||
| }), | ||||||
| parameters: { | ||||||
| docs: { | ||||||
| description: { | ||||||
| story: | ||||||
| 'Modal with left panel explicitly disabled via showLeftPanel=false.' | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the filtering above was filtering out tailwind apparently.