From a2bf9ecd32f164141ed35a92637257ad5839015b Mon Sep 17 00:00:00 2001 From: RubensSantos00 Date: Sat, 7 Aug 2021 00:13:46 -0300 Subject: [PATCH] Filtros --- src/App.js | 70 ++++++++++++++++++++++++++----- src/components/filtros/Filtros.js | 24 +++-------- src/components/produto/Produto.js | 6 ++- 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/src/App.js b/src/App.js index 6022b25..3af451d 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,7 @@ const Main = styled.div` background-color: yellow; ` -const MenuEsquerdo = styled.div` +const SideBar = styled.div` width: 15%; display: flex; background-color: white; @@ -27,24 +27,72 @@ const MenuEsquerdo = styled.div` justify-content: center; ` -export default class App extends React.Component{ - render(){ - return( +const ProductsSection = styled.div` + display: grid; + grid-template-columns: auto auto auto auto; + grid-template-rows :auto ; +` + +export default class App extends React.Component { + state = { + products: [ + {name:'teste', price:500}, + {name:'teste', price:200}, + ], + minprice: 100, + maxprice: 1000, + name: 'Teste' + } + + + onChangeMinPrice = (event) => { + this.setState({ minprice: event.target.value }) + } + onChangeMaxPrice = (event) => { + this.setState({ maxprice: event.target.value }) + } + + onChangeName = (event) => { + this.setState({ name: event.target.value }) + } + + showProducts = () => + this.state.products.map((product,index)=>{ + if(product.price >= this.state.minprice && product.price <= this.state.maxprice){ + return( + + ) + } + }) + + + + render() { + return (
- - - + + + -
- -
+ + {this.showProducts()} +
- ) + ) } } \ No newline at end of file diff --git a/src/components/filtros/Filtros.js b/src/components/filtros/Filtros.js index 14929ea..c4c11b4 100644 --- a/src/components/filtros/Filtros.js +++ b/src/components/filtros/Filtros.js @@ -20,27 +20,15 @@ const Inputs = styled.input` ` class Filtros extends React.Component { - state ={ - maxprice:0, - minprice:0, - name:'' - } - - onChangeMinPrice(event){ - this.setState({minprice:event.target.value}) - } - onChangeMaxPrice(event){ - this.setState({maxprice:event.target.value}) - } - onChangeName(event){ - this.setState({name:event.target.value}) - } + + + render() { return ( - - - + + + ) diff --git a/src/components/produto/Produto.js b/src/components/produto/Produto.js index 46a8a47..674d675 100644 --- a/src/components/produto/Produto.js +++ b/src/components/produto/Produto.js @@ -3,6 +3,7 @@ import styled from 'styled-components' const Wrapper = styled.div` border-style: solid; + height: 350px; ` const Image = styled.img` width: 300px; @@ -13,8 +14,9 @@ class Produtos extends React.Component{ return( -

Nome

-

Preço

+

{this.props.name}

+

{this.props.price}

+
)