2022-05-12 17:29:53 +00:00
|
|
|
<template>
|
|
|
|
<a :href="url" data-testid="youtube-search-result" role="button" @click.prevent="play">
|
|
|
|
<img :alt="video.snippet.title" :src="video.snippet.thumbnails.default.url" width="90">
|
|
|
|
<div class="meta">
|
|
|
|
<h3 class="title">{{ video.snippet.title }}</h3>
|
|
|
|
<p class="desc">{{ video.snippet.description }}</p>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, toRefs } from 'vue'
|
|
|
|
import { youTubeService } from '@/services'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { RouterKey } from '@/symbols'
|
|
|
|
import { requireInjection } from '@/utils'
|
|
|
|
|
|
|
|
const router = requireInjection(RouterKey)
|
2022-05-12 17:29:53 +00:00
|
|
|
|
|
|
|
const props = defineProps<{ video: YouTubeVideo }>()
|
|
|
|
const { video } = toRefs(props)
|
|
|
|
|
|
|
|
const url = computed(() => `https://youtu.be/${video.value.id.videoId}`)
|
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const play = () => {
|
|
|
|
youTubeService.play(video.value)
|
|
|
|
router.go('youtube')
|
|
|
|
}
|
2022-05-12 17:29:53 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
a {
|
|
|
|
display: flex;
|
2022-07-07 22:57:25 +00:00
|
|
|
gap: 10px;
|
2022-05-12 17:29:53 +00:00
|
|
|
|
|
|
|
&:hover, &:active, &:focus {
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
font-size: 1.1rem;
|
|
|
|
margin-bottom: .4rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.desc {
|
|
|
|
font-size: .9rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
img {
|
|
|
|
align-self: self-start;
|
|
|
|
}
|
2022-07-07 22:57:25 +00:00
|
|
|
|
|
|
|
.meta {
|
|
|
|
overflow-wrap: anywhere;
|
|
|
|
}
|
2022-05-12 17:29:53 +00:00
|
|
|
</style>
|