From 44366d1e7e633e505ee3b99ff815f31e85bf8073 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 6 Oct 2018 20:49:58 +0200 Subject: [PATCH] Moved properties in dedicated tab --- src/App.css | 13 ++++++- src/Vegetable.js | 34 +++++++++++++++++-- src/Vegetable/Main.js | 6 ---- src/Vegetable/Properties.js | 67 +++++++++++++++++++------------------ 4 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/App.css b/src/App.css index 816adea..61944a3 100644 --- a/src/App.css +++ b/src/App.css @@ -2,7 +2,6 @@ text-align: center; } - @media screen and (min-width: 640px) { input.form-control { margin: 0 16px; @@ -38,3 +37,15 @@ padding: 16px; margin-top: 32px; } + +.form-group, +label { + text-align: left; +} + +.properties--card { + background: #e9ecef; + padding: 6px; + border-radius: 6px; + box-shadow: 4px 4px 16px #999; +} diff --git a/src/Vegetable.js b/src/Vegetable.js index b75f9d3..7fe7831 100644 --- a/src/Vegetable.js +++ b/src/Vegetable.js @@ -25,6 +25,7 @@ import API from './Api'; import VegetableMain from './Vegetable/Main' import VegetableCarousel from './Vegetable/Carousel' import VegetableMap from './Vegetable/Map' +import VegetablesProperties from './Vegetable/Properties' import './Vegetable.css'; import 'react-notifications/lib/notifications.css'; @@ -47,6 +48,7 @@ class Vegetable extends Component { availableProperties: [] }; + this.handleChange = this.handleChange.bind(this); this.getVegetable = this.getVegetable.bind(this); this.updateVegetable = this.updateVegetable.bind(this); this.changeMainPicture = this.changeMainPicture.bind(this); @@ -58,6 +60,19 @@ class Vegetable extends Component { this.getVegetable(props.match.params.categoryId, props.match.params.vegetableId); } + handleChange(event) { + const target = event.target; + const value = target.type === 'checkbox' ? target.checked : target.value; + const name = target.name; + + this.setState(prevState => ({ + Vegetable: { + ...prevState.Vegetable, + [name]: value, + }, + })); + } + toggle(tab) { if (this.state.activeTab !== tab) { this.setState({ @@ -245,13 +260,21 @@ class Vegetable extends Component { className={classnames({ active: this.state.activeTab === '2' })} onClick={() => { this.toggle('2'); }} > - Carte + Propriétés { this.toggle('3'); }} + > + Carte + + + + { this.toggle('4'); }} > Galerie @@ -268,12 +291,19 @@ class Vegetable extends Component { /> + + + - + - -
diff --git a/src/Vegetable/Properties.js b/src/Vegetable/Properties.js index 5b63b7d..6a48f3b 100644 --- a/src/Vegetable/Properties.js +++ b/src/Vegetable/Properties.js @@ -2,13 +2,14 @@ import React, { Component, } from 'react'; import { + Row, + Col, Button, FormGroup, Label, Input, InputGroup, - InputGroupAddon, - Col + InputGroupAddon } from 'reactstrap'; import { FaPlus, @@ -103,7 +104,7 @@ class VegetablesProperties extends Component { break; } } - + return !isSet; } @@ -120,45 +121,47 @@ class VegetablesProperties extends Component { render() { return ( -
+ {this.state.selectedProperties.map( (item , key) => ( - - - + + + + + + ))} + +
+ + + + + + ) + } + return (null) + })} + + + + + - ))} -
- - - - - - {this.state.availableProperties.map( (item, key) => { - if ( this.notSet( item.id ) ) { - return () - } - return (null) - })} - - - - - - - - -
+ + ) }