-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
SpecRunnerDropdown.vue
75 lines (70 loc) · 2.08 KB
/
SpecRunnerDropdown.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<Popover
:key="`${props.disabled}`"
class="bg-white rounded border-1px border-gray-100 h-32px relative"
#="{ open, close }"
>
<PopoverButton
class="border-transparent rounded flex-grow h-full border-1px px-12px group"
:class="{
'hocus-default': !props.disabled,
'opacity-50 cursor-auto': props.disabled,
}"
:disabled="props.disabled"
>
<div
class="flex gap-8px items-center"
:class="{
'group-hocus:text-indigo-600': !props.disabled,
'text-indigo-600': open,
'text-gray-600': !open,
}"
>
<slot
name="heading"
:open="open"
:close="close"
/>
<i-cy-chevron-down
class="transform transition-all w-10px duration-300"
:class="{
'group-hocus:icon-dark-indigo-500': !props.disabled,
'icon-dark-gray-200': !open,
'rotate-180 icon-dark-indigo-500': open,
}"
/>
</div>
</PopoverButton>
<TransitionQuickFade>
<PopoverPanel
static
class="bg-white rounded shadow-dropdown top-36px z-10 absolute"
:class="{'hidden': !open, 'right-0': align === 'right', 'left-0': align === 'left'}"
>
<ul
v-if="props.variant !== 'panel'"
class="flex flex-col"
>
<slot />
</ul>
<slot v-else />
</PopoverPanel>
</TransitionQuickFade>
</Popover>
</template>
<script lang="ts" setup>
import TransitionQuickFade from '@cy/components/transitions/TransitionQuickFade.vue'
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
const props = withDefaults(defineProps<{
variant?: 'panel'
align?: 'left' | 'right'
// The disabled prop is used as the Popover key so that changes to the prop
// cause the Popover component to mount again. This re-mounting ensures that
// the PopoverPanel is closed if an enabled dropdown later becomes disabled.
disabled?: boolean
}>(), {
variant: undefined,
align: 'right',
disabled: false,
})
</script>