YButton: use link instead of button if used as navigation

This commit is contained in:
axolotle 2023-09-04 16:34:13 +02:00
parent bba01d685b
commit 535dd0e0c5

View file

@ -1,4 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { NuxtLink } from '#components'
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
type?: 'button' | 'submit' | 'reset' type?: 'button' | 'submit' | 'reset'
@ -33,10 +35,11 @@ const variantClass = computed(() => {
</script> </script>
<template> <template>
<button <component
:is="$attrs.to ? NuxtLink : 'button'"
class="btn" class="btn"
:class="[variantClass, { 'btn-block': block }]" :class="[variantClass, { 'btn-block': block }]"
:type="type" :type="$attrs.to ? null : type"
> >
<slot name="default"> <slot name="default">
<Icon <Icon
@ -48,5 +51,5 @@ const variantClass = computed(() => {
/> />
<span :class="{ 'sr-only': iconOnly }">{{ text }}</span> <span :class="{ 'sr-only': iconOnly }">{{ text }}</span>
</slot> </slot>
</button> </component>
</template> </template>