From df86daef6575ee6c2fa75c67234213e977e89d1e Mon Sep 17 00:00:00 2001 From: andres alcocer Date: Wed, 14 Nov 2018 12:05:26 -0500 Subject: [PATCH] implemented the modal --- src/components/Header/Header.js | 2 +- src/components/MovieRow/MovieRow.js | 3 ++ .../MovieRow/MovieSummary/MovieSummary.js | 26 ++++++++++ src/components/UI/Backdrop/Backdrop.js | 11 +++++ src/components/UI/Modal/Modal.js | 15 ++++++ src/containers/App.js | 48 +++++++++++++------ src/hoc/Aux/Aux.js | 3 ++ src/static/sass/components/_backdrop.scss | 9 ++++ src/static/sass/components/_modal.scss | 25 ++++++++++ src/static/sass/style.scss | 2 + 10 files changed, 128 insertions(+), 16 deletions(-) create mode 100644 src/components/MovieRow/MovieSummary/MovieSummary.js create mode 100644 src/components/UI/Backdrop/Backdrop.js create mode 100644 src/components/UI/Modal/Modal.js create mode 100644 src/hoc/Aux/Aux.js create mode 100644 src/static/sass/components/_backdrop.scss create mode 100644 src/static/sass/components/_modal.scss diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index d402d89..1fb7ace 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -2,7 +2,7 @@ import React from 'react'; const header = () => (
- */} +
); diff --git a/src/components/MovieRow/MovieRow.js b/src/components/MovieRow/MovieRow.js index 6c31810..ec0e1f6 100644 --- a/src/components/MovieRow/MovieRow.js +++ b/src/components/MovieRow/MovieRow.js @@ -1,4 +1,6 @@ import React from 'react'; + + const movieRow = (props) => ( @@ -6,6 +8,7 @@ const movieRow = (props) => (
+ ); diff --git a/src/components/MovieRow/MovieSummary/MovieSummary.js b/src/components/MovieRow/MovieSummary/MovieSummary.js new file mode 100644 index 0000000..7f0081b --- /dev/null +++ b/src/components/MovieRow/MovieSummary/MovieSummary.js @@ -0,0 +1,26 @@ +import React from 'react'; +import Aux from '../../../hoc/Aux/Aux'; + +const movieSummary = (props) => ( + + // // map object into an array of jsx elemenst + // const movieDetails = Object.keys(props.movies) + // .map(movieKey => { + // return

{movieKey}: {props.movies[movieKey]}

+ // }); + + + + {/* */} +

Movie Title

+

rating: 45% realease-date: 2018 runtime: 100m

+

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nemo, delectus! Veniam error perferendis pariatur atque facere? Repudiandae, quia mollitia sapiente + necessitatibus vitae error assumenda maiores perferendis quaerat excepturi voluptatum quidem?

+ + +

staring: mdf gglo bool emmy djf

+

Genres: mdf gglo bool emmy djf

+
+); + +export default movieSummary; \ No newline at end of file diff --git a/src/components/UI/Backdrop/Backdrop.js b/src/components/UI/Backdrop/Backdrop.js new file mode 100644 index 0000000..ae08f71 --- /dev/null +++ b/src/components/UI/Backdrop/Backdrop.js @@ -0,0 +1,11 @@ +import React from 'react'; + + + +const backdrop = (props) => ( + props.show ?
: null +); + +export default backdrop; \ No newline at end of file diff --git a/src/components/UI/Modal/Modal.js b/src/components/UI/Modal/Modal.js new file mode 100644 index 0000000..08a7213 --- /dev/null +++ b/src/components/UI/Modal/Modal.js @@ -0,0 +1,15 @@ +import React from 'react'; +import Aux from '../../../hoc/Aux/Aux'; +import Backdrop from '../Backdrop/Backdrop' + +const modal = (props) => ( + + +
+ {props.children} +
+
+); + +export default modal; \ No newline at end of file diff --git a/src/containers/App.js b/src/containers/App.js index e74920e..f3c32df 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -3,15 +3,18 @@ import Navigation from "./Navigation/Navigation" import Layout from './Layout/Layout'; import axios from 'axios'; import MovieRow from '../components/MovieRow/MovieRow' +import Modal from '../components/UI/Modal/Modal'; +import MovieSummary from '../components/MovieRow/MovieSummary/MovieSummary'; class App extends Component { state = { - myVal: true, + toggleMovieList: true, //an array that will hold all of our movies component - rows: [] + rows: [], + toggleModal: false } makeAipCall = (searchItem) => { @@ -32,6 +35,7 @@ makeAipCall = (searchItem) => { // pass in the movie object to our MovieRow component and keep it in a variable called // movieComponent const movieComponent = @@ -49,7 +53,7 @@ makeAipCall = (searchItem) => { onSearchHandler = (event) => { this.setState({ - myVal: false + toggleMovieList: false }); const userInput = event.target.value; this.makeAipCall(userInput); @@ -57,34 +61,48 @@ makeAipCall = (searchItem) => { if (userInput === "") { this.setState({ - myVal: true + toggleMovieList: true }); } } - onChangeHandler = () => { - // this.setState({ - // myVal: true - // }) - - alert("hello") + selectMovieHandler = () => { + this.setState({toggleModal: true}); + } - - + closeModal = () => { + this.setState({ toggleModal: false }); + } render() { return (
- {this.state.myVal ? :
:
{this.state.rows}
} - + + +
); } } -export default App; \ No newline at end of file +export default App; + + + +// get primary information about movie +//const url = +// "https://api.themoviedb.org/3/search/movie?api_key=224ce27b38a3805ecf6f6c36eb3ba9d0&page=1&query=" + +// searchItem; + +// curl --request GET \ +// --url 'https://api.themoviedb.org/3/movie/503314?api_key=224ce27b38a3805ecf6f6c36eb3ba9d0&language=en-US' \ +// --data '{}' + +// https://api.themoviedb.org/3/movie/{movie_id}?api_key=<>&language=en-US + diff --git a/src/hoc/Aux/Aux.js b/src/hoc/Aux/Aux.js new file mode 100644 index 0000000..fd75392 --- /dev/null +++ b/src/hoc/Aux/Aux.js @@ -0,0 +1,3 @@ +const aux = (props) => props.children; + +export default aux; \ No newline at end of file diff --git a/src/static/sass/components/_backdrop.scss b/src/static/sass/components/_backdrop.scss new file mode 100644 index 0000000..0d19870 --- /dev/null +++ b/src/static/sass/components/_backdrop.scss @@ -0,0 +1,9 @@ +.backdrop { + width: 100%; + height: 100%; + position: fixed; + z-index: 100; + left: 0; + top: 0; + background-color: rgba($color-background, .5); +} \ No newline at end of file diff --git a/src/static/sass/components/_modal.scss b/src/static/sass/components/_modal.scss new file mode 100644 index 0000000..9e78aef --- /dev/null +++ b/src/static/sass/components/_modal.scss @@ -0,0 +1,25 @@ +.modal { + position: fixed; + z-index: 500; + width: 100%; + top: 30%; + left: 0; + height: 42rem; + background: yellowgreen; + transition: all 1s; + transform: scale(0); +} + +.show { + // transform: 50% + transition: transform 1s; + transform: scale(1); + opacity: 1; +} + +.hide { + + transform: translateY(-100vh); + display: none; +} + diff --git a/src/static/sass/style.scss b/src/static/sass/style.scss index 5880ece..6b47bef 100644 --- a/src/static/sass/style.scss +++ b/src/static/sass/style.scss @@ -7,6 +7,8 @@ @import "base/typography"; @import "base/utils"; +@import "components/backdrop"; +@import "components/modal"; @import "components/search"; @import "components/movie"; @import "components/movieOriginals";