-
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
wp:implementación del challenge #68
base: master
Are you sure you want to change the base?
Changes from 10 commits
06b72dc
73ab9aa
d7c0e06
893fb3a
1eb8fea
c78c3f5
45f313a
61b567d
ff62aa2
3928117
dffa157
c68cf01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import React, { Component } from 'react'; | ||
import logo from './logo.svg'; | ||
import {BrowserRouter, Switch, Route} from "react-router-dom"; | ||
import ContainerListGiphy from './giphy/container/container-list-giphy'; | ||
import ContainerGiphysFavorites from './giphy-favorite/container/container-giphys-favorites'; | ||
import NotFound from './giphy/components/not-found'; | ||
import './App.css'; | ||
|
||
class App extends Component { | ||
|
||
export default class App extends Component { | ||
render() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<h1 className="App-title">Welcome to React</h1> | ||
</header> | ||
<p className="App-intro"> | ||
To get started, edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
</div> | ||
<React.Fragment> | ||
<BrowserRouter> | ||
<Switch> | ||
<Route exact path="/" component={ ContainerListGiphy } /> | ||
<Route path="/favorites" component={ ContainerGiphysFavorites } /> | ||
<Route path='*' component={NotFound} /> | ||
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. Not necessary to specify a path, if you live the path empty it will always match, and because the Route is at the end of the switch it will work as expected. |
||
</Switch> | ||
</BrowserRouter> | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export default function GiphyFavorite(props){ | ||
return( | ||
<div> | ||
giphy favorites | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, {Component} from 'react'; | ||
import GiphyFavorite from '../components/giphy-favorite'; | ||
|
||
export default class ContainerGiphysFavorites extends Component{ | ||
|
||
render(){ | ||
return( | ||
<div> | ||
<GiphyFavorite /> | ||
</div> | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.container{ | ||
width: 80%; | ||
margin: auto; | ||
text-align: center; | ||
box-sizing: border-box; | ||
} | ||
.container-giphy{ | ||
display: inline-block; | ||
width: 200px; | ||
height: 200px; | ||
margin:10px 5px 5px 10px; | ||
cursor: pointer; | ||
} | ||
.container-giphy img{ | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.container-giphy p{ | ||
text-align: center; | ||
margin: auto; | ||
right: 0; | ||
position: relative; | ||
font-size: 12px; | ||
} | ||
.input-search{ | ||
background-color: #fff; | ||
box-sizing: border-box; | ||
-webkit-appearance: none; | ||
border-radius: 0; | ||
font-weight: 400; | ||
width: 100%; | ||
border: 0; | ||
margin: 0; | ||
height: 52px; | ||
letter-spacing: 1px; | ||
font-size: 18px; | ||
background-image: url('../../img/search.gif'); | ||
background-repeat: no-repeat; | ||
background-size: 5% 100%; | ||
background-position-x: right; | ||
border: solid gray 1px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import Modal from '../../modal/component/modal'; | ||
import './list-giphy.css'; | ||
|
||
export default function ListGiphy(props){ | ||
return( | ||
<React.Fragment> | ||
<div className="container-giphy" onClick={props.handleOpenModal}> | ||
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. use styled components here |
||
<img src={props.urlGiphy} alt="Giphy"/> | ||
</div> | ||
</React.Fragment> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import image from '../../img/0757.png'; | ||
export default function NotFoud(){ | ||
return( | ||
<div className="container"> | ||
<img src={image} alt="Not Found"/> | ||
<h2>Upss Elemento no encontrado</h2> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import ListGiphy from './list-giphy'; | ||
const GphApiClient = require('giphy-js-sdk-core'); | ||
const client = GphApiClient('STKCOqnN3DKDQJRPbv5il9egmGwZqRSn'); | ||
|
||
// gifs | ||
export default function Search(props){ | ||
let textInput = React.createRef(); | ||
|
||
function handleSearch(e){ | ||
e.preventDefault(); | ||
const valueSearch = textInput.current.value; | ||
|
||
client.search('gifs', {"q": valueSearch.toString()}) | ||
.then((response) => { | ||
response.data.map((urlGiphy) => { | ||
// return( | ||
// <ListGiphy | ||
// urlGiphy={urlGiphy.images.downsized.gif_url} | ||
// /> | ||
// ) | ||
console.log(urlGiphy.images.downsized.gif_url); | ||
}) | ||
}) | ||
.catch((err) => { | ||
|
||
}) | ||
console.log(valueSearch); | ||
} | ||
|
||
return( | ||
<form onSubmit={handleSearch}> | ||
<input | ||
className="input-search" | ||
type="text" | ||
placeholder="Search Giphy" | ||
ref={textInput} | ||
/> | ||
</form> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React,{ Component } from 'react'; | ||
import axios from 'axios'; | ||
import ListGiphy from '../components/list-giphy'; | ||
import Search from '../components/search'; | ||
// import ContainerModal from '../../modal/container/container-modal'; | ||
import Modal from '../../modal/component/modal'; | ||
|
||
const listGiphy = []; | ||
export default class ContainerListGiphy extends Component{ | ||
state = { | ||
dataGiphy:{}, | ||
modalVisible:false, | ||
isFavorite:false, | ||
colorHeart:'gray' | ||
} | ||
handleCloseModal = ()=>{ | ||
this.setState({ | ||
modalVisible:false | ||
}) | ||
} | ||
handleOpenModal = () =>{ | ||
this.setState({ | ||
modalVisible:true | ||
}) | ||
} | ||
favorites = () =>{ | ||
this.setState({ | ||
isFavorite:!this.state.isFavorite, | ||
colorHeart:this.state.isFavorite ? 'red' : 'gray' | ||
}) | ||
} | ||
componentDidMount(){ | ||
// donde q=ryan+gosling parametro que va a buscar y limt = cantidad a mostrar | ||
const url = 'http://api.giphy.com/v1/gifs/trending?&api_key=STKCOqnN3DKDQJRPbv5il9egmGwZqRSn&limit=25'; | ||
axios.get(url) | ||
.then((resultsGiphy) => { | ||
this.setState({ | ||
dataGiphy:resultsGiphy | ||
}) | ||
}) | ||
} | ||
|
||
render(){ | ||
return( | ||
<section className="list-giphy container"> | ||
<Search/> | ||
{ | ||
listGiphy.map((giphy,index) => { | ||
return( | ||
<ListGiphy | ||
key={index} | ||
urlGiphy={giphy.images.downsized.url} | ||
description={giphy.title} | ||
handleOpenModal={this.handleOpenModal} | ||
/> | ||
) | ||
}) | ||
} | ||
{ | ||
this.state.modalVisible && | ||
<Modal | ||
favorites={this.favorites} | ||
handleCloseModal={this.handleCloseModal} | ||
colorHeart={this.state.colorHeart} | ||
listGiphy={listGiphy} | ||
/> | ||
} | ||
</section> | ||
) | ||
} | ||
componentWillUpdate(nextProps, nextState){ | ||
nextState.dataGiphy.data.data.forEach((giphys,index) => { | ||
listGiphy.push(giphys); | ||
}) | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export default function Heart(props){ | ||
return( | ||
<svg style={{fill:`${props.colorHeart}`}} className="heart-svg" onClick={props.favorites}> | ||
<path d="M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223,0,12.425,6.179,13.079,13.543 c0,0,0.353,1.828-0.424,5.119c-1.058,4.482-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021-6.898-11.503 c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2,13.159,2C18.522,2,22.832,5.343,24.85,10.126z"></path> | ||
</svg> | ||
) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.modal { | ||
max-width: 768px; | ||
width: 100%; | ||
margin: 0 auto; | ||
position: fixed; | ||
left: 0; | ||
right: 0; | ||
top: 100px; | ||
background: white; | ||
padding: 20px; | ||
border-radius: 20px; | ||
box-shadow: 0 0 10px rgba(0,0,0,.4); | ||
} | ||
|
||
.modal-close { | ||
width: 30px; | ||
height: 30px; | ||
position: absolute; | ||
right: 21px; | ||
top: 3px; | ||
border-radius: 50%; | ||
border: none; | ||
background: #171c30; | ||
color: white; | ||
cursor: pointer; | ||
} | ||
|
||
.modal-close:after { | ||
content: "X"; | ||
font-weight: bold; | ||
font-size: 20px; | ||
} | ||
.heart-svg{ | ||
fill:#777171; | ||
width: 55px; | ||
height: 55px; | ||
cursor: pointer; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
// import ListGiphy from '../../giphy/components/list-giphy'; | ||
import Heart from '../../icons/components/heart'; | ||
|
||
|
||
import './modal.css'; | ||
|
||
export default function Modal(props){ | ||
console.log(props.listGiphy,'data del modal'); | ||
return( | ||
<div className="modal"> | ||
{/* {props.listGiphy.map((image,index) =>{ | ||
return( | ||
<div> | ||
{console.log(image.images.downsized.url)} | ||
</div> | ||
) | ||
})} */} | ||
{/* <img /> */} | ||
<button className="modal-close" onClick={props.handleCloseModal}></button> | ||
|
||
<section> | ||
<p> | ||
Marca este Giphy como tu favorito | ||
</p> | ||
<div> | ||
<Heart | ||
favorites={props.favorites} | ||
colorHeart={props.colorHeart} | ||
/> | ||
</div> | ||
</section> | ||
</div> | ||
) | ||
} |
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.
Use styled components instead of global css