Skip to content

Commit

Permalink
refactor: merge duration/live/shorts indicator to VideoThumbnail comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
Bnyro committed Jan 22, 2025
1 parent 5266b2d commit 691cb6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 41 deletions.
32 changes: 5 additions & 27 deletions src/components/PlaylistVideos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
:prefer-listen="preferListen"
>
<router-link
class="flex hover:bg-gray-50 .dark:hover:bg-neutral-800"
class="flex rounded px-2 py-1 hover:bg-gray-50 .dark:hover:bg-neutral-800"
:class="{ 'bg-gray-200 .dark:bg-neutral-700': index === selectedIndex - 1 }"
:to="{
path: '/watch',
Expand All @@ -35,34 +35,12 @@
}"
>
<span class="min-w-5 flex-none text-xs" v-text="index + 1" />
<div class="w-24 flex-none pb-1">
<VideoThumbnail :item="related" />

<div class="relative text-xs">
<!-- shorts thumbnail -->
<span v-if="related.isShort" v-t="'video.shorts'" class="thumbnail-overlay thumbnail-left" />
<span
v-if="related.duration > 0 || (related.duration == 0 && related.isShort)"
class="thumbnail-overlay thumbnail-right px-0.5"
v-text="timeFormat(related.duration)"
/>
<i18n-t
v-else
keypath="video.live"
class="thumbnail-overlay thumbnail-right !bg-red-600"
tag="div"
>
<i class="i-fa6-solid:tower-broadcast w-3" />
</i18n-t>
<span
v-if="related.watched"
v-t="'video.watched'"
class="thumbnail-overlay bottom-5px left-5px px-0.5"
/>
</div>
<div class="w-24 flex-none">
<VideoThumbnail :item="related" :small="true" />
</div>

<div class="ml-2 flex flex-col">
<span class="text-sm font-semibold leading-4" :title="related.title" v-text="related.title" />
<span class="link" :title="related.title" v-text="related.title" />
<div class="flex-1">
<router-link
v-if="related.uploaderUrl && related.uploaderName && !hideChannel"
Expand Down
14 changes: 0 additions & 14 deletions src/components/VideoItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
>
<VideoThumbnail :item="item" />

<div class="relative text-sm">
<!-- shorts thumbnail -->
<span v-if="item.isShort" v-t="'video.shorts'" class="thumbnail-overlay thumbnail-left" />
<span
v-if="item.duration > 0 || (item.duration == 0 && item.isShort)"
class="thumbnail-overlay thumbnail-right px-0.5"
v-text="timeFormat(item.duration)"
/>
<i18n-t v-else keypath="video.live" class="thumbnail-overlay thumbnail-right !bg-red-600" tag="div">
<i class="i-fa6-solid:tower-broadcast w-3" />
</i18n-t>
<span v-if="item.watched" v-t="'video.watched'" class="thumbnail-overlay bottom-5px left-5px" />
</div>

<div>
<p
style="display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical"
Expand Down
20 changes: 20 additions & 0 deletions src/components/VideoThumbnail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
/>
</div>
</div>

<div class="relative" :class="small ? 'text-xs' : 'text-sm'">
<!-- shorts thumbnail -->
<span v-if="item.isShort" v-t="'video.shorts'" class="thumbnail-overlay thumbnail-left" />
<span
v-if="item.duration > 0 || (item.duration == 0 && item.isShort)"
class="thumbnail-overlay thumbnail-right px-0.5"
v-text="timeFormat(item.duration)"
/>
<i18n-t v-else keypath="video.live" class="thumbnail-overlay thumbnail-right !bg-red-600" tag="div">
<i class="i-fa6-solid:tower-broadcast w-3" />
</i18n-t>
<span v-if="item.watched" v-t="'video.watched'" class="thumbnail-overlay bottom-5px left-5px" />
</div>
</template>
<script>
export default {
Expand All @@ -26,6 +40,12 @@ export default {
return {};
},
},
small: {
type: Boolean,
default: () => {
return false;
},
},
},
computed: {
title() {
Expand Down

0 comments on commit 691cb6d

Please sign in to comment.