hardlounge/client/components/LinkPreviewToggle.vue

38 lines
900 B
Vue
Raw Normal View History

2018-07-11 18:00:12 +00:00
<template>
<button
v-if="link.type !== 'loading'"
2019-07-17 09:33:59 +00:00
:class="['toggle-button', 'toggle-preview', {opened: link.shown}]"
:aria-label="ariaLabel"
@click="onClick"
/>
2018-07-11 18:00:12 +00:00
</template>
<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: {
link: {type: Object as PropType<ClientLinkPreview>, required: true},
message: {type: Object as PropType<ClientMessage>, required: true},
},
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
return {
ariaLabel,
onClick,
};
2018-07-12 08:26:12 +00:00
},
});
2018-07-11 18:00:12 +00:00
</script>