Line data Source code
1 5 : <template>
2 5 : <section
3 : :class="
4 : cn(
5 : 'flex items-center justify-between gap-4 rounded-xl border border-border px-5 py-4',
6 : classes?.root
7 : )
8 : "
9 : data-testid="billing-plan-row"
10 : >
11 : <div class="flex min-w-0 flex-col gap-1">
12 : <h3
13 : :class="
14 : cn(
15 : 'm-0 text-sm font-semibold wrap-break-word text-foreground',
16 : classes?.title
17 : )
18 : "
19 : >
20 : {{ text.title }}
21 : </h3>
22 : <p
23 : v-if="text.line"
24 : :class="
25 : cn('m-0 text-sm wrap-break-word text-muted-foreground', classes?.line)
26 : "
27 : data-testid="billing-plan-line"
28 : >
29 : {{ text.line }}
30 : </p>
31 : </div>
32 : <div :class="cn('flex shrink-0 items-center gap-2', classes?.actions)">
33 : <slot name="leading" />
34 : <slot
35 : v-if="action"
36 : name="action"
37 : :action
38 : :label="copy.actions[action]"
39 : :variant="actionVariant"
40 : >
41 : <CheckoutButton
42 : :variant="actionVariant"
43 : size="md"
44 : class="shrink-0"
45 : @click="emit('action', action)"
46 : >
47 : {{ copy.actions[action] }}
48 : <i class="icon-[lucide--arrow-up-right]" aria-hidden="true" />
49 : </CheckoutButton>
50 : </slot>
51 : </div>
52 : </section>
53 : </template>
54 :
55 : <script setup lang="ts">
56 : import { computed } from 'vue'
57 :
58 : import type {
59 : PlanRowAction,
60 : PlanRowState
61 : } from '@comfyorg/account-core/billing'
62 : import { cn } from '@comfyorg/tailwind-utils'
63 :
64 : import CheckoutButton from '#/billing/checkout/CheckoutButton.vue'
65 : import { planRowText } from './planRowCopy'
66 : import type { PlanRowCopy } from './planRowCopy'
67 :
68 : type ActionVariant = 'inverted' | 'secondary'
69 :
70 : const {
71 : state,
72 : action,
73 : copy,
74 : locale,
75 : canManageSubscription,
76 : salesVariant = 'secondary',
77 : addCreditsVariant = 'secondary',
78 : classes
79 : } = defineProps<{
80 : state: PlanRowState
81 : action: PlanRowAction | null
82 : copy: PlanRowCopy
83 : locale: string
84 : canManageSubscription: boolean
85 : salesVariant?: ActionVariant
86 : addCreditsVariant?: ActionVariant
87 : classes?: Partial<Record<'root' | 'title' | 'line' | 'actions', string>>
88 : }>()
89 :
90 5 : const emit = defineEmits<{ action: [action: PlanRowAction] }>()
91 :
92 5 : const text = computed(() =>
93 : planRowText(state, copy, locale, canManageSubscription)
94 : )
95 :
96 5 : const actionVariant = computed<ActionVariant>(() => {
97 5 : if (action === 'contactSales') return salesVariant
98 5 : return action === 'manage' || addCreditsVariant === 'inverted'
99 : ? 'secondary'
100 : : 'inverted'
101 : })
102 : </script>
|