Line data Source code
1 16 : <template>
2 1 : <div class="flex flex-col gap-1">
3 1 : <CollapsibleRoot
4 : v-for="section in sections"
5 : :key="section.id"
6 : class="overflow-hidden rounded-sm"
7 : :open="expandedSectionId === section.id"
8 : @update:open="onSectionOpenChange(section.id, $event)"
9 : >
10 : <CollapsibleTrigger as-child>
11 : <Button
12 : :data-testid="`section-header-${section.id}`"
13 : :aria-expanded="expandedSectionId === section.id"
14 : :aria-controls="`section-content-${section.id}`"
15 : variant="secondary"
16 : class="w-full justify-between px-6 py-1"
17 : >
18 : <span>
19 : {{ $t(section.labelKey, section.items.length) }}
20 : </span>
21 : <i
22 : :class="
23 : cn(
24 : 'icon-[lucide--chevron-right] text-muted-foreground transition-transform',
25 : expandedSectionId === section.id && 'rotate-90'
26 : )
27 : "
28 : />
29 : </Button>
30 : </CollapsibleTrigger>
31 : <CollapsibleContent
32 : :id="`section-content-${section.id}`"
33 : :data-testid="`section-content-${section.id}`"
34 : class="overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down"
35 : >
36 : <ul class="max-h-25 overflow-y-auto px-6 pt-0.5 pb-1">
37 3 : <li
38 : v-for="item in section.items"
39 : :key="item.id"
40 : class="flex items-center gap-2 rounded-sm py-1"
41 : >
42 : <ShareAssetThumbnail
43 : :name="item.name"
44 : :preview-url="item.preview_url"
45 : @thumbnail-error="
46 : onThumbnailError($event.name, $event.previewUrl)
47 : "
48 : />
49 : <Tooltip :disabled="!item.name">
50 : <TooltipTrigger as-child>
51 : <span class="truncate text-xs text-foreground">
52 : {{ item.name }}
53 : </span>
54 : </TooltipTrigger>
55 : <TooltipContent>{{ item.name }}</TooltipContent>
56 : </Tooltip>
57 : <span
58 : v-if="item.in_library"
59 : class="ml-auto shrink-0 text-xs text-muted-foreground"
60 : >
61 : {{ $t('shareWorkflow.inLibrary') }}
62 : </span>
63 : </li>
64 : </ul>
65 : </CollapsibleContent>
66 : </CollapsibleRoot>
67 : </div>
68 : </template>
69 :
70 : <script setup lang="ts">
71 : import {
72 : CollapsibleContent,
73 : CollapsibleRoot,
74 : CollapsibleTrigger
75 : } from 'reka-ui'
76 :
77 : import type { AssetInfo } from '@comfyorg/ingest-types'
78 : import ShareAssetThumbnail from '@/platform/workflow/sharing/components/ShareAssetThumbnail.vue'
79 : import { useAssetSections } from '@/platform/workflow/sharing/composables/useAssetSections'
80 : import Button from '@comfyorg/design-system/button/Button'
81 : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
82 : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
83 : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
84 : import { cn } from '@comfyorg/tailwind-utils'
85 :
86 : const { items } = defineProps<{
87 : items: AssetInfo[]
88 : }>()
89 :
90 1 : const { sections, expandedSectionId, onSectionOpenChange } = useAssetSections(
91 : () => items
92 : )
93 :
94 0 : function onThumbnailError(name: string, previewUrl: string | null | undefined) {
95 0 : console.warn('[share][assets][thumbnail-error]', {
96 : name,
97 : previewUrl: previewUrl ?? null
98 : })
99 : }
100 : </script>
|