2024-05-06 11:33:00 +00:00
import React from "react"
2024-05-06 09:09:21 +00:00
import { Config } from "../App"
import tmdb from "./tmdb"
2024-05-06 11:33:00 +00:00
import { makeImgUrl } from "../functions"
2024-05-02 20:47:28 +00:00
2024-05-06 09:09:21 +00:00
export type Movie = {
id : number
2024-05-02 20:47:28 +00:00
poster_path : string
title : string
overview : string
}
const sampleData = {
adult : false ,
backdrop_path : "/jnE1GA7cGEfv5DJBoU2t4bZHaP4.jpg" ,
genre_ids : [ 28 , 878 ] ,
id : 1094844 ,
original_language : "en" ,
original_title : "Ape vs. Mecha Ape" ,
overview : "Recognizing the destructive power of its captive giant Ape, the military makes its own battle-ready A.I., Mecha Ape. But its first practical test goes horribly wrong, leaving the military no choice but to release the imprisoned giant ape to stop the colossal robot before it destroys downtown Chicago." ,
popularity : 2157.099 ,
poster_path : "/dJaIw8OgACelojyV6YuVsOhtTLO.jpg" ,
release_date : "2023-03-24" ,
title : "Ape vs. Mecha Ape" ,
video : false ,
vote_average : 5.538 ,
vote_count : 52
}
2024-05-05 21:59:33 +00:00
interface MovieWallProps extends React . ComponentPropsWithRef < "div" > {
movies : Array < Movie > ;
setMovies : Function ;
2024-05-06 09:09:21 +00:00
config : Config ;
2024-05-05 21:59:33 +00:00
}
2024-05-06 09:09:21 +00:00
export function MovieWall ( { movies , setMovies , config } : MovieWallProps ) {
2024-05-05 21:59:33 +00:00
const posters : Array < React.Component > = [ ]
2024-05-02 20:47:28 +00:00
for ( let i = 0 ; i < movies . length ; i ++ ) {
posters . push (
2024-05-06 09:09:21 +00:00
< Poster movie = { movies [ i ] } key = { movies [ i ] . id } index = { i } listSimilar = { tmdb . getSimilar } config = { config } setMovies = { setMovies } / >
2024-05-02 20:47:28 +00:00
)
}
return < >
{ posters }
< / >
}
2024-05-05 21:59:33 +00:00
interface PosterProps extends React . ComponentPropsWithRef < "div" > {
2024-05-02 20:47:28 +00:00
movie : Movie ;
2024-05-06 09:09:21 +00:00
listSimilar : Function ;
2024-05-05 21:59:33 +00:00
index : number ;
2024-05-06 09:09:21 +00:00
config : Config ;
setMovies : Function ;
2024-05-02 20:47:28 +00:00
}
2024-05-05 21:59:33 +00:00
2024-05-06 09:09:21 +00:00
function Poster ( { movie , config , listSimilar , setMovies } : PosterProps ) {
2024-05-06 11:33:00 +00:00
const style = {
backgroundImage : makeImgUrl ( movie . poster_path ) ,
2024-05-05 21:59:33 +00:00
backgroundSize : "cover" ,
2024-05-06 11:33:00 +00:00
// alignSelf: "auto",
2024-05-05 21:59:33 +00:00
color : "inherit"
2024-05-06 11:33:00 +00:00
}
2024-05-05 21:59:33 +00:00
return < div className = "poster" style = { style } >
2024-05-06 09:09:21 +00:00
< div className = "overlay" onClick = { ( ) = > { listSimilar ( config , movie , setMovies ) } } >
2024-05-05 21:59:33 +00:00
< / div >
< / div >
2024-05-02 20:47:28 +00:00
}