yunohost-portal/components/YButton.vue

36 lines
700 B
Vue
Raw Normal View History

2023-07-25 19:19:27 +02:00
<script setup lang="ts">
const props = withDefaults(
defineProps<{
type?: HTMLButtonElement['type']
2023-07-25 22:46:38 +02:00
text?: string
variant?: string
icon?: string
2023-07-25 19:19:27 +02:00
block?: boolean
}>(),
{
type: 'button',
2023-07-25 22:46:38 +02:00
text: undefined,
variant: 'primary',
icon: undefined,
2023-07-25 19:19:27 +02:00
block: false,
},
)
const variantClass = computed(() => {
return {
primary: 'btn-primary',
success: 'btn-success',
info: 'btn-info',
}[props.variant]
})
</script>
<template>
<button class="btn" :class="[variantClass, { 'btn-block': block }]">
2023-07-25 22:46:38 +02:00
<slot name="default">
<Icon v-if="icon" :name="icon" size="1.5em" aria-hidden="true" />
{{ text }}
</slot>
2023-07-25 19:19:27 +02:00
</button>
</template>