Piped/src/components/ChaptersBar.vue

78 lines
2.3 KiB
Vue
Raw Normal View History

<template>
<!-- desktop view -->
2022-09-05 17:32:02 +00:00
<div v-if="!mobileLayout" class="pp-chapters flex-col overflow-y-scroll max-h-75vh min-h-64 lt-lg:hidden">
<h6 aria-label="chapters" title="chapters">{{ $t("video.chapters") }} - {{ chapters.length }}</h6>
<div
:key="chapter.start"
v-for="(chapter, index) in chapters"
@click="$emit('seek', chapter.start)"
2022-09-05 17:32:02 +00:00
class="chapter efy_anim_pulse"
:class="{ 'pp-chapter-active': isCurrentChapter(index) }"
>
<div class="flex">
<img :src="chapter.image" :alt="chapter.title" />
<div class="flex flex-col m-2">
2022-09-05 17:32:02 +00:00
<span :title="chapter.title" v-text="index + 1 + '. ' + chapter.title" class="font-bold" />
<span class="font-bold" v-text="timeFormat(chapter.start)" />
</div>
</div>
</div>
</div>
<!-- mobile view -->
2022-09-05 17:32:02 +00:00
<div v-else class="pp-chapters pp-mobile flex overflow-x-auto">
<div
:key="chapter.start"
2022-07-22 18:54:52 +00:00
v-for="(chapter, index) in chapters"
@click="$emit('seek', chapter.start)"
2022-09-05 17:32:02 +00:00
class="chapter efy_anim_pulse"
:class="{ 'pp-chapter-active': isCurrentChapter(index) }"
>
2022-06-24 22:28:06 +00:00
<img :src="chapter.image" :alt="chapter.title" />
<div class="m-1 flex">
2022-09-05 17:32:02 +00:00
<span class="text-truncate font-bold" :title="chapter.title" v-text="chapter.title" />
<span class="px-1 font-bold" v-text="timeFormat(chapter.start)" />
</div>
</div>
</div>
</template>
2022-01-26 04:39:36 +00:00
<style>
.chapter {
2022-06-24 22:28:06 +00:00
@apply cursor-pointer self-center p-2.5;
2022-08-17 13:34:57 +00:00
}
2022-09-05 17:32:02 +00:00
.pp-mobile .chapter img {
2022-08-17 13:34:57 +00:00
@apply w-full h-full;
}
2022-09-05 17:32:02 +00:00
.chapter img {
2022-08-17 13:34:57 +00:00
@apply w-3/10 h-3/10;
}
.text-truncate {
2022-06-24 22:28:06 +00:00
@apply truncate overflow-hidden inline-block w-10em;
2022-01-26 04:39:36 +00:00
}
</style>
<script setup>
import { defineProps, defineEmits } from "vue";
2022-07-25 12:20:42 +00:00
const props = defineProps({
chapters: Object,
mobileLayout: {
type: Boolean,
default: () => true,
},
playerPosition: {
type: Number,
default: () => 0,
},
});
2022-07-25 12:20:42 +00:00
const isCurrentChapter = index => {
return (
props.playerPosition >= props.chapters[index].start &&
props.playerPosition < (props.chapters[index + 1]?.start ?? Infinity)
);
};
defineEmits(["seek"]);
</script>