mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
98 lines
2.9 KiB
Vue
98 lines
2.9 KiB
Vue
<template>
|
|
<!-- desktop view -->
|
|
<div v-if="!mobileLayout" class="flex-col overflow-y-scroll max-h-75vh min-h-64 <lg:hidden">
|
|
<h2 class="mb-2 bg-gray-500/50 p-2" aria-label="chapters" title="chapters">
|
|
{{ $t("video.chapters") }} ({{ chapters.length }})
|
|
</h2>
|
|
<div
|
|
:key="chapter.start"
|
|
v-for="(chapter, index) in chapters"
|
|
@click="$emit('seek', chapter.start)"
|
|
class="chapter-vertical"
|
|
:class="
|
|
isCurrentChapter(chapters, index, playerPosition)
|
|
? 'chapter-vertical bg-red-500/50'
|
|
: 'chapter-vertical'
|
|
"
|
|
>
|
|
<div class="flex">
|
|
<span class="mt-5 mr-2 text-current" v-text="index + 1" />
|
|
<img :src="chapter.image" :alt="chapter.title" />
|
|
<div class="flex flex-col m-2">
|
|
<span class="text-sm" :title="chapter.title" v-text="chapter.title" />
|
|
<span class="text-sm font-bold text-blue-500" v-text="timeFormat(chapter.start)" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- mobile view -->
|
|
<div v-else class="flex overflow-x-auto">
|
|
<div
|
|
:key="chapter.start"
|
|
v-for="chapter in chapters"
|
|
@click="$emit('seek', chapter.start)"
|
|
:class="isCurrentChapter(chapters, index, playerPosition) ? 'chapter bg-red-500/50' : 'chapter'"
|
|
>
|
|
<img :src="chapter.image" :alt="chapter.title" />
|
|
<div class="m-1 flex">
|
|
<span class="text-truncate text-sm" :title="chapter.title" v-text="chapter.title" />
|
|
<span class="px-1 text-sm font-bold text-blue-500" v-text="timeFormat(chapter.start)" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style>
|
|
::-webkit-scrollbar {
|
|
height: 5px;
|
|
}
|
|
.chapter {
|
|
@apply cursor-pointer self-center p-2.5;
|
|
img {
|
|
@apply w-full h-full;
|
|
}
|
|
}
|
|
.chapter-vertical {
|
|
@apply cursor-pointer self-center p-2.5;
|
|
img {
|
|
@apply w-3/10 h-3/10;
|
|
}
|
|
}
|
|
.chapter-vertical:hover {
|
|
@apply bg-gray-500;
|
|
}
|
|
.text-truncate {
|
|
@apply truncate overflow-hidden inline-block w-10em;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
export default {
|
|
methods: {
|
|
isCurrentChapter(chapters, index, playerPosition) {
|
|
if (index + 1 === chapters.length && playerPosition >= chapters[index].start) return true;
|
|
else if (index + 1 === chapters.length) return false;
|
|
else if (playerPosition >= chapters[index].start && playerPosition < chapters[index + 1].start) return true;
|
|
return false;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<script setup>
|
|
import { defineProps, defineEmits } from "vue";
|
|
|
|
defineProps({
|
|
chapters: Object,
|
|
mobileLayout: {
|
|
type: Boolean,
|
|
default: () => true,
|
|
},
|
|
playerPosition: {
|
|
type: Number,
|
|
default: () => 0,
|
|
},
|
|
});
|
|
|
|
defineEmits(["seek"]);
|
|
</script>
|