movie dispaly added

This commit is contained in:
andres alcocer
2018-11-13 23:27:41 -05:00
parent f496414660
commit 2467695d05
6 changed files with 46 additions and 33 deletions

View File

@@ -1,9 +1,8 @@
import React from 'react'; import React from 'react';
import SearchMovie from "../../containers/SearchMovie/SearchMovie";
const header = () => ( const header = () => (
<header className="header"> <header className="header">
{/* <SearchMovie /> */} */}
</header> </header>
); );

View File

@@ -3,47 +3,42 @@ import Navigation from "./Navigation/Navigation"
import Layout from './Layout/Layout'; import Layout from './Layout/Layout';
import axios from 'axios'; import axios from 'axios';
import MovieRow from '../components/MovieRow/MovieRow' import MovieRow from '../components/MovieRow/MovieRow'
// import SearchMovie from './SearchMovie/SearchMovie';
class App extends Component { class App extends Component {
state = { state = {
myVal: true, myVal: true,
//an array that will hold all of our movies component //an array that will hold all of our movies component
rows: [] rows: []
} }
myB = () => {
this.setState({
myVal: true
})
}
makeAipCall = (searchItem) => { makeAipCall = (searchItem) => {
const url = "https://api.themoviedb.org/3/search/movie?api_key=224ce27b38a3805ecf6f6c36eb3ba9d0&page=1&query=" + searchItem; const url = "https://api.themoviedb.org/3/search/movie?api_key=224ce27b38a3805ecf6f6c36eb3ba9d0&page=1&query=" + searchItem;
axios.get(url) axios.get(url)
.then(res => { .then(res => {
// extract the data from json object // extract the data from json object
console.log(res);
const movies = res.data.results; const movies = res.data.results;
// console.log(movies);
// Holds our movieComponent. // Holds our movieComponent.
let movieRows = []; let movieRows = [];
let total = 0; let total = 0;
movies.forEach((movie) => { movies.forEach((movie) => {
// manually build our image url and set it on the movie object // manually build our image url and set it on the movie object
movie.posterSrc = "https://image.tmdb.org/t/p/w185" + movie.poster_path; if (movie.poster_path !== null) {
total+= 1; movie.posterSrc = "https://image.tmdb.org/t/p/w185" + movie.poster_path;
// pass in the movie object to our MovieRow component and keep it in a variable called // pass in the movie object to our MovieRow component and keep it in a variable called
// movieComponent // movieComponent
const movieComponent = <MovieRow const movieComponent = <MovieRow
val={total} val={total}
key={movie.id} key={movie.id}
movie={movie} movie={movie}/>
/> // push our movieComponent to our movieRows array;
// push our movieComponent to our movieRows array; movieRows.push(movieComponent);
movieRows.push(movieComponent); }
}) })
// update state // update state
this.setState({ rows: movieRows }); this.setState({ rows: movieRows });
@@ -52,14 +47,27 @@ makeAipCall = (searchItem) => {
}); });
} }
myF = (event) => { onSearchHandler = (event) => {
this.setState({ this.setState({
myVal: false myVal: false
}); });
const userInput = event.target.value; const userInput = event.target.value;
this.makeAipCall(userInput); this.makeAipCall(userInput);
console.log(userInput); console.log(userInput);
if (userInput === "") {
this.setState({
myVal: true
});
}
}
onChangeHandler = () => {
// this.setState({
// myVal: true
// })
alert("hello")
} }
@@ -67,11 +75,11 @@ makeAipCall = (searchItem) => {
render() { render() {
return ( return (
<div> <div>
<Navigation showMan={this.myF} /> <Navigation showMovies={this.onSearchHandler} />
{this.state.myVal ? <Layout /> : <div onClick={this.myB} className="search-container">{this.state.rows}</div>} {this.state.myVal ? <Layout /> : <div onClick={this.onChangeHandler}
className="search-container">{this.state.rows}</div>}
</div> </div>

View File

@@ -5,7 +5,6 @@ import MovieShowcase from '../MovieShowcase/MovieShowcase';
import MovieOriginals from '../MovieOriginals/MovieOriginals'; import MovieOriginals from '../MovieOriginals/MovieOriginals';
import Footer from '../../components/Footer/Footer'; import Footer from '../../components/Footer/Footer';
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import SearchMovie from '../../containers/SearchMovie/SearchMovie';
class Layout extends Component { class Layout extends Component {

View File

@@ -44,8 +44,9 @@ class navigation extends Component {
<SearchLogo className="logo" /> <SearchLogo className="logo" />
<input <input
onChange={this.props.showMovies}
className="navigation__container--left__input" className="navigation__container--left__input"
onKeyDown={this.props.showMan} // onKeyPress={this.props.showMan}
type="text" type="text"
placeholder="Title, genres, people" /> placeholder="Title, genres, people" />
@@ -53,7 +54,6 @@ class navigation extends Component {
<NavigationItem link="/">KIDS</NavigationItem> <NavigationItem link="/">KIDS</NavigationItem>
<NavigationItem link="/">DVD</NavigationItem> <NavigationItem link="/">DVD</NavigationItem>
</ul> </ul>
{/* <NavigationItems /> */}
</nav> </nav>
) )
} }

View File

@@ -70,7 +70,6 @@ html {
height: 150%; height: 150%;
padding-bottom: 10rem; padding-bottom: 10rem;
padding-left: 4rem; padding-left: 4rem;
transition: all 5s;
} }

View File

@@ -1,4 +1,5 @@
.movie { .movie {
// z-index: -1;
flex: 1 1 auto; flex: 1 1 auto;
padding-top: 6rem; padding-top: 6rem;
display: inline-block; display: inline-block;
@@ -6,6 +7,13 @@
&__column-poster { &__column-poster {
height: 25rem; height: 25rem;
width: 17.5rem; width: 17.5rem;
cursor: pointer;
transition: transform .3s;
&:hover {
z-index: -1;
transform: scale(1.4);
}
} }