Line data Source code
1 : <template>
2 6 : <Dialog :open="true" @update:open="(value) => !value && emit('skip')">
3 : <DialogPortal>
4 : <DialogOverlay data-testid="coach-landing-overlay" class="bg-black/60" />
5 : <DialogContent
6 : data-testid="coach-landing"
7 : class="w-200 max-w-[calc(100vw-2.5rem)] overflow-hidden bg-secondary p-0 shadow-2xl md:h-fit md:min-h-100 md:max-w-200 md:flex-row"
8 : @pointer-down-outside.prevent
9 : @open-auto-focus="onOpenAutoFocus"
10 : >
11 : <DialogClose :aria-label="$t('g.close')" as-child>
12 : <Button
13 : variant="muted-textonly"
14 : size="icon"
15 : :aria-label="t('g.close')"
16 : class="absolute top-3 right-3 z-20"
17 : >
18 : <i class="icon-[lucide--x]" />
19 : </Button>
20 : </DialogClose>
21 : <div
22 : class="flex aspect-video items-center justify-center bg-background md:aspect-auto md:w-1/2"
23 : >
24 : <img
25 : v-if="image"
26 : :src="image"
27 : alt=""
28 : class="size-full object-cover"
29 : />
30 : </div>
31 : <div
32 : class="flex flex-col items-start justify-between self-stretch px-15 pt-15 pb-10 md:w-1/2"
33 : >
34 : <div class="flex flex-col gap-2.5">
35 : <DialogTitle class="m-0 text-[28px] leading-normal font-medium">
36 : {{ title }}
37 : </DialogTitle>
38 : <DialogDescription
39 : class="flex flex-col items-start gap-2 self-stretch text-base/5"
40 : >
41 : {{ message }}
42 : </DialogDescription>
43 : </div>
44 : <div class="flex w-full items-center justify-end gap-2">
45 : <Button variant="secondary" size="lg" @click="emit('skip')">
46 : {{ skipLabel }}
47 : </Button>
48 : <Button
49 : ref="startButtonRef"
50 : variant="inverted"
51 : size="lg"
52 : class="grow"
53 : :disabled="waitingForTarget"
54 : @click="emit('start')"
55 : >
56 : {{ primaryLabel }}
57 : </Button>
58 : </div>
59 : </div>
60 : </DialogContent>
61 : </DialogPortal>
62 : </Dialog>
63 : </template>
64 :
65 : <script setup lang="ts">
66 : import { useEventListener } from '@vueuse/core'
67 : import { useTemplateRef } from 'vue'
68 : import { useI18n } from 'vue-i18n'
69 :
70 : import Dialog from '@comfyorg/design-system/dialog/Dialog'
71 : import DialogClose from '@comfyorg/design-system/dialog/DialogClose'
72 : import DialogContent from '@comfyorg/design-system/dialog/DialogContent'
73 : import DialogDescription from '@comfyorg/design-system/dialog/DialogDescription'
74 : import DialogOverlay from '@comfyorg/design-system/dialog/DialogOverlay'
75 : import DialogPortal from '@comfyorg/design-system/dialog/DialogPortal'
76 : import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle'
77 : import Button from '@comfyorg/design-system/button/Button'
78 :
79 : const { title, message, image, primaryLabel, skipLabel, waitingForTarget } =
80 : defineProps<{
81 : title: string
82 : message: string
83 : image?: string
84 : primaryLabel: string
85 : skipLabel: string
86 : waitingForTarget: boolean
87 : }>()
88 :
89 6 : const emit = defineEmits<{
90 : start: []
91 : skip: []
92 : }>()
93 :
94 6 : const { t } = useI18n()
95 :
96 : // The global keybinding handler preventDefaults Escape before Reka's
97 : // DismissableLayer sees it, so Reka skips its own dismiss; do it explicitly.
98 6 : useEventListener(document, 'keydown', (e) => {
99 1 : if (e.key === 'Escape') emit('skip')
100 : })
101 :
102 6 : const startButtonRef = useTemplateRef('startButtonRef')
103 :
104 : // Land focus on the primary action, not the close button Reka would pick.
105 6 : function onOpenAutoFocus(event: Event) {
106 6 : event.preventDefault()
107 : const el = startButtonRef.value?.$el as HTMLButtonElement | undefined
108 6 : el?.focus()
109 : }
110 : </script>
|