2022-12-07 15:55:45 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { Card } from 'masto'
|
|
|
|
|
2022-12-09 21:13:59 +00:00
|
|
|
const props = defineProps<{
|
2022-12-07 15:55:45 +00:00
|
|
|
card: Card
|
2022-12-09 21:13:59 +00:00
|
|
|
/** For the preview image, only the small image mode is displayed */
|
|
|
|
smallPictureOnly?: boolean
|
|
|
|
/** When it is root card in the list, not appear as a child card */
|
|
|
|
root?: boolean
|
2022-12-07 15:55:45 +00:00
|
|
|
}>()
|
2022-12-09 21:13:59 +00:00
|
|
|
const alt = $computed(() => `${props.card.title} - ${props.card.title}`)
|
|
|
|
const isSquare = $computed(() => props.smallPictureOnly || props.card.width === props.card.height)
|
|
|
|
const description = $computed(() => props.card.description ? props.card.description : new URL(props.card.url).hostname)
|
2022-12-07 15:55:45 +00:00
|
|
|
|
|
|
|
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-12-09 21:13:59 +00:00
|
|
|
<NuxtLink
|
|
|
|
block
|
|
|
|
of-hidden
|
|
|
|
hover:bg-active
|
|
|
|
:to="card.url"
|
|
|
|
:class="{
|
|
|
|
'flex': isSquare,
|
|
|
|
'p-4': root,
|
|
|
|
'rounded-lg border border-base': !root,
|
|
|
|
}"
|
|
|
|
target="_blank"
|
2022-12-07 15:55:45 +00:00
|
|
|
>
|
2022-12-09 21:13:59 +00:00
|
|
|
<div
|
|
|
|
v-if="card.image"
|
|
|
|
flex flex-col
|
|
|
|
display-block of-hidden
|
|
|
|
|
|
|
|
border="base"
|
|
|
|
:class="{
|
|
|
|
'min-w-32 w-32 h-32 border-r': isSquare,
|
|
|
|
'w-full aspect-[1.91] border-b': !isSquare,
|
|
|
|
'rounded-lg': root,
|
|
|
|
}"
|
|
|
|
>
|
2022-12-07 15:55:45 +00:00
|
|
|
<CommonBlurhash
|
|
|
|
:blurhash="card.blurhash"
|
|
|
|
:src="card.image"
|
|
|
|
:width="card.width"
|
|
|
|
:height="card.height"
|
|
|
|
:alt="alt"
|
2022-12-09 21:13:59 +00:00
|
|
|
w-full h-full object-cover
|
2022-12-07 15:55:45 +00:00
|
|
|
/>
|
2022-12-09 21:13:59 +00:00
|
|
|
</div>
|
|
|
|
<div v-else min-w-32 w-32 h-32 bg="slate-500/10" flex justify-center items-center>
|
|
|
|
<div i-ri:profile-line w="30%" h="30%" text-secondary />
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
p4 max-h-2xl
|
|
|
|
flex flex-col
|
|
|
|
>
|
|
|
|
<p v-if="card.providerName" text-secondary line-clamp-1 text-ellipsis>
|
|
|
|
{{ card.providerName }}
|
|
|
|
</p>
|
|
|
|
<strong v-if="card.title" line-clamp-1 text-ellipsis>{{ card.title }}</strong>
|
|
|
|
<p v-if="description" text-secondary line-clamp-2 text-ellipsis>
|
|
|
|
{{ description }}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</NuxtLink>
|
2022-12-07 15:55:45 +00:00
|
|
|
</template>
|