removed Hoc component
This commit is contained in:
@@ -1,24 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react'
|
||||||
|
|
||||||
import Aux from '../../hoc/Aux';
|
import AddIcon from '../../static/images/add.svg'
|
||||||
import AddIcon from '../../static/images/add.svg';
|
import PlayIcon from '../../static/images/play-button.svg'
|
||||||
import PlayIcon from '../../static/images/play-button.svg';
|
|
||||||
|
|
||||||
export default function MovieDetails(props) {
|
export default function MovieDetails(props) {
|
||||||
return (
|
return (
|
||||||
<Aux>
|
<div>
|
||||||
<div className="modal__container">
|
<div className='modal__container'>
|
||||||
<h1 className="modal__title">
|
<h1 className='modal__title'>
|
||||||
{props.movie.title || props.movie.name}
|
{props.movie.title || props.movie.name}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="modal__info">
|
<p className='modal__info'>
|
||||||
<span className="modal__rating">
|
<span className='modal__rating'>
|
||||||
Rating: {props.movie.vote_average * 10}%{' '}
|
Rating: {props.movie.vote_average * 10}%{' '}
|
||||||
</span>
|
</span>
|
||||||
Release date: {props.movie.release_date || props.movie.first_air_date}{' '}
|
Release date: {props.movie.release_date || props.movie.first_air_date}{' '}
|
||||||
Runtime: {props.movie.runtime || props.movie.episode_run_time}m
|
Runtime: {props.movie.runtime || props.movie.episode_run_time}m
|
||||||
</p>
|
</p>
|
||||||
<p className="modal__episode">
|
<p className='modal__episode'>
|
||||||
{props.movie.number_of_episodes
|
{props.movie.number_of_episodes
|
||||||
? ' Episodes: ' + props.movie.number_of_episodes
|
? ' Episodes: ' + props.movie.number_of_episodes
|
||||||
: ''}
|
: ''}
|
||||||
@@ -26,16 +25,16 @@ export default function MovieDetails(props) {
|
|||||||
? ' Seasons: ' + props.movie.number_of_seasons
|
? ' Seasons: ' + props.movie.number_of_seasons
|
||||||
: ''}
|
: ''}
|
||||||
</p>
|
</p>
|
||||||
<p className="modal__overview">{props.movie.overview}</p>
|
<p className='modal__overview'>{props.movie.overview}</p>
|
||||||
<button className="modal__btn modal__btn--red">
|
<button className='modal__btn modal__btn--red'>
|
||||||
<PlayIcon className="modal__btn--icon" />
|
<PlayIcon className='modal__btn--icon' />
|
||||||
Play
|
Play
|
||||||
</button>
|
</button>
|
||||||
<button className="modal__btn">
|
<button className='modal__btn'>
|
||||||
<AddIcon className="modal__btn--icon" />
|
<AddIcon className='modal__btn--icon' />
|
||||||
My List
|
My List
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Aux>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,31 @@
|
|||||||
import React from 'react';
|
import React from 'react'
|
||||||
|
|
||||||
import Aux from '../../hoc/Aux';
|
import Backdrop from './Backdrop'
|
||||||
import Backdrop from './Backdrop';
|
|
||||||
|
|
||||||
export default function Modal(props) {
|
const Modal = ({
|
||||||
|
show,
|
||||||
|
modalClosed,
|
||||||
|
children,
|
||||||
|
movie: { backdrop_path, poster_path },
|
||||||
|
}) => {
|
||||||
const backgroundStyle = {
|
const backgroundStyle = {
|
||||||
backgroundSize: 'cover',
|
backgroundSize: 'cover',
|
||||||
backgroundImage: `url(https://image.tmdb.org/t/p/original/${
|
backgroundImage: `url(https://image.tmdb.org/t/p/original/${
|
||||||
props.movie.backdrop_path || props.movie.poster_path
|
backdrop_path || poster_path
|
||||||
})`,
|
})`,
|
||||||
};
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Aux>
|
<div>
|
||||||
<Backdrop show={props.show} toggleBackdrop={props.modalClosed} />
|
<Backdrop show={show} toggleBackdrop={modalClosed} />
|
||||||
<div
|
<div
|
||||||
style={backgroundStyle}
|
style={backgroundStyle}
|
||||||
className={props.show ? 'modal show' : 'modal hide'}
|
className={show ? 'modal show' : 'modal hide'}
|
||||||
>
|
>
|
||||||
{props.children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</Aux>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Modal
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
const aux = (props) => props.children;
|
|
||||||
|
|
||||||
export default aux;
|
|
||||||
@@ -1,43 +1,39 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import MainContent from '../components/MainContent';
|
import MainContent from '../components/MainContent'
|
||||||
import Modal from '../components/UI/Modal';
|
import Modal from '../components/UI/Modal'
|
||||||
import MovieDetails from '../components/Movie/MovieDetails';
|
import MovieDetails from '../components/Movie/MovieDetails'
|
||||||
|
|
||||||
|
const Home = () => {
|
||||||
|
const [toggleModal, setToggleModal] = useState(false)
|
||||||
|
const [movieOverview, setMovieOverview] = useState({})
|
||||||
|
|
||||||
class Home extends Component {
|
|
||||||
state = {
|
|
||||||
/** Toggles the modal when a movie is clicked. */
|
|
||||||
toggleModal: false,
|
|
||||||
/** Holds the movie information for a single movie. */
|
|
||||||
movieOverview: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Get the appropriate details for a specific movie that was clicked */
|
/* Get the appropriate details for a specific movie that was clicked */
|
||||||
selectMovieHandler = async (movie) => {
|
const selectMovieHandler = async (movie) => {
|
||||||
this.setState({ toggleModal: true });
|
console.log('movei is', movie)
|
||||||
await this.setState({ movieOverview: movie });
|
setToggleModal(true)
|
||||||
};
|
setMovieOverview(movie)
|
||||||
|
|
||||||
closeModal = () => {
|
|
||||||
this.setState({ toggleModal: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="main-content">
|
|
||||||
<MainContent selectMovieHandler={this.selectMovieHandler} />
|
|
||||||
</div>
|
|
||||||
<Modal
|
|
||||||
show={this.state.toggleModal}
|
|
||||||
modalClosed={this.closeModal}
|
|
||||||
movie={this.state.movieOverview}
|
|
||||||
>
|
|
||||||
<MovieDetails movie={this.state.movieOverview} />
|
|
||||||
</Modal>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
setToggleModal(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='main-content'>
|
||||||
|
<MainContent selectMovieHandler={selectMovieHandler} />
|
||||||
|
</div>
|
||||||
|
<Modal
|
||||||
|
show={toggleModal}
|
||||||
|
modalClosed={closeModal}
|
||||||
|
movie={movieOverview}
|
||||||
|
>
|
||||||
|
<MovieDetails movie={movieOverview} />
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Home;
|
export default Home
|
||||||
|
|||||||
Reference in New Issue
Block a user