Compare commits
2 Commits
bd14b70a45
...
704c8a36d5
Author | SHA1 | Date |
---|---|---|
|
704c8a36d5 | |
|
1af168ddb4 |
15
src/App.tsx
15
src/App.tsx
|
@ -7,6 +7,7 @@ import { Sidebar } from './objects/sidebar'
|
||||||
import { Movie } from './objects/movie-wall'
|
import { Movie } from './objects/movie-wall'
|
||||||
import CrossfadeImage from 'react-crossfade-image'
|
import CrossfadeImage from 'react-crossfade-image'
|
||||||
import { WatchProviders } from './objects/whereToWatch'
|
import { WatchProviders } from './objects/whereToWatch'
|
||||||
|
import useWindowDimensions from './hooks/useWindowDimensions'
|
||||||
|
|
||||||
export type Config = {
|
export type Config = {
|
||||||
language: string,
|
language: string,
|
||||||
|
@ -64,16 +65,24 @@ function App() {
|
||||||
minHeight: "100%",
|
minHeight: "100%",
|
||||||
aspectRatio: "16/9"
|
aspectRatio: "16/9"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { width } = useWindowDimensions()
|
||||||
|
|
||||||
|
function setMoviesHandler(movies: Movie[]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div id="background" className="-z-10 absolute">
|
<div id="background" className="-z-10 absolute">
|
||||||
<CrossfadeImage src={backdrop} style={crossfadeImageStyles} />
|
<CrossfadeImage src={backdrop} style={crossfadeImageStyles} />
|
||||||
</div>
|
</div>
|
||||||
<HamburgerMenu setConfig={setConfig} />
|
<HamburgerMenu setConfig={setConfig} />
|
||||||
<main className="flex justify-center gap-8">
|
<main className="flex justify-center items-center gap-8">
|
||||||
<Sidebar className="flex flex-col" movie={chosenMovie} similarMoviesAvailable={similarMoviesAvailable} watchProviders={watchProviders} config={config} />
|
WIDTH: {width}
|
||||||
|
<Sidebar className="flex flex-col max-w-sm" movie={chosenMovie} similarMoviesAvailable={similarMoviesAvailable} watchProviders={watchProviders} config={config} />
|
||||||
<MovieWall
|
<MovieWall
|
||||||
className="flex flex-wrap gap-2 max-w-6xl"
|
className="flex flex-wrap gap-2 max-w-5xl justify-center"
|
||||||
movies={movies}
|
movies={movies}
|
||||||
setMovies={setMovies}
|
setMovies={setMovies}
|
||||||
config={config}
|
config={config}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
function getWindowDimensions() {
|
||||||
|
const { innerWidth: width, innerHeight: height } = window;
|
||||||
|
return {
|
||||||
|
width,
|
||||||
|
height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useWindowDimensions() {
|
||||||
|
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleResize() {
|
||||||
|
setWindowDimensions(getWindowDimensions());
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
return () => window.removeEventListener('resize', handleResize);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return windowDimensions;
|
||||||
|
}
|
|
@ -82,9 +82,7 @@ function Poster({ className, movie, config, listSimilar, setMovies, setChosenMov
|
||||||
{isLoading ?
|
{isLoading ?
|
||||||
<div className="m-auto text-center h-full w-full fixed">
|
<div className="m-auto text-center h-full w-full fixed">
|
||||||
<div className="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>
|
<div className="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>
|
||||||
: <div className="z-10 h-full w-full absolute cursor-pointer" onClick={() => clickHandler()}>
|
: <div className="z-10 h-full w-full absolute cursor-pointer" onClick={() => clickHandler()}></div>
|
||||||
hello
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
{hasError ?? <div className="m-auto text-center">⚠️</div>}
|
{hasError ?? <div className="m-auto text-center">⚠️</div>}
|
||||||
<img
|
<img
|
||||||
|
|
|
@ -24,7 +24,7 @@ export function Sidebar({ movie, similarMoviesAvailable, watchProviders, config,
|
||||||
<CrossfadeImage src={tmdb.makeImgUrl(movie.poster_path ?? "")} containerClass="chosen-movie-poster" style={{ objectFit: "cover", height: "100%" }} />
|
<CrossfadeImage src={tmdb.makeImgUrl(movie.poster_path ?? "")} containerClass="chosen-movie-poster" style={{ objectFit: "cover", height: "100%" }} />
|
||||||
</a>
|
</a>
|
||||||
{similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."}
|
{similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."}
|
||||||
<p id="summary">{movie.overview === null ? "Loading"
|
<p id="summary" className="">{movie.overview === null ? "Loading"
|
||||||
: movie.overview === "" ? apology
|
: movie.overview === "" ? apology
|
||||||
: movie.overview}
|
: movie.overview}
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue