debian-mirror-gitlab/app/assets/javascripts/ide/components/new_dropdown/button.vue

61 lines
1,016 B
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
import Icon from '~/vue_shared/components/icon.vue';
2018-11-20 20:47:30 +05:30
import tooltip from '~/vue_shared/directives/tooltip';
2018-11-18 11:00:15 +05:30
export default {
2018-11-20 20:47:30 +05:30
directives: {
tooltip,
},
2018-11-18 11:00:15 +05:30
components: {
Icon,
},
props: {
label: {
type: String,
required: false,
default: null,
},
icon: {
type: String,
required: true,
},
iconClasses: {
type: String,
required: false,
default: null,
},
showLabel: {
type: Boolean,
required: false,
default: true,
},
},
2018-11-20 20:47:30 +05:30
computed: {
tooltipTitle() {
return this.showLabel ? '' : this.label;
},
},
2018-11-18 11:00:15 +05:30
methods: {
clicked() {
this.$emit('click');
},
},
};
</script>
<template>
<button
2018-11-20 20:47:30 +05:30
v-tooltip
2018-11-18 11:00:15 +05:30
:aria-label="label"
2018-11-20 20:47:30 +05:30
:title="tooltipTitle"
2018-11-18 11:00:15 +05:30
type="button"
class="btn-blank"
@click.stop.prevent="clicked"
>
2019-12-21 20:55:43 +05:30
<icon :name="icon" :class="iconClasses" />
2018-11-18 11:00:15 +05:30
<template v-if="showLabel">
{{ label }}
</template>
</button>
</template>