Line data Source code
1 5 : <template>
2 0 : <div
3 : :class="cn('@container', classes?.root)"
4 : :data-testid="`billing-banner-${view.kind}`"
5 : >
6 : <div
7 : role="status"
8 : :class="
9 : cn(
10 : 'flex flex-col gap-3 rounded-xl border border-border bg-background',
11 : look.windowBreakpoint
12 : ? 'sm:flex-row sm:items-center sm:gap-2'
13 : : '@2xl:flex-row @2xl:items-center @2xl:gap-2',
14 : look.roomy ? 'p-4' : 'p-3',
15 : classes?.panel
16 : )
17 : "
18 : >
19 : <div
20 : :class="
21 : cn(
22 : 'flex min-w-0 flex-1 flex-col',
23 : look.roomy ? 'gap-1' : 'gap-2',
24 : classes?.text
25 : )
26 : "
27 : >
28 : <div class="flex items-center gap-2">
29 : <i
30 : :class="
31 : cn(
32 : look.muted
33 : ? 'icon-[lucide--circle-alert] text-muted-foreground'
34 : : 'icon-[lucide--triangle-alert] text-warning',
35 : classes?.icon
36 : )
37 : "
38 : aria-hidden="true"
39 : data-testid="billing-banner-icon"
40 : />
41 : <span :class="cn('text-sm text-foreground', classes?.title)">
42 : {{ view.title }}
43 : </span>
44 : </div>
45 : <p :class="cn('m-0 pl-6 text-sm text-muted-foreground', classes?.body)">
46 : {{ view.body }}
47 : </p>
48 : </div>
49 : <div
50 : v-if="look.dismissKey !== null || look.action"
51 : :class="
52 : cn(
53 : 'flex shrink-0 flex-wrap items-center gap-2 pl-6',
54 : look.windowBreakpoint ? 'sm:pl-0' : '@2xl:pl-0',
55 : classes?.actions
56 : )
57 : "
58 : >
59 : <slot
60 : v-if="look.dismissKey !== null"
61 : name="dismiss"
62 : :dismiss-key="look.dismissKey"
63 : :label="copy.dismiss"
64 : >
65 : <CheckoutButton
66 : variant="textonly"
67 : :size
68 : @click="emit('dismiss', look.dismissKey)"
69 : >
70 : {{ copy.dismiss }}
71 : </CheckoutButton>
72 : </slot>
73 : <slot
74 : v-if="look.action"
75 : name="action"
76 : :action="look.action"
77 : :href="look.href"
78 : :label="copy.actions[look.action]"
79 : :variant="actionVariant"
80 : >
81 : <BillingBannerActionButton
82 : :href="look.href"
83 : :label="copy.actions[look.action]"
84 : :variant="actionVariant"
85 : :size
86 : :loading
87 : @click="emit('action', look.action)"
88 : />
89 : </slot>
90 : </div>
91 : </div>
92 : </div>
93 : </template>
94 :
95 : <script setup lang="ts">
96 : import { computed } from 'vue'
97 :
98 : import { cn } from '@comfyorg/tailwind-utils'
99 :
100 : import CheckoutButton from '#/billing/checkout/CheckoutButton.vue'
101 :
102 : import BillingBannerActionButton from './BillingBannerActionButton.vue'
103 : import { billingBannerLook } from './billingBannerView'
104 : import type {
105 : BillingBannerAction,
106 : BillingBannerCopy,
107 : BillingBannerView
108 : } from './billingBannerView'
109 :
110 : type ActionVariant = 'inverted' | 'secondary'
111 :
112 : const {
113 : view,
114 : copy,
115 : loading = false,
116 : addCreditsVariant = 'secondary',
117 : classes
118 : } = defineProps<{
119 : view: BillingBannerView
120 : copy: Pick<BillingBannerCopy, 'dismiss' | 'actions'>
121 : loading?: boolean
122 : addCreditsVariant?: ActionVariant
123 : classes?: Partial<
124 : Record<
125 : 'root' | 'panel' | 'text' | 'icon' | 'title' | 'body' | 'actions',
126 : string
127 : >
128 : >
129 : }>()
130 :
131 0 : const emit = defineEmits<{
132 : action: [action: BillingBannerAction]
133 : dismiss: [dismissKey: string]
134 : }>()
135 :
136 0 : const look = computed(() => billingBannerLook(view))
137 :
138 0 : const size = computed(() => (look.value.roomy ? 'lg' : 'md'))
139 :
140 0 : const actionVariant = computed<ActionVariant>(() =>
141 : look.value.action === 'addCredits' ? addCreditsVariant : 'inverted'
142 : )
143 : </script>
|