-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP React Cinema Project #10
Open
chrisphillers
wants to merge
10
commits into
constructorlabs:master
Choose a base branch
from
chrisphillers:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b6d38b9
First commit, Films displaying, Search/Fetch
chrisphillers a5ce5ed
More info/slider functionality
chrisphillers df1ad57
committing missing files
chrisphillers aed84b9
pagination, youtube fetch - potential async issue
chrisphillers 6875aec
trailer syntax & async fix
chrisphillers 8edd7e4
error message
chrisphillers bdf7307
slider and pagination functions fix
chrisphillers 9483579
style improvements
chrisphillers 3370a6b
Overall styling
chrisphillers 3989907
Responsiveness/styling improvements
chrisphillers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Hello World</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<link href="https://fonts.googleapis.com/css?family=Encode+Sans:300,400,700" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/css?family=Archivo+Black" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
|
||
<script src="dist/bundle.js"></script> | ||
</body> | ||
|
||
</body> | ||
</html> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,112 @@ | ||
import React from 'react'; | ||
import React from "react"; | ||
import Films from "./Films"; | ||
import Search from "./Search"; | ||
|
||
class App extends React.Component { | ||
constructor(){ | ||
constructor() { | ||
super(); | ||
|
||
this.state = { films: [], pageNum: 1, currentSearchFlim: "love", unFound: {gif: '', h6: ''}, hideButtons: true}; | ||
this.handleNext = this.handleNext.bind(this); | ||
this.handlePrevious = this.handlePrevious.bind(this); | ||
this.fetchIMDB = this.fetchIMDB.bind(this); | ||
// this.filmSearch = this.filmSearch.bind(this); | ||
// this.IMDBData= this.IMDBData.bind(this); | ||
this.notFound = this.notFound.bind(this); | ||
// this.searchText = this.searchText.bind(this); | ||
this.receiveSearch = this.receiveSearch.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
this.receiveSearch(this.state.currentSearchFlim); | ||
|
||
} | ||
|
||
notFound(){ | ||
this.setState({unFound:{gif:'/oops.gif', h6:"Terribly sorry, we couldn't find that"}}); | ||
} | ||
|
||
render(){ | ||
handleNext() { | ||
|
||
// this.setState(prevState =>Object.assign({}, prevState, { pageNum: prevState.pageNum + 1 })) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commented out code should be removed to avoid clutter |
||
// this.setState(prevState => ({...prevState, pageNum: prevState.pageNum + 1})); | ||
// this.setState({pageNum: this.state.pageNum + 1}) | ||
// this.setState( prevState => ({pageNum: prevState.pageNum + 1})) | ||
// this.receiveSearch(this.state.currentSearchFlim) | ||
this.setState({pageNum:this.state.pageNum + 1}, () => this.receiveSearch(this.state.currentSearchFlim)) | ||
|
||
} | ||
|
||
handlePrevious() { | ||
// event.preventDefault(); | ||
// this.setState({pageNum: this.state.pageNum - 1}) | ||
// this.receiveSearch(this.state.currentSearchFlim) | ||
this.setState({pageNum:this.state.pageNum - 1}, () => this.receiveSearch(this.state.currentSearchFlim)) | ||
|
||
} | ||
|
||
receiveSearch(filmSearchQuery) { | ||
this.setState( prevState => ({currentSearchFlim: filmSearchQuery})) | ||
// this.setState(prevState => Object.assign({}, prevState, { currentSearchFlim: filmSearchQuery})) | ||
const searchURL = `https://www.omdbapi.com/?s=${filmSearchQuery}&page=${this.state.pageNum}&apikey=73071eff`; | ||
this.fetchIMDB(searchURL); | ||
|
||
} | ||
|
||
// Initial Search Fetch | ||
fetchIMDB(searchURL) { | ||
fetch(searchURL) | ||
.then( | ||
response => (response.ok ? response.json() : Promise.reject(response)) | ||
) | ||
.then(films => { | ||
if (films.Response === "False") { | ||
this.notFound(); | ||
// alert("WHOOPS!"); | ||
this.setState({ films:[]}); | ||
// this.setState({unfound:{gif: '', h6: ''}}) | ||
} else { | ||
console.log(films); | ||
this.setState({ films: films.Search, unfound: {gif: '', h6: ''}}); //unforund reset not working | ||
// this.setState({pageNum:1}); //pagenum reset not working | ||
} | ||
}) | ||
// .catch(error => console.log("catch error", error)); | ||
} | ||
|
||
|
||
|
||
// hideButtonsFunction(){ | ||
// this.setState({showSlider: false}) | ||
|
||
|
||
|
||
render() { | ||
|
||
|
||
// const buttonsHider = cx('lower__buttons', {'lower__buttons__hidden': this.state.hidebuttons}) | ||
|
||
return ( | ||
<div> | ||
React cinema app | ||
<a name="top"></a> | ||
<span className="nav"> | ||
|
||
<Search receiveSearch={this.receiveSearch} /> | ||
</span> | ||
<div className="oops"> | ||
{this.state.unFound.h6} | ||
<img className="cry" src={this.state.unFound.gif}/> | ||
</div> | ||
<Films films={this.state.films} /> | ||
<div></div> | ||
<div className="lower__buttons__wrapper"> | ||
<button className="lower__button__2" onClick={this.handlePrevious} href="#top">Back</button> | ||
<button className="lower__button__1" onClick={this.handleNext} href="#top" >Next</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. button should not have an href |
||
</div> | ||
<a className="uparrow" href="#top">˄</a> | ||
</div> | ||
) | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
|
||
class Film extends React.Component{ | ||
constructor(){ | ||
super(); | ||
this.state={moreFilmInfo: [], showSlider: false, trailerYoutubeInfo: [], test: [], placeholder: '/placeholder.jpg', failed: true,}; | ||
this.fetchMoreInfo = this.fetchMoreInfo.bind(this); | ||
this.closeSliderFunction = this.closeSliderFunction.bind(this); | ||
// this.trailerVideo = this.trailerVideo.bind(this); | ||
|
||
// this.fallback = () => { | ||
// if (this.props.fallbackSrc) { | ||
// this.setState({ failed: true }); | ||
// } | ||
// }; | ||
|
||
} | ||
|
||
|
||
|
||
//async fetch | ||
fetchMoreInfo(){ | ||
Promise.all([ | ||
fetch(`https://www.omdbapi.com/?i=${this.props.film.imdbID}&apikey=73071eff`), | ||
// fetch(`https://api.themoviedb.org/3/movie/tt0112864/videos?api_key=8aed3c92a5c6ef5e792ffaf51ac22616&language=en-US`), | ||
fetch(`https://api.themoviedb.org/3/movie/${this.props.film.imdbID}/videos?api_key=8aed3c92a5c6ef5e792ffaf51ac22616&language=en-US`), | ||
fetch(`https://www.omdbapi.com/?i=${this.props.film.imdbID}&apikey=73071eff`) | ||
]) | ||
.then(([res1, res2, res3]) => Promise.all([res1.json(), res2.json(), res3.json()])) | ||
.then(([moreFilmInfo, trailerYoutubeInfo, test]) => this.setState({ | ||
moreFilmInfo: moreFilmInfo, | ||
trailerYoutubeInfo: `http://www.youtube.com/embed/${trailerYoutubeInfo.results[0].key}?modestbranding=1&rel=0&iv_load_policy=3&theme=light`, | ||
test: test, | ||
showSlider: true | ||
}) | ||
|
||
); | ||
|
||
} | ||
|
||
// // <p>URL:https://www.youtube.com/watch?v=${this.state.trailerYoutubeInfo}</p> | ||
|
||
// Multiple fetches -> | ||
|
||
// fetchMoreInfo(){ //default for now | ||
// const movieURL = `https://www.omdbapi.com/?i=${this.props.film.imdbID}&apikey=73071eff`; | ||
// fetch(movieURL) | ||
// .then(function(response) { | ||
|
||
// return response.json(); | ||
// }) | ||
// .then(moreFilmInfo=> { | ||
// this.setState({moreFilmInfo: moreFilmInfo, showSlider: true}) | ||
// // console.log(find); | ||
// } | ||
// ); | ||
// // .catch(function(error) { | ||
// // displayErrorToUser3(`${error} ahhhh server problem`); | ||
// // }); | ||
// } | ||
|
||
// trailerVideo(){ //default for now | ||
// const ytURL = `https://api.themoviedb.org/3/movie/${this.props.film.imdbID}/videos?api_key=8aed3c92a5c6ef5e792ffaf51ac22616&language=en-US`; | ||
// fetch(ytURL) | ||
// .then(function(response) { | ||
|
||
// return response.json(); | ||
// }) | ||
// .then(trailerYoutubeInfo=> { | ||
// this.setState({trailerYoutubeInfo: trailerYoutubeInfo}) | ||
// // console.log(find); | ||
// } | ||
// ); | ||
// // .catch(function(error) { | ||
// // displayErrorToUser3(`${error} ahhhh server problem`); | ||
// // }); | ||
// } | ||
|
||
//end of fetches | ||
|
||
closeSliderFunction(){ | ||
this.setState({showSlider: false}) | ||
|
||
|
||
// function to pause trailer video on close | ||
var iframe = element.querySelector( 'iframe'); | ||
var video = element.querySelector( 'video' ); | ||
console.log(iframe); | ||
if ( iframe ) { | ||
var iframeSrc = iframe.src; | ||
iframe.src = iframeSrc; | ||
} | ||
if ( video ) { | ||
video.pause(); | ||
} | ||
|
||
} | ||
|
||
render() { | ||
|
||
// if (this.state.failed) { | ||
// return <img src={this.state.fallbackSrc} />; | ||
// } else { | ||
// return <img src={this.state.src} onError={this.fallback} />; | ||
// } | ||
|
||
// const url = 'https://media.giphy.com/media/l2JJDrvnFUEboRgSQ/giphy.gif'; | ||
// const brokenUrl = url.replace('gif','glif'); | ||
// const fallbackUrl = 'https://media.giphy.com/media/uprwwjptZW4Za/giphy.gif'; | ||
|
||
|
||
|
||
//Slider Toggle | ||
const sliderView = cx('hidden', {'moreInfo': this.state.showSlider}) | ||
// const sliderClose = cx('moreinfo', {'hidden': this.state.showSlider}) | ||
|
||
return ( | ||
|
||
<div className="film" > | ||
<div className="film_results"> | ||
<div className="film__titles"> | ||
<h2>{this.props.film.Title}</h2> | ||
<h3>{this.props.film.Year}</h3> | ||
</div> | ||
<img onClick={this.fetchMoreInfo} id={this.props.film.imdbID} onError={this.state.placeholder} src={this.props.film.Poster} alt=""/> | ||
</div> | ||
|
||
{/* <h2>Broken image:</h2> | ||
<img src={brokenUrl} fallbackSrc={fallbackUrl}/> | ||
<h2>Good image:</h2> | ||
<img src={url} fallbackSrc={fallbackUrl}/> */} | ||
|
||
|
||
{/* <img onClick={this.fetchMoreInfo} id={this.props.film.imdbID} src={this.props.film.Poster === N/A ? this.state.placeholder : this.props.film.Poster} alt=""/> */} | ||
{/* <img onClick={this.fetchMoreInfo} id={this.props.film.imdbID} src={this.props.film.Poster} alt="" ref={img => this.img = img} onError={</img> () => this.img.src = '/placeholder.jpg'/> */} | ||
|
||
<div className={sliderView}> | ||
<div> | ||
<h4 className="closer" onClick={this.closeSliderFunction}>X</h4> | ||
<p className="more__info__title">{this.state.moreFilmInfo.Title}</p> | ||
<div className="more__info__text"> | ||
<p> {this.state.moreFilmInfo.Genre}</p> | ||
<p>{this.state.moreFilmInfo.Plot}</p> | ||
</div> | ||
{/* <p>{this.state.test.Plot}</p> */} | ||
{/* <iframe src="http://www.youtube.com/embed/gQ0uSh2Hgcs?modestbranding=1&showinfo=0&rel=0" width="560" height="315" frameborder="0"></iframe> */} | ||
<iframe className="trailer" src={this.state.trailerYoutubeInfo} frameborder="0"></iframe> | ||
{/* <iframe src=`http://www.youtube.com/embed/${this.state.trailerYoutubeInfo.results[0].key}` width="560" height="315" frameborder="0"></iframe> */} | ||
<p>{this.state.trailerYoutubeInfo.id}</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
); | ||
// console.log(this.state.moreFilmInfo.Plot); | ||
// console.log(this.state.trailerYoutubeInfo); | ||
// console.log(this.state.test); | ||
} | ||
|
||
} | ||
|
||
export default Film; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import Film from './Film'; | ||
|
||
|
||
|
||
class Films extends React.Component { | ||
constructor(){ | ||
super(); | ||
|
||
} | ||
|
||
|
||
render(){ | ||
console.log(this.props.films) | ||
return ( | ||
<div className="films" id="films"> | ||
{this.props.films.map((film, index) => { | ||
return <Film key={index} film={film} />; | ||
})} | ||
|
||
</div> | ||
) | ||
} | ||
} | ||
|
||
|
||
|
||
export default Films; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
|
||
class MoreInfo extends React.Component{ | ||
constructor(){ | ||
super(); | ||
} | ||
|
||
|
||
render(){ | ||
|
||
return ( | ||
<div className="moreInfo" id="moreInfo"> | ||
<h3>{this.props.allInfo.Title}</h3> | ||
|
||
</div> | ||
) | ||
} | ||
} | ||
|
||
|
||
|
||
export default MoreInfo; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to break out each property definition onto own line to make code easier to read