refactor(components): hoverContainer组件属性调整

This commit is contained in:
Soybean
2021-11-17 14:00:57 +08:00
parent 9c7bdb67b7
commit 4642ee62a3
8 changed files with 22 additions and 21 deletions

View File

@ -2,34 +2,37 @@
<div v-if="showTooltip">
<n-tooltip :placement="placement" trigger="hover">
<template #trigger>
<div class="flex-center h-full cursor-pointer hover:bg-[#f6f6f6] dark:hover:bg-[#333]">
<div class="flex-center h-full cursor-pointer hover:bg-[#f6f6f6] dark:hover:bg-[#333]" :class="contentClass">
<slot></slot>
</div>
</template>
{{ content }}
{{ tooltipContent }}
</n-tooltip>
</div>
<div v-else class="flex-center cursor-pointer hover:bg-[#f6f6f6] dark:hover:bg-[#333]">
<div v-else class="flex-center cursor-pointer hover:bg-[#f6f6f6] dark:hover:bg-[#333]" :class="contentClass">
<slot></slot>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { NTooltip } from 'naive-ui';
import type { FollowerPlacement } from 'vueuc';
interface Props {
/** 是否显示tooltip */
showTooltip?: boolean;
/** tooltip显示文本 */
tooltipContent?: string;
/** tooltip的位置 */
placement?: FollowerPlacement;
/** tooltip显示文本 */
content?: string;
/** class类 */
contentClass?: string;
}
withDefaults(defineProps<Props>(), {
showTooltip: true,
const props = withDefaults(defineProps<Props>(), {
tooltipContent: '',
placement: 'bottom',
content: ''
contentClass: ''
});
const showTooltip = computed(() => Boolean(props.tooltipContent));
</script>
<style scoped></style>