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

47 lines
799 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';
/**
* Port of detail_behavior expand button.
*
* @example
* <expand-button>
* <template slot="expanded">
* Text goes here.
* </template>
* </expand-button>
*/
export default {
name: 'ExpandButton',
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
},
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
type="button"
v-show="isCollapsed"
class="text-expander btn-blank"
:aria-label="ariaLabel"
@click="onClick">
...
</button>
2018-03-27 19:54:05 +05:30
<span v-if="!isCollapsed">
2018-03-17 18:26:18 +05:30
<slot name="expanded"></slot>
</span>
</span>
</template>