-
Notifications
You must be signed in to change notification settings - Fork 35
basic functionality working, stretch goals still to come. Styling is lacking in areas. #3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="stylesheet" href="./style.css"> | ||
| <title>Hello World</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script src="dist/bundle.js"></script> | ||
| </body> | ||
|
|
||
| <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8" /> | ||
|
|
||
| <link rel="stylesheet" href="./stylesheet.css"> | ||
| <title>Hamzah Cracks React</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="root"></div> | ||
| <script src="dist/bundle.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import React from "react"; | ||
| import Search from "./Search"; | ||
| import Results from "./Results"; | ||
| import MoreInfo from "./MoreInfo"; | ||
|
|
||
| const config = { | ||
|
Contributor
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. nice |
||
| apiKey: "77c3b516", | ||
| url: "http://www.omdbapi.com/?i=" | ||
| }; | ||
|
|
||
| class App extends React.Component { | ||
| constructor(props) { | ||
| super(); | ||
|
|
||
| this.state = { | ||
| films: [], | ||
| showDetailedInfo: false, | ||
| imdbLink: "https://www.imdb.com/title/", | ||
| imdbID: "", | ||
| details: {}, | ||
| errorPic: "./assets/woops.jpg" | ||
|
Contributor
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. if error pic does not change, it could be better off being specified in a config or variable. Reserve state for things that will be changed by your app. Same applies to |
||
| }; | ||
|
|
||
| this.recieveFilmInfo = this.recieveFilmInfo.bind(this); | ||
| this.recieveMoreInfo = this.recieveMoreInfo.bind(this); | ||
| this.closeDetails = this.closeDetails.bind(this); | ||
| } | ||
|
|
||
| recieveFilmInfo(results) { | ||
| this.setState({ | ||
| films: results.Search, | ||
| imdbID: results.Search.imdbID | ||
|
Contributor
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. I am not sure the Search property has an imdbID field as it's an array |
||
| }); | ||
| } | ||
|
|
||
| recieveMoreInfo(imdbID) { | ||
| this.setState({ | ||
| imdbID, | ||
| showDetailedInfo: true | ||
| }); | ||
| this.fetchDetails(imdbID); | ||
| } | ||
|
|
||
| closeDetails(showDetailedInfo) { | ||
| this.setState({ | ||
|
Contributor
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. nice |
||
| showDetailedInfo: false | ||
| }); | ||
| } | ||
|
|
||
| fetchDetails(imdbID) { | ||
| fetch(`${config.url}${imdbID}&plot=small&apikey=${config.apiKey}`) | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| this.setState({ | ||
| details: data | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <div> | ||
| <header> | ||
| <h1 className="header">Hamzah's Online Movie Search Engine</h1> | ||
| </header> | ||
|
|
||
| <Search recieveFilmInfo={this.recieveFilmInfo} /> | ||
| <div className="results_container" id="show_results"> | ||
| <Results | ||
| recieveMoreInfo={this.recieveMoreInfo} | ||
| recieveFavourite={this.recieveFavourite} | ||
| fetchDetails={this.fetchDetails} | ||
| imdbLink={this.state.imdbLink} | ||
| films={this.state.films} | ||
| imdbID={this.state.imdbID} | ||
| errorPic={this.errorPic} | ||
| favourites={this.state.favourites} | ||
| /> | ||
| </div> | ||
| {this.state.showDetailedInfo ? ( | ||
| <MoreInfo | ||
| closeDetails={this.closeDetails} | ||
| details={this.state.details} | ||
| /> | ||
| ) : null} | ||
| <div className="footer"> | ||
| <footer> | ||
| <a | ||
| className="a__links" | ||
| href="http://www.omdbapi.com/" | ||
| target="_blank" | ||
| > | ||
| Powered by OMDB | ||
| </a> | ||
| </footer> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default App; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import React from "react"; | ||
|
|
||
| function MoreInfo({ details, closeDetails }) { | ||
| console.log(details); | ||
|
Contributor
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. Avoid committing console.logs |
||
| return ( | ||
| <div className="more__info"> | ||
| <ul> | ||
| <li key={details.imdbID} className="details__section"> | ||
| <div className="details__mainInfo"> | ||
| <h5>Title: {details.Title}</h5> | ||
| <p>Released: {details.Released}</p> | ||
| <p>Year: {details.Year}</p> | ||
| <p>Rating: {details.Rated}</p> | ||
| <p> | ||
| Voted {details.imdbRating} from {details.imdbVotes} votes | ||
| </p> | ||
| </div> | ||
| <div className="details__actorInfo"> | ||
| <h4>Directed by {details.Director}</h4> | ||
| <p> | ||
| Starring: <br /> | ||
| {details.Actors} | ||
| </p> | ||
| <p>Written by {details.Writer}</p> | ||
| </div> | ||
| <div className="details__plot"> | ||
| <h4> | ||
| Synopsis: <br /> | ||
| {details.Plot} | ||
| </h4> | ||
| </div> | ||
| <button className="button__close" onClick={closeDetails}> | ||
| Close me | ||
| </button> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default MoreInfo; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import React from "react"; | ||
|
|
||
| function Results({ | ||
| films, | ||
| imdbLink, | ||
| recieveMoreInfo, | ||
| recieveFavourite, | ||
| errorPic | ||
| }) { | ||
| return ( | ||
| <div> | ||
| <ul> | ||
| {films.map(film => { | ||
|
Contributor
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. good use of naming conventions |
||
| return ( | ||
| <li key={film.imdbID} className="result_sections"> | ||
| <div className="title"> | ||
| <h2 className="movie_title" id="movie_title"> | ||
| {film.Title} | ||
| </h2> | ||
| <p className="movie_year">{film.Year}</p> | ||
| </div> | ||
| <div className="poster"> | ||
| <a href={`${imdbLink}${film.imdbID}`} target="._blank"> | ||
| <img | ||
| src={film.Poster} | ||
| onError={() => <img src={errorPic} />} | ||
| /> | ||
| </a> | ||
| </div> | ||
| )} | ||
| <div className="more_info"> | ||
| <button onClick={() => recieveMoreInfo(film.imdbID)}> | ||
| More Info | ||
| </button> | ||
| <button className="amazon_link"> | ||
| <a | ||
| className="amazon_link" | ||
| href={`https://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Ddvd&field-keywords=${ | ||
| film.Title | ||
| }`} | ||
| target="_blank" | ||
| > | ||
| Buy Now | ||
| </a> | ||
| </button> | ||
| <button | ||
| onClick={() => recieveFavourite(film.Title)} | ||
| className="favourites" | ||
| > | ||
| Add to Favourites | ||
| </button> | ||
| </div> | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default Results; | ||
|
|
||
| // {film.Poster.value != "N/A" ? ( | ||
|
Contributor
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. Avoid committing commented out code |
||
| // <div className="poster"> | ||
| // <a href={`${imdbLink}${film.imdbID}`} target="_blank"> | ||
| // <img src={film.Poster} /> | ||
| // </a> | ||
| // </div> | ||
| // ) : ( | ||
| // <div className="poster__error"> | ||
| // <a href="#"> | ||
| // <img src={ /> | ||
| // </a> | ||
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.
like it