homebox/frontend/components/Label/Chip.vue

41 lines
1 KiB
Vue
Raw Permalink Normal View History

2022-09-02 01:52:40 +00:00
<script setup lang="ts">
import { LabelOut, LabelSummary } from "~~/lib/api/types/data-contracts";
2022-09-03 09:17:57 +00:00
export type sizes = "sm" | "md" | "lg" | "xl";
2022-09-02 01:52:40 +00:00
defineProps({
label: {
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,
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
ref="badge"
class="badge badge-secondary text-secondary-content"
2022-09-03 09:17:57 +00:00
:class="{
'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' : ''">
<Icon name="heroicons-arrow-right" class="mr-2 swap-on"></Icon>
<Icon name="heroicons-tag" class="mr-2 swap-off"></Icon>
</label>
{{ label.name }}
2022-09-02 01:52:40 +00:00
</NuxtLink>
</template>