2022-11-24 05:04:20 +00:00
|
|
|
<script setup lang="ts">
|
2022-11-29 08:15:05 +00:00
|
|
|
const props = defineProps<{
|
2022-11-24 05:04:20 +00:00
|
|
|
text?: string | number
|
2022-11-27 15:11:34 +00:00
|
|
|
content: string
|
2022-11-24 05:04:20 +00:00
|
|
|
color: string
|
|
|
|
icon: string
|
2022-11-24 08:34:05 +00:00
|
|
|
activeIcon?: string
|
2022-11-24 05:04:20 +00:00
|
|
|
hover: string
|
|
|
|
groupHover: string
|
|
|
|
active?: boolean
|
|
|
|
disabled?: boolean
|
2022-11-25 23:46:25 +00:00
|
|
|
as?: string
|
2022-11-29 08:15:05 +00:00
|
|
|
command?: boolean
|
2022-11-24 05:04:20 +00:00
|
|
|
}>()
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
inheritAttrs: false,
|
|
|
|
})
|
2022-11-29 08:15:05 +00:00
|
|
|
|
|
|
|
const el = ref<HTMLDivElement>()
|
|
|
|
|
|
|
|
useCommand({
|
|
|
|
scope: 'Actions',
|
|
|
|
|
|
|
|
order: -2,
|
|
|
|
visible: () => props.command && !props.disabled,
|
|
|
|
|
|
|
|
name: () => props.content,
|
|
|
|
icon: () => props.icon,
|
|
|
|
|
|
|
|
onActivate() {
|
2022-12-02 02:18:57 +00:00
|
|
|
if (!checkLogin())
|
|
|
|
return
|
2022-11-29 08:15:05 +00:00
|
|
|
const clickEvent = new MouseEvent('click', {
|
|
|
|
view: window,
|
|
|
|
bubbles: true,
|
|
|
|
cancelable: true,
|
|
|
|
})
|
|
|
|
el.value?.dispatchEvent(clickEvent)
|
|
|
|
},
|
|
|
|
})
|
2022-11-24 05:04:20 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-25 23:46:25 +00:00
|
|
|
<component
|
2022-11-29 08:15:05 +00:00
|
|
|
:is="as || 'button'"
|
|
|
|
v-bind="$attrs" ref="el"
|
|
|
|
w-fit flex gap-1 items-center
|
|
|
|
rounded group :hover="hover"
|
2022-11-30 13:00:54 +00:00
|
|
|
focus:outline-none cursor-pointer
|
2022-11-29 08:15:05 +00:00
|
|
|
:focus-visible="hover"
|
2022-11-27 15:11:34 +00:00
|
|
|
:class="active ? [color] : 'text-secondary'"
|
2022-11-30 13:00:54 +00:00
|
|
|
:aria-label="content"
|
2022-11-24 08:34:05 +00:00
|
|
|
>
|
2022-11-27 15:11:34 +00:00
|
|
|
<CommonTooltip placement="bottom" :content="content">
|
|
|
|
<div rounded-full p2 :group-hover="groupHover" :group-focus-visible="groupHover" group-focus-visible:ring="2 current">
|
|
|
|
<div :class="[active && activeIcon ? activeIcon : icon, { 'pointer-events-none': disabled }]" />
|
|
|
|
</div>
|
|
|
|
</CommonTooltip>
|
2022-11-24 05:04:20 +00:00
|
|
|
|
2022-12-03 05:28:32 +00:00
|
|
|
<CommonAnimateNumber v-if="text !== undefined" :increased="active" text-sm>
|
2022-11-30 07:30:35 +00:00
|
|
|
<span text-secondary-light>{{ text }}</span>
|
2022-11-30 06:21:11 +00:00
|
|
|
<template #next>
|
2022-11-30 07:30:35 +00:00
|
|
|
<span :class="[color]">{{ text }}</span>
|
2022-11-30 06:21:11 +00:00
|
|
|
</template>
|
|
|
|
</CommonAnimateNumber>
|
2022-11-25 23:46:25 +00:00
|
|
|
</component>
|
2022-11-24 05:04:20 +00:00
|
|
|
</template>
|