thelounge/client/components/LinkPreviewToggle.vue

30 lines
538 B
Vue
Raw Normal View History

2018-07-11 20:00:12 +02:00
<template>
<button
v-if="link.type !== 'loading'"
2019-07-17 11:33:59 +02:00
:class="['toggle-button', 'toggle-preview', {opened: link.shown}]"
:aria-label="ariaLabel"
@click="onClick"
/>
2018-07-11 20:00:12 +02:00
</template>
<script>
export default {
name: "LinkPreviewToggle",
props: {
link: Object,
},
computed: {
ariaLabel() {
return this.link.shown ? "Collapse preview" : "Expand preview";
},
},
2018-07-11 20:00:12 +02:00
methods: {
2018-07-12 10:26:12 +02:00
onClick() {
2018-07-11 20:00:12 +02:00
this.link.shown = !this.link.shown;
this.$parent.$emit("linkPreviewToggle", this.link, this.$parent.message);
2018-07-12 10:26:12 +02:00
},
},
2018-07-11 20:00:12 +02:00
};
</script>