yunohost-portal/components/YButton.vue

45 lines
895 B
Vue
Raw Normal View History

2023-07-25 19:19:27 +02:00
<script setup lang="ts">
const props = withDefaults(
defineProps<{
2023-08-01 16:30:36 +02:00
type?: 'button' | 'submit' | 'reset'
2023-07-25 22:46:38 +02:00
text?: string
variant?: string
icon?: string
2023-07-26 04:09:10 +02:00
iconSize?: string
iconOnly?: boolean
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-26 04:08:17 +02:00
iconSize: '1.5em',
iconOnly: false,
2023-07-25 19:19:27 +02:00
block: false,
},
)
const variantClass = computed(() => {
return {
primary: 'btn-primary',
success: 'btn-success',
info: 'btn-info',
2023-07-26 04:08:17 +02:00
error: 'btn-error',
2023-07-25 19:19:27 +02:00
}[props.variant]
})
</script>
<template>
2023-08-01 16:30:36 +02:00
<button
class="btn"
:class="[variantClass, { 'btn-block': block }]"
:type="type"
>
2023-07-25 22:46:38 +02:00
<slot name="default">
2023-07-26 04:08:17 +02:00
<Icon v-if="icon" :name="icon" :size="iconSize" aria-hidden="true" />
<span :class="{ 'sr-only': iconOnly }">{{ text }}</span>
2023-07-25 22:46:38 +02:00
</slot>
2023-07-25 19:19:27 +02:00
</button>
</template>