Line data Source code
1 : <template>
2 31 : <div role="radiogroup" v-bind="$attrs" :class="cn('flex flex-col', gapClass)">
3 62 : <Button
4 : v-for="option in viewTypeOptions"
5 : :key="option.value.toString()"
6 : role="radio"
7 : :aria-checked="modelValue === option.value"
8 : :class="
9 : cn(
10 : 'flex self-stretch py-2 pr-4 pl-2 hover:bg-secondary',
11 : heightClass,
12 : modelValue === option.value && 'bg-secondary'
13 : )
14 : "
15 : variant="textonly"
16 : @click="
17 : modelValue !== option.value && emit('update:modelValue', option.value)
18 : "
19 : >
20 : <div
21 : class="flex size-8 min-h-8 items-center justify-center rounded-lg bg-accent"
22 : >
23 : <i :class="option.icon" aria-hidden="true" />
24 : </div>
25 : <div class="mx-2 flex flex-1 flex-col items-start">
26 : <span class="text-sm font-medium text-foreground">
27 : {{ option.title }}
28 : </span>
29 : <span class="text-xs text-muted-foreground">
30 : {{ option.subtitle }}
31 : </span>
32 : </div>
33 : <i
34 : v-if="modelValue === option.value"
35 : class="icon-[lucide--check] text-foreground"
36 : aria-hidden="true"
37 : />
38 : </Button>
39 : </div>
40 : </template>
41 :
42 : <script setup lang="ts">
43 : import Button from '@comfyorg/design-system/button/Button'
44 : import { cn } from '@comfyorg/tailwind-utils'
45 : import { useI18n } from 'vue-i18n'
46 :
47 25 : const { t } = useI18n()
48 :
49 : const { size = 'md' } = defineProps<{
50 : modelValue: boolean
51 : size?: 'sm' | 'md'
52 : }>()
53 :
54 25 : const emit = defineEmits<{
55 : 'update:modelValue': [value: boolean]
56 : }>()
57 :
58 25 : const viewTypeOptions = [
59 : {
60 : value: true,
61 : icon: 'icon-[lucide--app-window]',
62 : title: t('builderToolbar.app'),
63 : subtitle: t('builderToolbar.appDescription')
64 : },
65 : {
66 : value: false,
67 : icon: 'icon-[comfy--workflow]',
68 : title: t('builderToolbar.nodeGraph'),
69 : subtitle: t('builderToolbar.nodeGraphDescription')
70 : }
71 : ]
72 25 : const heightClass = size === 'sm' ? 'h-12' : 'h-14'
73 25 : const gapClass = size === 'sm' ? 'gap-1' : 'gap-2'
74 : </script>
|