Files
mixtape/zero.Backoffice.UI/app/components/ui-select-button.vue
T

69 lines
1.6 KiB
Vue
Raw Normal View History

2020-04-24 15:13:54 +02:00
<template>
<button type="button" class="ui-select-button type-light" :disabled="disabled" @click="tryClick">
<span class="ui-select-button-icon" v-if="!isImage">
<ui-icon :symbol="icon" />
</span>
2020-06-10 12:35:26 +02:00
<span class="ui-select-button-icon is-image" v-if="isImage">
2022-01-02 15:35:00 +01:00
<ui-thumbnail :media="source" :alt="icon" />
2020-06-10 12:35:26 +02:00
</span>
2021-12-07 15:59:29 +01:00
<div class="ui-select-button-content" v-if="label || description">
2020-06-15 16:05:47 +02:00
<strong class="ui-select-button-label" v-localize:html="{ key: label, tokens: tokens }"></strong>
2020-06-05 15:34:13 +02:00
<span class="ui-select-button-description" v-if="description" v-localize:html="{ key: description, tokens: tokens }"></span>
2021-12-07 15:59:29 +01:00
</div>
<slot></slot>
2020-04-24 15:13:54 +02:00
</button>
</template>
<script>
2021-12-07 15:59:29 +01:00
//import MediaApi from 'zero/api/media.js'; // TODO vue
2020-06-10 12:35:26 +02:00
2020-04-24 15:13:54 +02:00
export default {
2020-06-05 15:34:13 +02:00
name: 'uiSelectButton',
2020-04-24 15:13:54 +02:00
props: {
icon: {
type: String,
default: 'fth-box'
},
2020-06-10 12:35:26 +02:00
iconAsImage: {
type: Boolean,
default: false
},
2020-04-24 15:13:54 +02:00
label: {
2020-09-18 11:15:17 +02:00
type: String,
default: null
2020-04-24 15:13:54 +02:00
},
description: {
type: String,
default: null
},
2020-06-05 15:34:13 +02:00
tokens: {
type: Object,
default: () => {}
},
2020-04-24 15:13:54 +02:00
disabled: Boolean
},
2020-06-10 12:35:26 +02:00
computed: {
isImage()
{
return this.iconAsImage && this.icon.indexOf('fth-') !== 0;
},
source()
{
2021-12-07 15:59:29 +01:00
return this.icon; //this.iconAsImage ? (this.icon.indexOf('/') === 0 ? this.icon : MediaApi.getImageSource(this.icon)) : null;
2020-06-10 12:35:26 +02:00
}
2020-04-24 15:13:54 +02:00
},
2020-06-10 12:35:26 +02:00
2020-04-24 15:13:54 +02:00
methods: {
tryClick(ev)
{
this.$emit('click', ev);
}
}
}
</script>