2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2020-01-01 13:55:28 +05:30
|
|
|
import { GlButton } from '@gitlab/ui';
|
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: {
|
2020-01-01 13:55:28 +05:30
|
|
|
GlButton,
|
2018-11-08 19:23:39 +05:30
|
|
|
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>
|
2020-01-01 13:55:28 +05:30
|
|
|
<gl-button
|
2018-03-17 18:26:18 +05:30
|
|
|
v-show="isCollapsed"
|
|
|
|
:aria-label="ariaLabel"
|
2018-11-08 19:23:39 +05:30
|
|
|
type="button"
|
2020-01-01 13:55:28 +05:30
|
|
|
class="js-text-expander-prepend text-expander btn-blank"
|
2019-02-15 15:39:39 +05:30
|
|
|
@click="onClick"
|
|
|
|
>
|
|
|
|
<icon :size="12" name="ellipsis_h" />
|
2020-01-01 13:55:28 +05:30
|
|
|
</gl-button>
|
|
|
|
<span v-if="isCollapsed"> <slot name="short"></slot> </span>
|
2019-02-15 15:39:39 +05:30
|
|
|
<span v-if="!isCollapsed"> <slot name="expanded"></slot> </span>
|
2020-01-01 13:55:28 +05:30
|
|
|
<gl-button
|
|
|
|
v-show="!isCollapsed"
|
|
|
|
:aria-label="ariaLabel"
|
|
|
|
type="button"
|
|
|
|
class="js-text-expander-append text-expander btn-blank"
|
|
|
|
@click="onClick"
|
|
|
|
>
|
|
|
|
<icon :size="12" name="ellipsis_h" />
|
|
|
|
</gl-button>
|
2018-03-17 18:26:18 +05:30
|
|
|
</span>
|
|
|
|
</template>
|