2018-01-03 16:03:39 -05:00
|
|
|
<script>
|
|
|
|
import { __ } from '~/locale';
|
|
|
|
/**
|
|
|
|
* Port of detail_behavior expand button.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* <expand-button>
|
|
|
|
* <template slot="expanded">
|
|
|
|
* Text goes here.
|
|
|
|
* </template>
|
|
|
|
* </expand-button>
|
|
|
|
*/
|
|
|
|
export default {
|
2018-01-06 13:59:49 -05:00
|
|
|
name: 'ExpandButton',
|
2018-01-03 16:03:39 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isCollapsed: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
ariaLabel() {
|
|
|
|
return __('Click to expand text');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.isCollapsed = !this.isCollapsed;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<span>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
v-show="isCollapsed"
|
|
|
|
class="text-expander btn-blank"
|
2018-01-05 05:56:09 -05:00
|
|
|
:aria-label="ariaLabel"
|
2018-01-03 16:03:39 -05:00
|
|
|
@click="onClick">
|
|
|
|
...
|
|
|
|
</button>
|
2018-02-27 07:51:15 -05:00
|
|
|
<span v-if="!isCollapsed">
|
2018-01-03 16:03:39 -05:00
|
|
|
<slot name="expanded"></slot>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</template>
|