-
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
weekend react cinema #19
Open
zuberman
wants to merge
2
commits into
constructorlabs:master
Choose a base branch
from
zuberman: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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,58 +1,13 @@ | ||
# React Cinema | ||
React Cinema | ||
|
||
Let's revisit our first project where we built a movie search engine using the Open Movie Database. This time we want to implement it using React. It should be a Single Page App, that is all the functionality should be on a single page, rather switch between multiple pages. | ||
Functionality | ||
-This is a movie title search engine. | ||
-Simply enter your query into the search bar. | ||
-20 movie results will be displayed on search and you can view further movies by clicking on the view next 20 results button as many times as you wish. | ||
-If you want further information on a particular movie, just click on the movie tile. This will display further information on the movie in a pop up. | ||
|
||
Before starting to code produce a diagram using pen and paper of your application which shows both layout and a tree diagram of the components. | ||
|
||
What are some of the components you are going to need? Which components will fetch data and how will that data be displayed? Which components will store state and how will they pass data to other components? Which components should be re-used? Rather than re-implementing your previous solution again have a think about what you have learned in the past week and how you can apply it here. | ||
|
||
You can start coding once your plan has been checked by a TA or instructor. | ||
|
||
## The brief | ||
|
||
We want to create a movie search engine. To power it we will use the [Open Movie Database](http://www.omdbapi.com) API. | ||
|
||
To start using the OMDB API you will first need to sign up with them to receive and API key. The key issued to you will allow you 1000 requests per day and you will need to include this key as part of every request. | ||
|
||
To get started, fork and clone this repo. Please submit a pull request after your first commit and push commits regularly. | ||
|
||
You should complete as many of the following tasks as you can. | ||
|
||
- [ ] Work using mobile first, that is create the mobile version first and add tablet and desktop versions after. | ||
- [ ] Create an HTML page which should have a `form` at the top which contains a text input and a submit button. Below it should have a placeholder element for the returned results. | ||
- [ ] Use JavaScript to capture the `submit` event in your search form, extract the query string from the text input and use that to make an API call to the Open Movie Database API to search for films which match the query string using `fetch`. `console.log` the results | ||
- [ ] Display the data returned by the API including title, year and poster picture | ||
|
||
**Movie details** | ||
|
||
- [ ] Adjust your layout to create room for a detailed view of movie information | ||
- [ ] Capture clicks on your movie results items and use that information to make another request to the API for detailed movie information. Using event delegation will help you here. `console.log` the returned result | ||
- [ ] Display the detailed movie result in the in the details view you created earlier | ||
- [ ] Make your design responsive and ensure it looks great at different screen widths | ||
|
||
**Your own feature** | ||
|
||
- [ ] Implement any feature you would find useful or interesting | ||
|
||
**Stretch goals** | ||
|
||
- [ ] Implement pagination so that users can navigate between all movies in search results rather than just the first ten | ||
- [ ] Create a favourites list. It's up to you how you would add items to favourites. You could add a button or otherwise. Display a list of favourites somewhere on your page. | ||
- [ ] Make the favourites list sortable. Add `up` and `down` buttons to your favourites which on click will move the result in relevant direction | ||
- [ ] Save favourites locally using `localStorage` so that favourites persist in browser after refresh | ||
- [ ] Let's create a search preview. It should listen for input events and submit a search request with current query string. Display the search preview results in an absolute positioned container just below the search box. | ||
Hint: You may want to kick of the searching after at least 3 characters have been typed. | ||
|
||
## Objectives | ||
|
||
* We want to see great looking webpages that work well at all screen widths | ||
* Your code should have consistent indentation and sensible naming | ||
* Use lots of concise, reusable functions with a clear purpose | ||
* Add code comments where it is not immediately obvious what your code does | ||
* Your code should not throw errors and handle edge cases gracefully. For example not break if server fails to return expected results | ||
* Use BEM methodology to style your page | ||
* Try to use pure functions as much as possible, but keep in mind it will not be possible to make all functions pure. | ||
|
||
## README.md | ||
|
||
When finished, include a README.md in your repo. Someone who is not familiar with the project should be able to look at it and understand what it is and what to do with it. Explain functionality created, mention any outstanding issues and possible features you would include if you had more time. List technologies used to create the app. Include a screenshot of your app in the README. | ||
Technical information | ||
-React components are used (Search, Movies, Movie) | ||
-The additional information is shown in a modal. | ||
The OMDB API is used for the movie search. |
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
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,14 +1,74 @@ | ||
import React from 'react'; | ||
import Search from './Search.js' | ||
import Movies from './Movies.js' | ||
|
||
class App extends React.Component { | ||
constructor(){ | ||
super(); | ||
|
||
this.state ={ | ||
pageNumber: 1, | ||
searchQuery: "", | ||
movies: [], | ||
videoClass: "video" | ||
} | ||
|
||
this.apiCall = this.apiCall.bind(this); | ||
this.submittedSearchQuery = this.submittedSearchQuery.bind(this); | ||
this.receivePaginationQuery = this.receivePaginationQuery.bind(this); | ||
this.receiveVideoBlock = this.receiveVideoBlock.bind(this); | ||
} | ||
|
||
componentDidMount(){ | ||
|
||
} | ||
|
||
apiCall(){ | ||
var url = `http://www.omdbapi.com/?apikey=77164d83&s=${this.state.searchQuery}&page=${[this.state.pageNumber]}` | ||
fetch(url) | ||
.then(function(response) { | ||
return response.json(); | ||
}) | ||
.then(body => { | ||
console.log(body.Search) | ||
this.setState({ | ||
movies: body.Search | ||
}) | ||
}) | ||
} | ||
|
||
submittedSearchQuery(search){ | ||
console.log(search) | ||
this.setState({ | ||
pageNumber: 1, | ||
searchQuery: search | ||
},() => this.apiCall() | ||
) | ||
} | ||
|
||
receivePaginationQuery(){ | ||
this.setState({ | ||
pageNumber: ++this.state.pageNumber | ||
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. Calling ++ mutates state. It would be better to use this.state.pageNumber + 1 to increment value |
||
},() => this.apiCall() | ||
) | ||
} | ||
|
||
receiveVideoBlock(){ | ||
this.setState({ | ||
videoClass: "video2" | ||
}) | ||
} | ||
|
||
|
||
render(){ | ||
return ( | ||
<div> | ||
React cinema app | ||
<header><h1>Screen Search</h1></header> | ||
<Search submittedSearchQuery={this.submittedSearchQuery} receivePaginationQuery={this.receivePaginationQuery} receiveVideoBlock={this.receiveVideoBlock}/> | ||
<Movies movies={this.state.movies} /> | ||
<div className="main"> | ||
<video className={this.state.videoClass} src="007.mp4" autoPlay loop muted></video> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
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,152 @@ | ||
body{ | ||
background-color: white;; | ||
color:#555; | ||
font-family:Arial, Helvetica, sans-serif; | ||
font-size:16px; | ||
line-height:1.6em; | ||
margin:0; | ||
} | ||
|
||
header { | ||
background-color: coral; | ||
text-align: center; | ||
color: white; | ||
margin:auto; | ||
overflow:hidden; | ||
font-family: 'Notable', sans-serif; | ||
} | ||
|
||
.searchForm { | ||
padding-top: 15px; | ||
align-content: center; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
|
||
.modal{ | ||
display:none; | ||
position: fixed; | ||
z-index:1; | ||
left: 0; | ||
top:0; | ||
height: 100%; | ||
width:100%; | ||
overflow: auto; | ||
background-color: rgba(0,0,0,0.5); | ||
} | ||
|
||
.modal2{ | ||
display: block; | ||
position: fixed; | ||
z-index:1; | ||
left: 0; | ||
top:0; | ||
height: 100%; | ||
width:100%; | ||
overflow: auto; | ||
background-color: rgba(0,0,0,0.5); | ||
} | ||
|
||
|
||
.modal-content{ | ||
background-color:#f4f4f4; | ||
margin: 20% auto; | ||
width:70%; | ||
box-shadow: 0 5px 8px 0 rgba(0,0,0,0.2),0 7px 20px 0 rgba(0,0,0,0.17); | ||
animation-name:modalopen; | ||
animation-duration:1s; | ||
} | ||
|
||
.modal-header h2, .modal-footer h3{ | ||
margin:0; | ||
} | ||
|
||
.modal-header{ | ||
background:coral; | ||
padding:15px; | ||
color:#fff; | ||
} | ||
|
||
.modal-body{ | ||
padding:10px 20px; | ||
} | ||
|
||
|
||
.button{ | ||
background-color: coral; | ||
padding: 1em 2em; | ||
color: #fff; | ||
border:0; | ||
} | ||
|
||
.button:hover{ | ||
background:#333; | ||
} | ||
|
||
|
||
.closeBtn{ | ||
color:#ccc; | ||
float: right; | ||
font-size: 30px; | ||
} | ||
|
||
.closeBtn:hover,.closeBtn:focus{ | ||
color: #000; | ||
text-decoration: none; | ||
cursor:pointer; | ||
} | ||
|
||
.movieItem { | ||
box-shadow: 10px 10px grey; | ||
margin:30px; | ||
background-color: #f4f4f4; | ||
border: 1px solid; | ||
text-align: center; | ||
overflow-wrap: normal; | ||
max-width: 325px; | ||
} | ||
|
||
h2 { | ||
display: flex; | ||
justify-content: center; | ||
flex-wrap: wrap; | ||
text | ||
} | ||
|
||
.movieItem:hover { | ||
background-color: #C0C0C0; | ||
} | ||
|
||
.movieItem:hover { | ||
z-index: 1.5; | ||
/* width: 300px; | ||
height:300px; */ | ||
} | ||
|
||
#posterImage { | ||
min-width: 300px; | ||
min-height: 460px; | ||
max-width: 325px; | ||
} | ||
|
||
.main { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-around; | ||
} | ||
|
||
.video{ | ||
display: flex; | ||
margin-top: 10px; | ||
height:100vh; | ||
} | ||
|
||
.video2{ | ||
display: none; | ||
} | ||
|
||
@keyframes modalopen{ | ||
from{opacity: 0} | ||
to{opacity: 1} | ||
} |
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.
method is not in use and can be removed