-
Notifications
You must be signed in to change notification settings - Fork 62
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
Initiate Pull Request #49
Open
RogFed
wants to merge
13
commits into
wizelineacademy:master
Choose a base branch
from
RogFed:development
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.
+11,853
−29
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b9a102f
Initiate Pull Request
RogFed d90a096
Install React Router
RogFed ec5b287
Create Home and Favourites Components
RogFed ae04202
Import BrowserRouter Component, wrap the App Component to start using…
RogFed 72dffa6
Import Route and Switch Components, Implement 2 Routes -> A Home Rout…
RogFed 795b67c
Create SearchBar Component, handle the value update using component s…
RogFed 00cf7bc
Add a few styles just for fun
RogFed 9d9121b
Install Axios, it will be used for API requests
RogFed 3a62c61
Save API Key and url for Giphy requests
RogFed a73045d
DisplayGifs Component, using a lifecycle method make an API Request, …
RogFed 1fd7c14
SingleGif Component recieves props used for rendering different gifs,…
RogFed b46ca8d
Import SearchBar and DisplayGifs components responsible for rendering…
RogFed 7b42f15
Remove unused Component import
RogFed 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
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
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,28 +1,43 @@ | ||
.App { | ||
text-align: center; | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
height: 80px; | ||
html { | ||
font-size: 62.5%; | ||
} | ||
|
||
.App-header { | ||
background-color: #222; | ||
height: 150px; | ||
padding: 20px; | ||
color: white; | ||
body { | ||
font-size: 1.6rem; | ||
background: #0C120C; | ||
} | ||
|
||
.App-title { | ||
font-size: 1.5em; | ||
.HomeView { | ||
padding: 1vh 1vw; | ||
} | ||
|
||
.App-intro { | ||
font-size: large; | ||
.SearchBar input { | ||
width: 100%; | ||
padding: 2vh 1vw; | ||
background: #3C6997; | ||
border: none; | ||
border-radius: 5px; | ||
font-size: 2rem; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { transform: rotate(0deg); } | ||
to { transform: rotate(360deg); } | ||
.SearchBar input::-webkit-input-placeholder { | ||
color: #000; | ||
} | ||
|
||
.DisplayGifs { | ||
padding: 3vh 1vw; | ||
color: #F2C812; | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.SingleGif { | ||
flex-basis: 30%; | ||
margin: 1vh 1vw; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const giphyAPI = { | ||
API_KEY: 'Sa7XeM55KtWebQ4JSASjAax5mDscbodO', | ||
URL: 'https://api.giphy.com/v1/gifs/trending' | ||
} | ||
|
||
export default giphyAPI; |
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,13 @@ | ||
/** | ||
* FavouritesView Component | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
const FavouritesView = () => { | ||
return ( | ||
<h1>FavouritesView</h1> | ||
); | ||
} | ||
|
||
export default FavouritesView; |
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,20 @@ | ||
/** | ||
* HomeView Component | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
//Import Components | ||
import SearchBar from './home/SearchBar'; | ||
import DisplayGifs from './home/DisplayGifs'; | ||
|
||
const HomeView = () => { | ||
return ( | ||
<section className="HomeView"> | ||
<SearchBar /> | ||
<DisplayGifs /> | ||
</section> | ||
); | ||
} | ||
|
||
export default HomeView; |
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,68 @@ | ||
/** | ||
* DisplayGifs Component | ||
*/ | ||
|
||
import React, { Component, Fragment } from 'react'; | ||
import axios from 'axios'; | ||
|
||
import SingleGif from './SingleGif'; | ||
|
||
//import API Request Data | ||
import API_DATA from '../../api'; | ||
|
||
export default class DisplayGifs extends Component { | ||
|
||
constructor(props){ | ||
super(props); | ||
|
||
this.state = { | ||
gifs: {} | ||
} | ||
} | ||
|
||
componentDidMount(){ | ||
this.sendGiphyRequest(API_DATA); | ||
} | ||
|
||
sendGiphyRequest = (data) => { | ||
const { API_KEY, URL } = data; | ||
|
||
axios({ | ||
method: 'get', | ||
url: URL, | ||
params: { | ||
api_key: API_KEY | ||
} | ||
}).then( res => { | ||
this.setState( () => { | ||
return { gifs: res.data }; | ||
} ); | ||
} ).catch( err => { | ||
console.log(err); | ||
} ); | ||
} | ||
|
||
renderSingleGif = () => { | ||
const gifs = this.state.gifs.data; | ||
if(!gifs){ | ||
return; | ||
} | ||
|
||
let singleGif = gifs.map( (gif) => { | ||
const { embed_url, title, id } = gif; | ||
return <SingleGif url={embed_url} title={title} key={id} />; | ||
} ); | ||
|
||
return singleGif; | ||
} | ||
|
||
render(){ | ||
return ( | ||
<section className="DisplayGifs"> | ||
<Fragment> | ||
{this.renderSingleGif()} | ||
</Fragment> | ||
</section> | ||
); | ||
} | ||
} |
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,36 @@ | ||
/** | ||
* SearchBar Component | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
|
||
/** | ||
* SearchBar Component becomes a class based component to handle its value state | ||
*/ | ||
|
||
export default class SearchBar extends Component { | ||
constructor(props){ | ||
super(props); | ||
|
||
this.state = { | ||
term: "" | ||
} | ||
} | ||
|
||
onTermChange = (e) => { | ||
const targetElement = e.target; | ||
const newValue = targetElement.value; | ||
|
||
this.setState( () => { | ||
return { term: newValue } | ||
} ); | ||
} | ||
|
||
render(){ | ||
return ( | ||
<section className="SearchBar"> | ||
<input type="text" value={this.state.term} onChange={ this.onTermChange } placeholder="Search Giphy:" /> | ||
</section> | ||
); | ||
}; | ||
} |
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,18 @@ | ||
/** | ||
* SingleGif Component | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
const SingleGif = (props) => { | ||
return ( | ||
<div className="SingleGif"> | ||
<div style={{ 'width': '100%', 'height': '0', 'paddingBottom': '100%', 'position': 'relative' }}> | ||
<iframe src={props.url} width="100%" height="100%" | ||
style={{ 'position': 'absolute' }} frameBorder="0" className="giphy-embed" allowFullScreen title={props.title}></iframe> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default SingleGif; |
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
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.
I would advise you to keep your key on a
.env
file not versioned and provide an.env.example
to express the usage of the var name.