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

60 lines
995 B
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
2021-01-29 00:20:46 +05:30
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
export default {
2018-11-20 20:47:30 +05:30
directives: {
2021-01-29 00:20:46 +05:30
GlTooltip: GlTooltipDirective,
2018-11-20 20:47:30 +05:30
},
2018-11-18 11:00:15 +05:30
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2018-11-18 11:00:15 +05:30
},
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
2021-01-29 00:20:46 +05:30
v-gl-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"
>
2020-11-24 15:15:51 +05:30
<gl-icon :name="icon" :class="iconClasses" />
2018-11-18 11:00:15 +05:30
<template v-if="showLabel">
{{ label }}
</template>
</button>
</template>