From 2467695d055cbaf25e8a9fc1611f46ece65b40a8 Mon Sep 17 00:00:00 2001 From: andres alcocer Date: Tue, 13 Nov 2018 23:27:41 -0500 Subject: [PATCH] movie dispaly added --- src/components/Header/Header.js | 3 +- src/containers/App.js | 62 ++++++++++++++----------- src/containers/Layout/Layout.js | 1 - src/containers/Navigation/Navigation.js | 4 +- src/static/sass/base/_base.scss | 1 - src/static/sass/components/_movie.scss | 8 ++++ 6 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index bdd45fd..d402d89 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -1,9 +1,8 @@ import React from 'react'; -import SearchMovie from "../../containers/SearchMovie/SearchMovie"; const header = () => (
- {/* */} + */}
); diff --git a/src/containers/App.js b/src/containers/App.js index 0084275..e74920e 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -3,47 +3,42 @@ import Navigation from "./Navigation/Navigation" import Layout from './Layout/Layout'; import axios from 'axios'; import MovieRow from '../components/MovieRow/MovieRow' -// import SearchMovie from './SearchMovie/SearchMovie'; + + class App extends Component { state = { myVal: true, - //an array that will hold all of our movies component + //an array that will hold all of our movies component rows: [] } - myB = () => { - this.setState({ - myVal: true - }) - } - - - - makeAipCall = (searchItem) => { const url = "https://api.themoviedb.org/3/search/movie?api_key=224ce27b38a3805ecf6f6c36eb3ba9d0&page=1&query=" + searchItem; axios.get(url) .then(res => { // extract the data from json object + console.log(res); const movies = res.data.results; + // console.log(movies); // Holds our movieComponent. let movieRows = []; let total = 0; movies.forEach((movie) => { // manually build our image url and set it on the movie object - movie.posterSrc = "https://image.tmdb.org/t/p/w185" + movie.poster_path; - total+= 1; - // pass in the movie object to our MovieRow component and keep it in a variable called - // movieComponent - const movieComponent = - // push our movieComponent to our movieRows array; - movieRows.push(movieComponent); + if (movie.poster_path !== null) { + 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 + // movieComponent + const movieComponent = + // push our movieComponent to our movieRows array; + movieRows.push(movieComponent); + } + }) // update state this.setState({ rows: movieRows }); @@ -52,14 +47,27 @@ makeAipCall = (searchItem) => { }); } - myF = (event) => { - + onSearchHandler = (event) => { this.setState({ myVal: false }); const userInput = event.target.value; this.makeAipCall(userInput); console.log(userInput); + + if (userInput === "") { + this.setState({ + myVal: true + }); + } + } + + onChangeHandler = () => { + // this.setState({ + // myVal: true + // }) + + alert("hello") } @@ -67,11 +75,11 @@ makeAipCall = (searchItem) => { render() { - return (
- - {this.state.myVal ? :
{this.state.rows}
} + + {this.state.myVal ? :
{this.state.rows}
}
diff --git a/src/containers/Layout/Layout.js b/src/containers/Layout/Layout.js index 29a5eda..0f6c974 100644 --- a/src/containers/Layout/Layout.js +++ b/src/containers/Layout/Layout.js @@ -5,7 +5,6 @@ import MovieShowcase from '../MovieShowcase/MovieShowcase'; import MovieOriginals from '../MovieOriginals/MovieOriginals'; import Footer from '../../components/Footer/Footer'; import { BrowserRouter } from "react-router-dom"; -import SearchMovie from '../../containers/SearchMovie/SearchMovie'; class Layout extends Component { diff --git a/src/containers/Navigation/Navigation.js b/src/containers/Navigation/Navigation.js index a4d1894..7da0516 100644 --- a/src/containers/Navigation/Navigation.js +++ b/src/containers/Navigation/Navigation.js @@ -44,8 +44,9 @@ class navigation extends Component { @@ -53,7 +54,6 @@ class navigation extends Component { KIDS DVD - {/* */} ) } diff --git a/src/static/sass/base/_base.scss b/src/static/sass/base/_base.scss index 8a66b08..8d1e4cc 100644 --- a/src/static/sass/base/_base.scss +++ b/src/static/sass/base/_base.scss @@ -70,7 +70,6 @@ html { height: 150%; padding-bottom: 10rem; padding-left: 4rem; - transition: all 5s; } diff --git a/src/static/sass/components/_movie.scss b/src/static/sass/components/_movie.scss index 7750d46..a6e98f7 100644 --- a/src/static/sass/components/_movie.scss +++ b/src/static/sass/components/_movie.scss @@ -1,4 +1,5 @@ .movie { + // z-index: -1; flex: 1 1 auto; padding-top: 6rem; display: inline-block; @@ -6,6 +7,13 @@ &__column-poster { height: 25rem; width: 17.5rem; + cursor: pointer; + transition: transform .3s; + + &:hover { + z-index: -1; + transform: scale(1.4); + } }