113 lines
3.0 KiB
Vue
113 lines
3.0 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import { proxyImage } from '@/lib/proxyImage';
|
|
import StoryViewer from '@/components/dredge/Stories/StoryViewer.vue';
|
|
import type { ThreadMessage } from '@/types/dredge.types';
|
|
|
|
const props = defineProps<{
|
|
message: ThreadMessage;
|
|
}>();
|
|
|
|
const isOpen = ref(false);
|
|
</script>
|
|
|
|
<template>
|
|
<component
|
|
:is="message.story_share!.exists_locally ? 'button' : 'a'"
|
|
class="story-share"
|
|
:class="{ 'story-share--large': message.story_share!.exists_locally }"
|
|
v-bind="
|
|
message.story_share!.exists_locally
|
|
? { type: 'button' }
|
|
: { href: message.shared_url ?? undefined, target: '_blank', rel: 'noopener noreferrer' }
|
|
"
|
|
@click="message.story_share!.exists_locally && (isOpen = true)"
|
|
>
|
|
<img
|
|
v-if="message.shared_preview_image"
|
|
:src="proxyImage(message.shared_preview_image)"
|
|
alt=""
|
|
class="story-share__image"
|
|
/>
|
|
<span v-if="message.shared_title || message.shared_caption" class="story-share__body">
|
|
<span v-if="message.shared_title" class="story-share__title">
|
|
{{ message.shared_title }}
|
|
</span>
|
|
<span v-if="message.shared_caption" class="story-share__caption">
|
|
{{ message.shared_caption }}
|
|
</span>
|
|
</span>
|
|
</component>
|
|
|
|
<StoryViewer
|
|
v-if="isOpen && message.story_share"
|
|
:username="message.story_share.username"
|
|
:item-id="message.story_share.item_id"
|
|
@close="isOpen = false"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.story-share {
|
|
display: flex;
|
|
gap: 0.6rem;
|
|
text-decoration: none;
|
|
color: inherit;
|
|
background: rgba(0, 0, 0, 0.15);
|
|
border: none;
|
|
border-radius: 8px;
|
|
padding: 0.4rem;
|
|
font: inherit;
|
|
text-align: left;
|
|
width: 100%;
|
|
cursor: pointer;
|
|
}
|
|
.story-share__image {
|
|
width: 48px;
|
|
height: 48px;
|
|
object-fit: cover;
|
|
border-radius: 6px;
|
|
flex-shrink: 0;
|
|
}
|
|
.story-share__body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
justify-content: center;
|
|
}
|
|
.story-share__title {
|
|
font-weight: 600;
|
|
font-size: 0.82rem;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.story-share__caption {
|
|
font-size: 0.75rem;
|
|
opacity: 0.8;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* A story we actually have locally: worth a much bigger, tappable preview
|
|
instead of the compact link-card treatment used for everything else. */
|
|
.story-share--large {
|
|
flex-direction: column;
|
|
background: rgba(0, 0, 0, 0.2);
|
|
padding: 0.5rem;
|
|
}
|
|
.story-share--large .story-share__image {
|
|
width: 160px;
|
|
height: 284px; /* ~9:16, matching Instagram's own story aspect ratio */
|
|
border-radius: 10px;
|
|
}
|
|
.story-share--large .story-share__body {
|
|
width: 160px;
|
|
}
|
|
.story-share--large .story-share__caption,
|
|
.story-share--large .story-share__title {
|
|
white-space: normal;
|
|
}
|
|
</style>
|