ruoyi-plus-soybean/src/components/custom/button-icon.vue

49 lines
1.0 KiB
Vue
Raw Normal View History

2023-11-17 08:45:00 +08:00
<script setup lang="ts">
import type { PopoverPlacement } from 'naive-ui';
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;
zIndex?: number;
2023-12-14 21:45:29 +08:00
}
const props = withDefaults(defineProps<Props>(), {
class: '',
icon: '',
tooltipContent: '',
tooltipPlacement: 'bottom',
zIndex: 98
});
const DEFAULT_CLASS = 'h-[36px] text-icon';
2023-11-17 08:45:00 +08:00
</script>
<template>
<NTooltip :placement="tooltipPlacement" :z-index="zIndex" :disabled="!tooltipContent">
2023-11-17 08:45:00 +08:00
<template #trigger>
<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>