2018-07-11 18:00:12 +00:00
|
|
|
<template>
|
|
|
|
<button
|
2018-09-24 10:41:56 +00:00
|
|
|
v-if="link.type !== 'loading'"
|
2019-07-17 09:33:59 +00:00
|
|
|
:class="['toggle-button', 'toggle-preview', {opened: link.shown}]"
|
2019-03-13 17:08:32 +00:00
|
|
|
:aria-label="ariaLabel"
|
2019-02-25 05:38:13 +00:00
|
|
|
@click="onClick"
|
|
|
|
/>
|
2018-07-11 18:00:12 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import {computed, defineComponent, PropType} from "vue";
|
|
|
|
import {ClientMessage, ClientLinkPreview} from "../js/types";
|
|
|
|
|
|
|
|
export default defineComponent({
|
2018-07-11 18:00:12 +00:00
|
|
|
name: "LinkPreviewToggle",
|
|
|
|
props: {
|
2022-06-19 00:25:21 +00:00
|
|
|
link: {type: Object as PropType<ClientLinkPreview>, required: true},
|
|
|
|
message: {type: Object as PropType<ClientMessage>, required: true},
|
2019-03-13 17:08:32 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
emits: ["toggle-link-preview"],
|
|
|
|
setup(props, {emit}) {
|
|
|
|
const ariaLabel = computed(() => {
|
|
|
|
return props.link.shown ? "Collapse preview" : "Expand preview";
|
|
|
|
});
|
|
|
|
|
|
|
|
const onClick = () => {
|
|
|
|
props.link.shown = !props.link.shown;
|
|
|
|
emit("toggle-link-preview", props.link, props.message);
|
|
|
|
};
|
2018-07-11 18:00:12 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
return {
|
|
|
|
ariaLabel,
|
|
|
|
onClick,
|
|
|
|
};
|
2018-07-12 08:26:12 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
2018-07-11 18:00:12 +00:00
|
|
|
</script>
|