2021-01-17 18:57:57 +01:00
|
|
|
<template>
|
|
|
|
<a
|
|
|
|
class="button"
|
|
|
|
:class="{
|
|
|
|
'is-loading': loading,
|
|
|
|
'has-no-shadow': !shadow,
|
|
|
|
'is-primary': type === 'primary',
|
|
|
|
'is-outlined': type === 'secondary',
|
|
|
|
'is-text is-inverted has-no-shadow underline-none':
|
|
|
|
type === 'tertary',
|
|
|
|
}"
|
2021-08-20 17:00:03 +02:00
|
|
|
:disabled="disabled || null"
|
2021-01-17 18:57:57 +01:00
|
|
|
@click="click"
|
2021-08-20 17:00:03 +02:00
|
|
|
:href="href !== '' ? href : null"
|
2021-01-17 18:57:57 +01:00
|
|
|
>
|
|
|
|
<icon :icon="icon" v-if="showIconOnly"/>
|
|
|
|
<span class="icon is-small" v-else-if="icon !== ''">
|
|
|
|
<icon :icon="icon"/>
|
|
|
|
</span>
|
|
|
|
<slot></slot>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'x-button',
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'primary',
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
to: {
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
shadow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
2021-08-23 21:18:12 +02:00
|
|
|
emits: ['click'],
|
2021-01-17 18:57:57 +01:00
|
|
|
computed: {
|
|
|
|
showIconOnly() {
|
|
|
|
return this.icon !== '' && typeof this.$slots.default === 'undefined'
|
2021-07-17 23:21:46 +02:00
|
|
|
},
|
2021-01-17 18:57:57 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click(e) {
|
|
|
|
if (this.disabled) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.to !== false) {
|
|
|
|
this.$router.push(this.to)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('click', e)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|