2021-01-17 18:57:57 +01:00
|
|
|
<template>
|
2022-01-04 19:58:06 +01:00
|
|
|
<BaseButton
|
2021-01-17 18:57:57 +01:00
|
|
|
class="button"
|
2022-01-04 19:58:06 +01:00
|
|
|
:class="[
|
|
|
|
variantClass,
|
|
|
|
{
|
|
|
|
'is-loading': loading,
|
|
|
|
'has-no-shadow': !shadow || variant === 'tertiary',
|
|
|
|
}
|
|
|
|
]"
|
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>
|
2022-01-04 19:58:06 +01:00
|
|
|
<slot />
|
|
|
|
</BaseButton>
|
2021-01-17 18:57:57 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-04 19:58:06 +01:00
|
|
|
<script lang="ts">
|
2022-02-15 13:07:59 +01:00
|
|
|
import {defineComponent} from 'vue'
|
|
|
|
|
|
|
|
export default defineComponent({
|
2021-01-17 18:57:57 +01:00
|
|
|
name: 'x-button',
|
2022-02-15 13:07:59 +01:00
|
|
|
})
|
2022-01-04 19:58:06 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import {computed, useSlots, PropType} from 'vue'
|
|
|
|
import BaseButton from '@/components/base/BaseButton.vue'
|
|
|
|
|
|
|
|
const BUTTON_TYPES_MAP = Object.freeze({
|
|
|
|
primary: 'is-primary',
|
|
|
|
secondary: 'is-outlined',
|
|
|
|
tertiary: 'is-text is-inverted underline-none',
|
|
|
|
})
|
|
|
|
|
|
|
|
type ButtonTypes = keyof typeof BUTTON_TYPES_MAP
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
variant: {
|
|
|
|
type: String as PropType<ButtonTypes>,
|
|
|
|
default: 'primary',
|
2021-01-17 18:57:57 +01:00
|
|
|
},
|
2022-01-04 19:58:06 +01:00
|
|
|
icon: {
|
2022-04-10 20:56:14 +02:00
|
|
|
type: String,
|
2022-01-04 19:58:06 +01:00
|
|
|
default: '',
|
2021-01-17 18:57:57 +01:00
|
|
|
},
|
2022-01-04 19:58:06 +01:00
|
|
|
loading: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
shadow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
|
2022-01-04 19:58:06 +01:00
|
|
|
const variantClass = computed(() => BUTTON_TYPES_MAP[props.variant])
|
2021-01-17 18:57:57 +01:00
|
|
|
|
2022-01-04 19:58:06 +01:00
|
|
|
const slots = useSlots()
|
|
|
|
const showIconOnly = computed(() => props.icon !== '' && typeof slots.default === 'undefined')
|
2021-10-18 14:32:59 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-10-20 12:20:12 +02:00
|
|
|
.button {
|
|
|
|
transition: all $transition;
|
|
|
|
border: 0;
|
|
|
|
text-transform: uppercase;
|
|
|
|
font-size: 0.85rem;
|
|
|
|
font-weight: bold;
|
2022-02-13 22:26:44 +01:00
|
|
|
min-height: $button-height;
|
2021-11-22 22:12:54 +01:00
|
|
|
box-shadow: var(--shadow-sm);
|
2022-01-04 19:58:06 +01:00
|
|
|
display: inline-flex;
|
2021-10-20 12:20:12 +02:00
|
|
|
|
|
|
|
&:hover {
|
2021-11-22 22:12:54 +01:00
|
|
|
box-shadow: var(--shadow-md);
|
2021-10-20 12:20:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&.fullheight {
|
|
|
|
padding-right: 7px;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.is-active,
|
|
|
|
&.is-focused,
|
|
|
|
&:active,
|
|
|
|
&:focus,
|
|
|
|
&:focus:not(:active) {
|
2021-11-22 22:12:54 +01:00
|
|
|
box-shadow: var(--shadow-xs) !important;
|
2021-10-20 12:20:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&.is-primary.is-outlined:hover {
|
2021-11-22 22:12:54 +01:00
|
|
|
color: var(--white);
|
2021-10-20 12:20:12 +02:00
|
|
|
}
|
|
|
|
|
2022-01-04 19:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.is-small {
|
|
|
|
border-radius: $radius;
|
2021-10-20 12:20:12 +02:00
|
|
|
}
|
|
|
|
|
2021-10-18 14:32:59 +02:00
|
|
|
.underline-none {
|
|
|
|
text-decoration: none !important;
|
|
|
|
}
|
|
|
|
</style>
|