Skip to content
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

added css phoebedg #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" src="./style.css">
<title>Hello World</title>
</head>
<body>
<div id="root"></div>
<script src="dist/bundle.js"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="./style.css">
<title>React Cinema</title>
</head>

<body>
<div id="root"></div>
<script src="dist/bundle.js"></script>
</body>

</html>
Binary file added moviereel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 45 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
import React from 'react';
import React from "react";
import Search from "./components/Search";
import MovieResults from "./components/MovieResults";
import Info from "./components/Info";

class App extends React.Component {
constructor(){
super();
constructor(props) {
super(props);

this.state = {
movies: [],
moreInfo: []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to initialise moreInfo to empty string if it will store a string

};

this.getMovies = this.getMovies.bind(this);
this.getMoreInfo = this.getMoreInfo.bind(this);
this.hideInfo = this.hideInfo.bind(this);
}

getMovies(result) {
this.setState({
movies: result
});
}

getMoreInfo(result) {
this.setState({
moreInfo: result
});
}

hideInfo() {
this.setState({
moreInfo: ""
});
}

render(){
render() {
return (
<div>
React cinema app
<div className="background">
<Search getMovies={this.getMovies} hideInfo={this.hideInfo} />
<MovieResults
movies={this.state.movies}
getMoreInfo={this.getMoreInfo}
/>
{this.state.moreInfo === "" ? null : (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might not work since moreInfo is initialised to empty array. You could also simplify it to take advantage of empty string being falsy by writing it as !this.state.moreInfo ? null : <Info moreInfo={this.state.moreInfo} />

<Info moreInfo={this.state.moreInfo} />
)}
{/* <Info moreInfo={this.state.moreInfo} /> */}
</div>
)
);
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/components/Info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";

function Info({ moreInfo }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

console.log("moreInfo:", moreInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point: it's good practice to avoid committing console.logs


return (
<div className="infocard">
<ul className="detailedinfo">
<li>Actors: {moreInfo.Actors}</li>
<li>Genre: {moreInfo.Genre}</li>
<li>Director: {moreInfo.Director}</li>
<li>Plot: {moreInfo.Plot}</li>
<li>Released: {moreInfo.Released}</li>
<li>Runtime: {moreInfo.Runtime}</li>
</ul>
</div>
);
}

export default Info;
54 changes: 54 additions & 0 deletions src/components/MovieResult.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from "react";

// let imdb = "https://www.imdb.com/title/";

const omd = {
apiKey: "2c6457b6&",
firstSearch: "red",
url: "http://www.omdbapi.com/"
};

class MovieResult extends React.Component {
constructor(props) {
super(props);

this.handleClick = this.handleClick.bind(this);
}

fetchMoreInfo() {
fetch(`${omd.url}?i=${this.props.movie.imdbID}&apikey=${omd.apiKey}`)
.then(response => response.json())
.then(result => {
this.props.getMoreInfo(result);
})
.catch(error => console.log(error));
}

handleClick(event) {
event.preventDefault();

this.fetchMoreInfo();
}

render() {
return (
<div className="moviecard">
<div className="cardtext">
<a onClick={this.handleClick} href={this.props.movie.Poster}>
<h2 className="movieheading">{this.props.movie.Title}</h2>
</a>
<h3>{this.props.movie.Year}</h3>
</div>
<a href={this.props.movie.imdbID}>
<img
className="poster"
src={this.props.movie.Poster}
alt="Movie Poster"
/>
</a>
</div>
);
}
}

export default MovieResult;
20 changes: 20 additions & 0 deletions src/components/MovieResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import MovieResult from "./MovieResult";

function MovieResults({ movies, getMoreInfo }) {
return (
<div className="movieinfo">
{movies.map(movie => {
return (
<MovieResult
movie={movie}
key={movie.imdbID}
getMoreInfo={getMoreInfo}
/>
);
})}
</div>
);
}

export default MovieResults;
76 changes: 76 additions & 0 deletions src/components/Search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from "react";

const config = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

omd: {
apiKey: "2c6457b6&",
firstSearch: "red",
url: "http://www.omdbapi.com/"
}
};

class Search extends React.Component {
constructor(props) {
super(props);

this.state = {
movie: config.omd.firstSearch
};

this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleClick = this.handleClick.bind(this);
}

fetchMovies() {
fetch(`${config.omd.url}?s=${this.state.movie}&apikey=${config.omd.apiKey}`)
.then(response => response.json())
.then(result => {
this.props.getMovies(result.Search);
})
.catch(error => console.log(error));
}

handleSubmit(event) {
event.preventDefault();
this.fetchMovies();
}

handleChange(event) {
this.setState({
movie: event.target.value
});
}

handleClick(event) {
this.props.hideInfo();
}

componentDidMount() {
this.fetchMovies();
}

render() {
return (
<div className="header">
<h1 className="title">OPEN MOVIE DATABASE SEARCH</h1>
<img
className="moviereel"
src="/Users/phoebedg/workspace/react-cinema/moviereel.png"
alt="Movie Reel"
/>
<form className="form" onSubmit={this.handleSubmit}>
<label />
<input
onClick={this.handleClick}
className="input"
onChange={this.handleChange}
value={this.state.movie}
/>
<button className="button">Go</button>
</form>
</div>
);
}
}

export default Search;
130 changes: 130 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
body {
background-color: crimson;
height: auto;
overflow-y: scroll;
position: relative;
}

.background {
height: auto;
}

.header {
position: fixed;
top: 0px;
z-index: 1;
right: 0;
left: 0;
background-color: crimson;
}

.title {
margin: auto;
text-align: center;
padding-top: 30px;
font-family: "Julius Sans One", sans-serif;
font-size: 75px;
font-weight: bold;
text-shadow: 4px 4px red;
}

.moviereel {
width: 70px;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
border: none;
border-radius: 50%;
box-shadow: 4px 4px red;
}

.form {
margin: auto;
margin-top: 30px;
text-align: center;
padding: 5px;
}

.input {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
border: 2px solid red;
border-radius: 5px;
box-shadow: 4px 4px red;
}

.button {
background-color: white; /* Green */
border: none;
border-radius: 5px;
color: red;
padding: 9.5px 18px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-family: "Roboto", sans-serif;
box-shadow: 4px 4px red;
}

.movieinfo {
display: flex;
margin-top: 100px;
}

.moviecard {
margin: 20px;
margin-top: 250px;
width: 250px;
position: relative;
font-family: "Roboto", sans-serif;
}

.poster {
width: 250px;
height: 370px;
padding-bottom: 10px;
}

.cardtext {
margin: auto;
padding: 10px;
text-align: center;
border-style: solid;
border-width: 1px;
border-color: white;
border-radius: 5px;
font-family: "Roboto", sans-serif;
background-color: rgba(255, 255, 255, 0.5);
box-shadow: 5px 1px 1px red;
}

.movieheading {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kebab case works well for multi-word CSS classes. For example .card-text

height: auto;
}

.infocard {
text-align: center;
height: auto;
padding: 15px;
overflow: auto;
border-style: solid;
border-width: 1px;
border-color: white;
border-radius: 5px;
font-family: "Roboto", sans-serif;
background-color: rgba(255, 255, 255, 0.5);
box-shadow: 5px 1px 1px red;
}

.detailedinfo {
overflow-y: scroll;
margin: auto;
margin-top: 25px;
margin-bottom: 25px;
padding: 10px;
height: auto;
width: 600px;
}