2022-12-11 19:52:36 +09:00
|
|
|
<script lang="ts" setup>
|
2023-01-08 15:21:09 +09:00
|
|
|
import type { mastodon } from 'masto'
|
2022-12-11 19:52:36 +09:00
|
|
|
|
|
|
|
const {
|
|
|
|
tag,
|
|
|
|
} = $defineProps<{
|
2023-01-08 15:21:09 +09:00
|
|
|
tag: mastodon.v1.Tag
|
2022-12-11 19:52:36 +09:00
|
|
|
}>()
|
|
|
|
|
2023-01-23 04:21:34 +09:00
|
|
|
const to = $computed(() => {
|
|
|
|
const { hostname, pathname } = new URL(tag.url)
|
|
|
|
return `/${hostname}${pathname}`
|
|
|
|
})
|
2023-01-24 01:36:28 +09:00
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
function onclick(evt: MouseEvent | KeyboardEvent) {
|
|
|
|
const path = evt.composedPath() as HTMLElement[]
|
|
|
|
const el = path.find(el => ['A', 'BUTTON'].includes(el.tagName?.toUpperCase()))
|
|
|
|
const text = window.getSelection()?.toString()
|
|
|
|
if (!el && !text)
|
|
|
|
go(evt)
|
|
|
|
}
|
|
|
|
|
|
|
|
function go(evt: MouseEvent | KeyboardEvent) {
|
|
|
|
if (evt.metaKey || evt.ctrlKey)
|
|
|
|
window.open(to)
|
|
|
|
else
|
|
|
|
router.push(to)
|
|
|
|
}
|
2022-12-11 19:52:36 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-24 01:36:28 +09:00
|
|
|
<div
|
|
|
|
block p4 hover:bg-active flex justify-between cursor-pointer
|
|
|
|
@click="onclick"
|
|
|
|
@keydown.enter="onclick"
|
|
|
|
>
|
2022-12-11 19:52:36 +09:00
|
|
|
<div>
|
2023-01-24 01:36:28 +09:00
|
|
|
<h4 flex items-center text-size-base leading-normal font-medium line-clamp-1 break-all ws-pre-wrap>
|
|
|
|
<TagActionButton :tag="tag" />
|
2022-12-11 19:52:36 +09:00
|
|
|
<span>#</span>
|
|
|
|
<span hover:underline>{{ tag.name }}</span>
|
|
|
|
</h4>
|
2023-01-25 03:52:48 +09:00
|
|
|
<CommonTrending v-if="tag.history" :history="tag.history" text-sm text-secondary line-clamp-1 ws-pre-wrap break-all />
|
2022-12-11 19:52:36 +09:00
|
|
|
</div>
|
2023-01-25 03:52:48 +09:00
|
|
|
<div v-if="tag.history" flex items-center>
|
2022-12-11 19:52:36 +09:00
|
|
|
<CommonTrendingCharts :history="tag.history" />
|
|
|
|
</div>
|
2023-01-24 01:36:28 +09:00
|
|
|
</div>
|
2022-12-11 19:52:36 +09:00
|
|
|
</template>
|