|
|
@ -2,16 +2,13 @@ |
|
|
|
<transition appear name="fade"> |
|
|
|
<div class="modal p-8 overflow-auto items-center" @click.self="close"> |
|
|
|
<transition name="slide"> |
|
|
|
<div v-if="movie !== undefined" class="relative w-full max-w-6xl bg-white overflow-hidden rounded-xl flex-col flex-shrink-0 shadow-xl"> |
|
|
|
<div v-if="movie !== undefined" class="relative w-full max-w-6xl bg-white md:bg-none overflow-hidden rounded-xl flex-col flex-shrink-0 shadow-xl"> |
|
|
|
<div class="bg-center bg-cover" :class="{ 'text-white': isDark }" |
|
|
|
:style="movie.backdrop_path ? `background: url('/api/tmdb/image/w1280${movie.backdrop_path}')` : ''"> |
|
|
|
<div class="movie-modal-content z-10" :style="backdropOverlayStyle"> |
|
|
|
<div class="flex p-4"> |
|
|
|
<div class="w-24 h-40 flex-shrink-0 md:h-auto md:w-72 rounded-lg md:rounded-xl overflow-hidden shadow-md mdshadow-xl"> |
|
|
|
<i v-if="!movie.poster_path" class="fas fa-image mx-auto my-auto"></i> |
|
|
|
<img v-else class="w-full h-full object-cover" ref="poster" |
|
|
|
:src="`/api/tmdb/image/w342${movie.poster_path}`" @load="onPosterLoad"> |
|
|
|
</div> |
|
|
|
<div class="flex p-4 items-center"> |
|
|
|
<movie-poster v-if="movie.poster_path" :src="movie.poster_path" |
|
|
|
class="w-3/12 flex-shrink-0 rounded-xl shadow-md md:shadow-xl" @onLoad="onPosterLoad"/> |
|
|
|
<div class="p-4 flex flex-col justify-center"> |
|
|
|
<h2 class="text-lg md:text-4xl"> |
|
|
|
<span class="font-bold">{{ movie.title }}</span> |
|
|
@ -58,8 +55,12 @@ import { IApiMovieDetailsResponse, IApiMovieDetails } from "@common/api_schema"; |
|
|
|
import { authFetch } from "../../routes"; |
|
|
|
import { getAverageRgb } from "../../util"; |
|
|
|
import { useStore, Mutation, Action } from "../../store"; |
|
|
|
import MoviePoster from "../MoviePoster.vue"; |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
components: { |
|
|
|
MoviePoster |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
backdropOverlayStyle(): string { |
|
|
|
let { r, g, b } = this.rgb; |
|
|
@ -119,15 +120,15 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
this.close(); |
|
|
|
}, |
|
|
|
onPosterLoad() { |
|
|
|
onPosterLoad(img: HTMLImageElement) { |
|
|
|
this.isPosterLoaded = true; |
|
|
|
this.computeBackdropColor(); |
|
|
|
this.computeBackdropColor(img); |
|
|
|
}, |
|
|
|
computeBackdropColor() { |
|
|
|
computeBackdropColor(img: HTMLImageElement) { |
|
|
|
// This is being weird and this is the only way I can fix it... |
|
|
|
let rgb: {[k: string]: number} = {r: 0, g: 0, b: 0}; |
|
|
|
try { |
|
|
|
rgb = getAverageRgb(<HTMLImageElement>this.$refs["poster"]); |
|
|
|
rgb = getAverageRgb(img); |
|
|
|
} catch(e) { |
|
|
|
return { r: 0, g: 0, b: 0 }; |
|
|
|
} |
|
|
|