mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-25 15:03:35 +00:00
revamped chapter layouts for desktop view
* desktop chapters layout * fallback to mobile view on small screens
This commit is contained in:
parent
ed8481cc20
commit
fb4a2129d4
@ -1,6 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <h2 v-t="'video.chapters'" class="mb-5" /> -->
|
<!-- desktop view -->
|
||||||
<div class="flex overflow-x-auto">
|
<div v-if="mobileLayout == false" class="flex-col <lg:hidden" style="overflow-y: scroll; max-height: 29.3em">
|
||||||
|
<h2 v-t="'video.chapters'" class="mb-2 bg-gray-500/50 p-2" />
|
||||||
|
<div
|
||||||
|
:key="chapter.start"
|
||||||
|
v-for="chapter in chapters"
|
||||||
|
@click="$emit('seek', chapter.start)"
|
||||||
|
class="chapter-vertical"
|
||||||
|
>
|
||||||
|
<div class="flex">
|
||||||
|
<img :src="chapter.image" :alt="chapter.title" />
|
||||||
|
<div class="flex flex-col m-2">
|
||||||
|
<span class="text-truncate 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="chapter">
|
<div :key="chapter.start" v-for="chapter in chapters" @click="$emit('seek', chapter.start)" class="chapter">
|
||||||
<img :src="chapter.image" :alt="chapter.title" class="" />
|
<img :src="chapter.image" :alt="chapter.title" class="" />
|
||||||
<div class="m-1 flex">
|
<div class="m-1 flex">
|
||||||
@ -24,6 +42,18 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.chapter-vertical {
|
||||||
|
@apply cursor-pointer;
|
||||||
|
align-self: center;
|
||||||
|
padding: 10px;
|
||||||
|
img {
|
||||||
|
width: 30%;
|
||||||
|
height: 30%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.chapter-vertical:hover {
|
||||||
|
@apply bg-gray-500;
|
||||||
|
}
|
||||||
.text-truncate {
|
.text-truncate {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 10em;
|
width: 10em;
|
||||||
@ -38,6 +68,10 @@ import { defineProps, defineEmits } from "vue";
|
|||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
chapters: Object,
|
chapters: Object,
|
||||||
|
mobileLayout: {
|
||||||
|
type: Boolean,
|
||||||
|
default: () => true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defineEmits(["seek"]);
|
defineEmits(["seek"]);
|
||||||
|
@ -16,16 +16,23 @@
|
|||||||
<ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" />
|
<ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" />
|
||||||
|
|
||||||
<div v-show="!video.error">
|
<div v-show="!video.error">
|
||||||
<VideoPlayer
|
<div :class="isMobile ? 'flex-col' : 'flex'">
|
||||||
ref="videoPlayer"
|
<VideoPlayer
|
||||||
:video="video"
|
ref="videoPlayer"
|
||||||
:sponsors="sponsors"
|
:video="video"
|
||||||
:playlist="playlist"
|
:sponsors="sponsors"
|
||||||
:index="index"
|
:playlist="playlist"
|
||||||
:selected-auto-play="selectedAutoPlay"
|
:index="index"
|
||||||
:selected-auto-loop="selectedAutoLoop"
|
:selected-auto-play="selectedAutoPlay"
|
||||||
/>
|
:selected-auto-loop="selectedAutoLoop"
|
||||||
<ChaptersBar v-if="video?.chapters?.length > 0" :chapters="video.chapters" @seek="navigate" />
|
/>
|
||||||
|
<ChaptersBar
|
||||||
|
:mobileLayout="isMobile"
|
||||||
|
v-if="video?.chapters?.length > 0"
|
||||||
|
:chapters="video.chapters"
|
||||||
|
@seek="navigate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="font-bold mt-2 text-2xl break-words" v-text="video.title" />
|
<div class="font-bold mt-2 text-2xl break-words" v-text="video.title" />
|
||||||
|
|
||||||
<div class="flex mb-1.5">
|
<div class="flex mb-1.5">
|
||||||
@ -203,6 +210,7 @@ export default {
|
|||||||
smallViewQuery: smallViewQuery,
|
smallViewQuery: smallViewQuery,
|
||||||
smallView: smallViewQuery.matches,
|
smallView: smallViewQuery.matches,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
|
isMobile: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -226,6 +234,18 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
// check screen size
|
||||||
|
if (window.innerWidth >= 1024) {
|
||||||
|
this.isMobile = false;
|
||||||
|
}
|
||||||
|
// add an event listener to watch for screen size changes
|
||||||
|
window.addEventListener("resize", () => {
|
||||||
|
if (window.innerWidth >= 1024) {
|
||||||
|
this.isMobile = false;
|
||||||
|
} else {
|
||||||
|
this.isMobile = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
this.getVideoData().then(() => {
|
this.getVideoData().then(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const videoId = this.getVideoId();
|
const videoId = this.getVideoId();
|
||||||
|
Loading…
Reference in New Issue
Block a user