Line data Source code
1 : <template>
2 1997 : <div :class="containerClasses">
3 : <slot name="top"></slot>
4 : <slot name="bottom"></slot>
5 : </div>
6 : </template>
7 :
8 : <script setup lang="ts">
9 : import { computed } from 'vue'
10 :
11 : import { cn } from '@comfyorg/tailwind-utils'
12 :
13 : const {
14 : size = 'regular',
15 : variant = 'default',
16 : rounded = 'md',
17 : customAspectRatio,
18 : hasBorder = true,
19 : hasBackground = true,
20 : hasShadow = true,
21 : hasCursor = true,
22 : class: customClass = ''
23 : } = defineProps<{
24 : size?: 'mini' | 'compact' | 'regular' | 'portrait' | 'tall' | 'auto'
25 : variant?: 'default' | 'ghost' | 'outline'
26 : rounded?: 'none' | 'md' | 'lg' | 'xl'
27 : customAspectRatio?: string
28 : hasBorder?: boolean
29 : hasBackground?: boolean
30 : hasShadow?: boolean
31 : hasCursor?: boolean
32 : class?: string
33 : }>()
34 :
35 2355 : const structureClasses = 'flex flex-col overflow-hidden'
36 :
37 1802 : const roundedClasses = {
38 : none: 'rounded-none',
39 : md: 'rounded',
40 : lg: 'rounded-lg',
41 : xl: 'rounded-xl'
42 : } as const
43 :
44 1802 : const containerClasses = computed(() => {
45 1802 : const variantClasses = {
46 : default: cn(
47 : hasBackground && 'bg-secondary',
48 : hasBorder && 'border border-border',
49 : hasShadow && 'shadow-sm',
50 : hasCursor && 'cursor-pointer'
51 : ),
52 : ghost: cn(
53 : hasCursor && 'cursor-pointer',
54 : 'p-2 transition-colors duration-200'
55 : ),
56 : outline: cn(
57 : hasBorder && 'border-2 border-border/50',
58 : hasCursor && 'cursor-pointer',
59 : 'transition-colors hover:border-border/25'
60 : )
61 : }
62 :
63 1802 : const aspectRatio = customAspectRatio
64 : ? `aspect-[${customAspectRatio}]`
65 : : {
66 : mini: 'aspect-100/120',
67 : compact: 'aspect-240/311',
68 : regular: 'aspect-256/308',
69 : portrait: 'aspect-256/325',
70 : tall: 'aspect-256/353',
71 : auto: ''
72 : }[size]
73 :
74 1802 : return cn(
75 : structureClasses,
76 : roundedClasses[rounded],
77 : variantClasses[variant],
78 : aspectRatio,
79 : customClass
80 : )
81 : })
82 : </script>
|