improve sidebar styling

This commit is contained in:
andrzej 2024-05-19 17:17:30 +02:00
parent 051f8adcfb
commit f17b85a033
4 changed files with 66 additions and 33 deletions

View File

@ -48,30 +48,45 @@ main {
#sidebar { #sidebar {
flex-basis: calc(var(--poster-width)*2); flex-basis: 20%;
max-height: 100%;
min-height: 100%;
font-size: 1.6rem; font-size: 1.6rem;
text-align: center;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
min-height: 100%; display: grid;
display: flex;
flex-direction: column; grid-template-rows: 1fr 2fr 2fr 1fr;
justify-content: space-evenly; ;
align-content: stretch;
h1 { h1 {
font-size: 2em; font-size: 2em;
margin: 0; margin: 1rem 0 0 0;
/* line-height: 0.8em; */
font-family: RobotoBold; font-family: RobotoBold;
padding: 0.1em 0.2em 0.1em 0.2em; padding: 0.1em 0.2em 0.1em 0.2em;
align-self: flex-start; grid-row: 1/ span 1;
overflow: hidden;
}
figure {
width: 100%;
margin: 0;
grid-row: 2/ span 1;
place-self: center;
.chosen-movie-poster {
aspect-ratio: 2/3;
max-width: 100%;
max-height: 100%;
}
} }
#summary { #summary {
overflow: scroll; overflow: scroll;
flex-grow: 2;
max-height: 24rem; max-height: 24rem;
grid-row: 3/ span 1;
} }
p { p {
@ -80,14 +95,8 @@ main {
margin: 0.1em 0.2em 0.1em 0.2em; margin: 0.1em 0.2em 0.1em 0.2em;
} }
figure { footer {
width: 100%; grid-row: 4/ span 1;
margin: 0;
img {
aspect-ratio: 2/3;
}
} }
} }
@ -160,20 +169,36 @@ main {
filter: blur(1rem) brightness(0.4); filter: blur(1rem) brightness(0.4);
} }
#watch-providers { #watch-providers-container {
max-width: 100%;
display: flex; display: flex;
gap: 0.2rem;
justify-content: space-around;
.watch-providers {
text-align: center;
border: 1rem white;
h1 {
font-size: 1.6rem;
}
h1 {
font-size: 1.6rem;
} }
.watch-logos-container { .watch-logos-container {
display: flex; display: flex;
flex-wrap: nowrap;
gap: 0.4rem; gap: 0.4rem;
justify-content: center;
.watch-logo { .watch-logo {
width: 30px;
aspect-ratio: 1/1; aspect-ratio: 1/1;
max-height: 2rem;
img {
width: 100%;
}
} }
} }

View File

@ -2,6 +2,7 @@ import React from "react";
import { Movie } from "./movie-wall"; import { Movie } from "./movie-wall";
import tmdb from "./tmdb"; import tmdb from "./tmdb";
import { WhereToWatch } from "./whereToWatch"; import { WhereToWatch } from "./whereToWatch";
import CrossfadeImage from 'react-crossfade-image'
export interface SidebarProps extends React.ComponentPropsWithRef<"div"> { export interface SidebarProps extends React.ComponentPropsWithRef<"div"> {
movie: Movie; movie: Movie;
similarMoviesAvailable: boolean; similarMoviesAvailable: boolean;
@ -12,7 +13,7 @@ export function Sidebar({ movie, similarMoviesAvailable, watchProviders }: Sideb
<h1>{movie?.title ?? "loading"}</h1> <h1>{movie?.title ?? "loading"}</h1>
<figure> <figure>
<a href={tmdb.makeMovieLink(movie)} target="_blank" rel="noopener noreferrer"> <a href={tmdb.makeMovieLink(movie)} target="_blank" rel="noopener noreferrer">
<img src={tmdb.makeImgUrl(movie.poster_path ?? "")} /> <CrossfadeImage src={tmdb.makeImgUrl(movie.poster_path ?? "")} containerClass="chosen-movie-poster" />
</a> </a>
<figcaption> <figcaption>
{similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."} {similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."}

View File

@ -25,7 +25,6 @@ export default {
page page
} }
}) })
console.log(res)
if (res.status === 200) { if (res.status === 200) {
res = res.data.results res = res.data.results
callback(res) callback(res)
@ -44,7 +43,6 @@ export default {
page page
} }
}) })
console.log(res)
if (res.status === 200) { if (res.status === 200) {
const array: Array<Movie> = res.data.results const array: Array<Movie> = res.data.results
.filter((e: Movie) => { .filter((e: Movie) => {

View File

@ -61,26 +61,35 @@ interface ProviderIconsProps extends React.ComponentPropsWithRef<"div"> {
} }
function ProviderIcons({ providerList, link }: ProviderIconsProps) { function ProviderIcons({ providerList, link }: ProviderIconsProps) {
const list = providerList.map((e: any, i: number) => { const list = providerList.map((e: any, i: number) => {
return <a href={link}><img src={tmdb.makeLogoPath(e.logo_path)} className="watch-logo" key={e.provider_id + "_" + i} /></a> return <div className="watch-logo">
<a href={link}>
<img src={tmdb.makeLogoPath(e.logo_path)} key={e.provider_id + "_" + i} /></a>
</div>
}) })
return <div className="watch-logos-container"> return <div className="watch-logos-container">
{list} {list}
</div> </div>
} }
function watchProvidersExist(watchProviders: any) {
return watchProviders?.link
}
export function WhereToWatch({ watchProviders }: WhereToWatchProps) { export function WhereToWatch({ watchProviders }: WhereToWatchProps) {
if (!watchProviders?.link) { console.log("Watch providers exist?" + watchProvidersExist(watchProviders))
if (!watchProvidersExist(watchProviders)) {
console.group() console.group()
console.log("Watch providers (WhereToWatch)") console.log("Watch providers (WhereToWatch)")
console.log(watchProviders) console.log(watchProviders)
console.groupEnd() console.groupEnd()
return <div id="no-watch"></div> return <p>Por el momento no hay opciónes streaming.</p>
} }
return <><div id="watch-providers"> return <><footer id="sidebar-footer">
{watchProviders?.flatrate?.length > 0 ? <div><h1>Streaming:</h1><ProviderIcons providerList={watchProviders.flatrate} link={watchProviders.link} /></div> : ""} <div id="watch-providers-container">
{watchProviders?.rent?.length > 0 ? <div><h1>Alquiler:</h1><ProviderIcons providerList={watchProviders.rent} link={watchProviders.link} /></div> : ""} {watchProviders?.flatrate?.length > 0 ? <div className="watch-providers"><h1>Streaming:</h1><ProviderIcons providerList={watchProviders.flatrate} link={watchProviders.link} /></div> : ""}
{watchProviders?.buy?.length > 0 ? <div><h1>Comprar:</h1><ProviderIcons providerList={watchProviders.buy} link={watchProviders.link} /></div> : ""} {watchProviders?.rent?.length > 0 ? <div className="watch-providers"><h1>Alquiler:</h1><ProviderIcons providerList={watchProviders.rent} link={watchProviders.link} /></div> : ""}
</div> {watchProviders?.buy?.length > 0 ? <div className="watch-providers"><h1>Comprar:</h1><ProviderIcons providerList={watchProviders.buy} link={watchProviders.link} /></div> : ""}
</div>
<p>Powered by Just Watch.</p> <p>Powered by Just Watch.</p>
</footer>
</> </>
} }