1
0
elk/components/common/dropdown/Dropdown.vue

29 lines
564 B
Vue
Raw Normal View History

2022-11-24 17:34:05 +09:00
<script setup lang="ts">
2023-01-03 20:58:08 +09:00
import { InjectionKeyDropdownContext } from '~/constants/symbols'
defineProps<{
placement?: string
}>()
2022-11-24 17:34:05 +09:00
const dropdown = $ref<any>()
const colorMode = useColorMode()
2022-11-24 17:34:05 +09:00
const hide = () => dropdown.hide()
2023-01-03 20:58:08 +09:00
provide(InjectionKeyDropdownContext, {
hide,
})
defineExpose({
hide,
2022-11-24 17:34:05 +09:00
})
</script>
<template>
<VDropdown v-bind="$attrs" ref="dropdown" :class="colorMode.value" :placement="placement || 'auto'">
2022-11-24 17:34:05 +09:00
<slot />
<template #popper="scope">
<slot name="popper" v-bind="scope" />
</template>
</VDropdown>
</template>