2024-05-06 11:33:00 +00:00
|
|
|
import React from "react";
|
|
|
|
import { Movie } from "./movie-wall";
|
2024-05-07 16:58:39 +00:00
|
|
|
import tmdb from "./tmdb";
|
2024-05-23 13:54:06 +00:00
|
|
|
import { WatchProviders, WhereToWatch } from "./whereToWatch";
|
2024-05-19 15:17:30 +00:00
|
|
|
import CrossfadeImage from 'react-crossfade-image'
|
2024-05-22 13:05:38 +00:00
|
|
|
import { Config } from "../App";
|
2024-05-23 13:54:06 +00:00
|
|
|
|
2024-05-06 11:33:00 +00:00
|
|
|
export interface SidebarProps extends React.ComponentPropsWithRef<"div"> {
|
|
|
|
movie: Movie;
|
2024-05-08 17:35:21 +00:00
|
|
|
similarMoviesAvailable: boolean;
|
2024-05-23 13:54:06 +00:00
|
|
|
watchProviders: WatchProviders;
|
2024-05-22 13:05:38 +00:00
|
|
|
config: Config;
|
2024-10-05 15:16:08 +00:00
|
|
|
className: string
|
2024-05-06 11:33:00 +00:00
|
|
|
}
|
2024-10-05 15:16:08 +00:00
|
|
|
export function Sidebar({ movie, similarMoviesAvailable, watchProviders, config, className }: SidebarProps) {
|
2024-05-22 13:05:38 +00:00
|
|
|
const apology = config.language == "es" ?
|
|
|
|
"Resumen no disponible" :
|
|
|
|
config.language == "en" ?
|
|
|
|
"Summary unavailable." :
|
|
|
|
""
|
2024-10-05 15:16:08 +00:00
|
|
|
return <div id="sidebar" className={className}>
|
2024-10-07 16:33:40 +00:00
|
|
|
<div className="sm:h-14 w-fit flex justify-center items-center">
|
|
|
|
<h1 className="font-bold text-base sm:text-lg sm:text-wrap my-1 sm:my-4 overflow-hidden text-center text-balance">{movie?.title ?? "loading"}</h1>
|
|
|
|
</div>
|
2024-10-07 14:18:57 +00:00
|
|
|
<div className="flex flex-row sm:flex-col gap-2 justify-center sm:items-center">
|
|
|
|
<a href={tmdb.makeMovieLink(movie)} target="_blank" rel="noopener noreferrer" className="h-32 sm:h-96 aspect-poster flex justify-center">
|
|
|
|
<CrossfadeImage src={tmdb.makeImgUrl(movie.poster_path ?? "")} style={{
|
|
|
|
objectFit: "clip",
|
2024-10-07 16:33:40 +00:00
|
|
|
height: "100%",
|
|
|
|
apectRatio: "2 / 3"
|
2024-10-07 14:18:57 +00:00
|
|
|
}} />
|
|
|
|
</a>
|
|
|
|
{similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."}
|
2024-10-07 16:33:40 +00:00
|
|
|
<div className="h-32 sm:h-72 w-64 sm:w-full overflow-y-scroll overflow-x-hidden sm:mt-4 p-2 sm:p-4 text-sm sm:text-base flex justify-center items-center border-2 border-slate-800 rounded-lg ">
|
2024-10-07 14:18:57 +00:00
|
|
|
{/* TODO: make the apology vertically centered */}
|
2024-10-07 16:33:40 +00:00
|
|
|
{movie.overview === null ?
|
|
|
|
<p>Loading...</p>
|
|
|
|
: movie.overview === "" ?
|
|
|
|
<p>{apology}</p>
|
|
|
|
:
|
|
|
|
<p className="self-start">{movie.overview}</p>
|
|
|
|
}
|
2024-10-07 14:18:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<WhereToWatch watchProviders={watchProviders} config={config} className="w-full h-16 sm:h-32 flex flex-col justify-center mb-1 sm:mb-4 text-xs sm:text-base" />
|
2024-10-06 21:46:47 +00:00
|
|
|
</div >
|
2024-05-06 11:33:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|