feat: more actions in status card

This commit is contained in:
三咲智子 2022-11-24 16:34:05 +08:00
parent 2422c809e0
commit e9c9ecefc8
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
7 changed files with 157 additions and 87 deletions

View file

@ -0,0 +1,18 @@
<script setup lang="ts">
import { dropdownContextKey } from './ctx'
const dropdown = $ref<any>()
provide(dropdownContextKey, {
hide: () => dropdown.hide(),
})
</script>
<template>
<VDropdown v-bind="$attrs" ref="dropdown">
<slot />
<template #popper="scope">
<slot name="popper" v-bind="scope" />
</template>
</VDropdown>
</template>

View file

@ -0,0 +1,22 @@
<script setup lang="ts">
import { dropdownContextKey } from './ctx'
defineProps<{
icon?: string
}>()
const emit = defineEmits(['click'])
const { hide } = inject(dropdownContextKey)!
const handleClick = (evt: MouseEvent) => {
hide()
emit('click', evt)
}
</script>
<template>
<div flex gap-2 items-center cursor-pointer px4 py3 font-700 hover="bg-active" @click="handleClick">
<div v-if="icon" :class="icon" />
<span text-15px><slot /></span>
</div>
</template>

View file

@ -0,0 +1,5 @@
import type { InjectionKey } from 'vue'
export const dropdownContextKey: InjectionKey<{
hide: () => void
}> = Symbol('dropdownContextKey')