Line data Source code
1 16 : <template>
2 48 : <nav data-testid="publish-nav" class="flex flex-col gap-6 px-3 py-4">
3 : <ol class="flex list-none flex-col p-0">
4 144 : <li
5 : v-for="step in steps"
6 : :key="step.name"
7 : v-auto-animate
8 : :aria-current="isCurrentStep(step.name) ? 'step' : undefined"
9 : :class="
10 : cn(
11 : isProfileCreationFlow &&
12 : step.name === 'finish' &&
13 : 'rounded-lg bg-accent'
14 : )
15 : "
16 : >
17 : <Button
18 : variant="textonly"
19 : size="unset"
20 : :class="
21 : cn(
22 : 'h-10 w-full justify-start rounded-lg px-4 py-3 text-left',
23 : isCurrentStep(step.name) &&
24 : !(isProfileCreationFlow && step.name === 'finish') &&
25 : 'bg-muted'
26 : )
27 : "
28 : @click="$emit('stepClick', step.name)"
29 : >
30 : <Badge
31 : variant="circle"
32 : severity="contrast"
33 : :class="
34 : cn(
35 : 'size-5 border bg-transparent text-xs font-bold',
36 : isCurrentStep(step.name)
37 : ? 'border-foreground bg-foreground'
38 : : isCompletedStep(step.name)
39 : ? 'border-foreground text-foreground'
40 : : 'border-muted-foreground text-muted-foreground'
41 : )
42 : "
43 : >
44 : {{ step.number }}
45 : </Badge>
46 : <span class="truncate text-sm text-foreground">
47 : {{ step.label }}
48 : </span>
49 : </Button>
50 :
51 : <div
52 : v-if="isProfileCreationFlow && step.name === 'finish'"
53 : v-auto-animate
54 : class="flex h-10 w-full items-center rounded-lg bg-muted pl-11 select-none"
55 : >
56 : <span class="truncate text-sm text-foreground">
57 : {{ $t('comfyHubProfile.profileCreationNav') }}
58 : </span>
59 : </div>
60 : </li>
61 : </ol>
62 : </nav>
63 : </template>
64 :
65 : <script setup lang="ts">
66 : import { computed } from 'vue'
67 :
68 : import { vAutoAnimate } from '@formkit/auto-animate/vue'
69 :
70 : import Badge from '@comfyorg/design-system/badge/Badge'
71 : import Button from '@comfyorg/design-system/button/Button'
72 : import type { ComfyHubPublishStep } from '@/platform/workflow/sharing/composables/useComfyHubPublishWizard'
73 : import { cn } from '@comfyorg/tailwind-utils'
74 : import { useI18n } from 'vue-i18n'
75 :
76 : type ComfyHubPrimaryStep = Exclude<ComfyHubPublishStep, 'profileCreation'>
77 :
78 : const { currentStep } = defineProps<{
79 : currentStep: ComfyHubPublishStep
80 : }>()
81 :
82 : defineEmits<{
83 : stepClick: [step: ComfyHubPrimaryStep]
84 : }>()
85 :
86 30 : const { t } = useI18n()
87 :
88 30 : const steps = [
89 : {
90 : name: 'describe' as const,
91 : number: 1,
92 : label: t('comfyHubPublish.stepDescribe')
93 : },
94 : {
95 : name: 'examples' as const,
96 : number: 2,
97 : label: t('comfyHubPublish.stepExamples')
98 : },
99 : { name: 'finish' as const, number: 3, label: t('comfyHubPublish.stepFinish') }
100 : ]
101 :
102 30 : const isProfileCreationFlow = computed(() => currentStep === 'profileCreation')
103 :
104 30 : const currentStepNumber = computed(() => {
105 48 : if (isProfileCreationFlow.value) {
106 1 : return 3
107 : }
108 :
109 48 : return steps.find((step) => step.name === currentStep)?.number ?? 0
110 : })
111 :
112 432 : function isCurrentStep(stepName: ComfyHubPrimaryStep) {
113 432 : return currentStep === stepName
114 : }
115 :
116 97 : function isCompletedStep(stepName: ComfyHubPrimaryStep) {
117 97 : return (
118 : (steps.find((step) => step.name === stepName)?.number ?? 0) <
119 : currentStepNumber.value
120 : )
121 : }
122 : </script>
|