2022-09-02 01:52:40 +00:00
|
|
|
<script setup lang="ts">
|
2024-03-01 18:08:14 +00:00
|
|
|
import type { LabelOut, LabelSummary } from "~~/lib/api/types/data-contracts";
|
2024-03-01 01:20:18 +00:00
|
|
|
import MdiArrowRight from "~icons/mdi/arrow-right";
|
|
|
|
import MdiTagOutline from "~icons/mdi/tag-outline";
|
2022-09-03 09:17:57 +00:00
|
|
|
|
2022-12-30 01:19:15 +00:00
|
|
|
export type sizes = "sm" | "md" | "lg" | "xl";
|
2022-09-02 01:52:40 +00:00
|
|
|
defineProps({
|
|
|
|
label: {
|
2022-09-12 22:47:27 +00:00
|
|
|
type: Object as () => LabelOut | LabelSummary,
|
2022-09-02 01:52:40 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2022-09-03 09:17:57 +00:00
|
|
|
size: {
|
|
|
|
type: String as () => sizes,
|
2022-09-09 22:46:53 +00:00
|
|
|
default: "md",
|
2022-09-03 09:17:57 +00:00
|
|
|
},
|
2022-09-02 01:52:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const badge = ref(null);
|
|
|
|
const isHover = useElementHover(badge);
|
|
|
|
const { focused } = useFocus(badge);
|
|
|
|
|
|
|
|
const isActive = computed(() => isHover.value || focused.value);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-09-03 09:17:57 +00:00
|
|
|
<NuxtLink
|
2022-09-09 22:46:53 +00:00
|
|
|
ref="badge"
|
2022-12-30 01:19:15 +00:00
|
|
|
class="badge badge-secondary text-secondary-content"
|
2022-09-03 09:17:57 +00:00
|
|
|
:class="{
|
2022-12-30 01:19:15 +00:00
|
|
|
'badge-lg p-4': size === 'lg',
|
|
|
|
'p-3': size !== 'sm' && size !== 'lg',
|
2022-09-03 09:17:57 +00:00
|
|
|
'p-2 badge-sm': size === 'sm',
|
|
|
|
}"
|
|
|
|
:to="`/label/${label.id}`"
|
|
|
|
>
|
|
|
|
<label class="swap swap-rotate" :class="isActive ? 'swap-active' : ''">
|
2024-03-01 01:20:18 +00:00
|
|
|
<MdiArrowRight class="mr-2 swap-on" />
|
|
|
|
<MdiTagOutline class="mr-2 swap-off" />
|
2022-09-03 09:17:57 +00:00
|
|
|
</label>
|
|
|
|
{{ label.name }}
|
2022-09-02 01:52:40 +00:00
|
|
|
</NuxtLink>
|
|
|
|
</template>
|