2023-11-17 08:45:00 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { PopoverPlacement } from 'naive-ui';
|
2024-06-01 16:53:08 +08:00
|
|
|
import { twMerge } from 'tailwind-merge';
|
2023-11-17 08:45:00 +08:00
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
name: 'ButtonIcon',
|
|
|
|
inheritAttrs: false
|
|
|
|
});
|
|
|
|
|
2023-12-14 21:45:29 +08:00
|
|
|
interface Props {
|
|
|
|
/** Button class */
|
|
|
|
class?: string;
|
|
|
|
/** Iconify icon name */
|
|
|
|
icon?: string;
|
|
|
|
/** Tooltip content */
|
|
|
|
tooltipContent?: string;
|
|
|
|
/** Tooltip placement */
|
|
|
|
tooltipPlacement?: PopoverPlacement;
|
2024-03-27 22:32:35 +08:00
|
|
|
zIndex?: number;
|
2023-12-14 21:45:29 +08:00
|
|
|
}
|
|
|
|
|
2024-01-25 23:24:35 +08:00
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2024-06-01 16:53:08 +08:00
|
|
|
class: '',
|
2024-01-25 23:24:35 +08:00
|
|
|
icon: '',
|
|
|
|
tooltipContent: '',
|
2024-03-27 22:32:35 +08:00
|
|
|
tooltipPlacement: 'bottom',
|
|
|
|
zIndex: 98
|
2024-01-25 23:24:35 +08:00
|
|
|
});
|
|
|
|
|
2024-06-01 16:53:08 +08:00
|
|
|
const DEFAULT_CLASS = 'h-[36px] text-icon';
|
2023-11-17 08:45:00 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-06-01 16:53:08 +08:00
|
|
|
<NTooltip :placement="tooltipPlacement" :z-index="zIndex" :disabled="!tooltipContent">
|
2023-11-17 08:45:00 +08:00
|
|
|
<template #trigger>
|
2024-06-01 16:53:08 +08:00
|
|
|
<NButton quaternary :class="twMerge(DEFAULT_CLASS, props.class)" v-bind="$attrs">
|
|
|
|
<div class="flex-center gap-8px">
|
|
|
|
<slot>
|
|
|
|
<SvgIcon :icon="icon" />
|
|
|
|
</slot>
|
|
|
|
</div>
|
|
|
|
</NButton>
|
2023-11-17 08:45:00 +08:00
|
|
|
</template>
|
|
|
|
{{ tooltipContent }}
|
|
|
|
</NTooltip>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped></style>
|