Line data Source code
1 : <script setup lang="ts">
2 : import {
3 : CollapsibleContent,
4 : CollapsibleRoot,
5 : CollapsibleTrigger,
6 : PopoverArrow,
7 : PopoverRoot,
8 : PopoverTrigger
9 : } from 'reka-ui'
10 : import { computed } from 'vue'
11 : import { useI18n } from 'vue-i18n'
12 :
13 : import Button from '@comfyorg/design-system/button/Button'
14 : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
15 : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
16 : import PartnerNodeItem from '@/renderer/extensions/linearMode/PartnerNodeItem.vue'
17 : import { graphCreditsBadges } from '@/systems/badgeSystem'
18 :
19 : defineProps<{ mobile?: boolean }>()
20 :
21 2355 : const { t } = useI18n()
22 72 : const canvasStore = useCanvasStore()
23 :
24 72 : const creditsBadges = computed(() => {
25 80 : const rootGraph = canvasStore.currentGraph?.rootGraph
26 80 : return rootGraph ? graphCreditsBadges(rootGraph) : []
27 : })
28 72 : </script>
29 : <template>
30 80 : <PopoverRoot v-if="mobile && creditsBadges.length">
31 : <PopoverTrigger as-child>
32 : <Button class="mr-2 size-10">
33 : <i class="icon-[lucide--coins] bg-credit" />
34 : </Button>
35 : </PopoverTrigger>
36 : <PopoverContent
37 : side="top"
38 : :side-offset="5"
39 : dismiss-on-viewport-change
40 : class="w-auto overflow-visible rounded-lg border-border/50 p-2 shadow-sm"
41 : >
42 : <section
43 : class="max-h-(--reka-popover-content-available-height) scroll-shadows-background overflow-y-auto"
44 : >
45 0 : <PartnerNodeItem
46 : v-for="{ nodeId, title, price } in creditsBadges"
47 : :key="nodeId"
48 : :title
49 : :price
50 : />
51 : </section>
52 : <PopoverArrow class="fill-background stroke-border/50" />
53 : </PopoverContent>
54 : </PopoverRoot>
55 : <div v-else-if="creditsBadges.length === 1">
56 0 : <PartnerNodeItem
57 : v-for="{ nodeId, title, price } in creditsBadges"
58 : :key="nodeId"
59 : :title
60 : :price
61 : class="border-t border-border/50 pt-2"
62 : />
63 : </div>
64 : <CollapsibleRoot
65 : v-else-if="creditsBadges.length"
66 : v-slot="{ open }"
67 : class="flex max-h-1/2 w-full flex-col"
68 : >
69 : <div class="mb-1 w-full border-b border-border/50" />
70 : <CollapsibleTrigger as-child>
71 : <Button variant="textonly" class="w-full text-sm">
72 : <i class="icon-[lucide--coins] bg-credit" />
73 : {{ t('linearMode.hasCreditCost') }}
74 : <i v-if="open" class="ml-auto icon-[lucide--chevron-up]" />
75 : <i v-else class="ml-auto icon-[lucide--chevron-down]" />
76 : </Button>
77 : </CollapsibleTrigger>
78 : <CollapsibleContent class="scroll-shadows-background overflow-y-auto">
79 0 : <PartnerNodeItem
80 : v-for="{ nodeId, title, price } in creditsBadges"
81 : :key="nodeId"
82 : :title
83 : :price
84 : />
85 : </CollapsibleContent>
86 : </CollapsibleRoot>
87 : </template>
|