debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/expand_button.vue

58 lines
990 B
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2018-10-15 14:42:47 +05:30
import { __ } from '~/locale';
2018-11-08 19:23:39 +05:30
import Icon from '~/vue_shared/components/icon.vue';
2018-10-15 14:42:47 +05:30
/**
* Port of detail_behavior expand button.
*
* @example
* <expand-button>
* <template slot="expanded">
* Text goes here.
* </template>
* </expand-button>
*/
export default {
name: 'ExpandButton',
2018-11-08 19:23:39 +05:30
components: {
Icon,
},
2018-10-15 14:42:47 +05:30
data() {
return {
isCollapsed: true,
};
},
computed: {
ariaLabel() {
return __('Click to expand text');
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
},
2018-11-08 19:23:39 +05:30
destroyed() {
this.isCollapsed = true;
},
2018-10-15 14:42:47 +05:30
methods: {
onClick() {
this.isCollapsed = !this.isCollapsed;
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<span>
<button
v-show="isCollapsed"
:aria-label="ariaLabel"
2018-11-08 19:23:39 +05:30
type="button"
class="text-expander btn-blank"
2019-01-03 12:48:30 +05:30
@click="onClick">
<icon
:size="12"
name="ellipsis_h"
/>
2018-03-17 18:26:18 +05:30
</button>
2019-01-03 12:48:30 +05:30
<span v-if="!isCollapsed">
<slot name="expanded"></slot>
</span>
2018-03-17 18:26:18 +05:30
</span>
</template>