Extract the numeric input as single component
This commit is contained in:
parent
e8c78539ae
commit
71d66fdb74
|
|
@ -0,0 +1,48 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {Button, InputGroup, InputGroupAddon, Input} from 'reactstrap';
|
||||
import '../../static/css/numericinput.css';
|
||||
|
||||
export default class NumericInput extends React.Component {
|
||||
render() {
|
||||
return (<InputGroup>
|
||||
<InputGroupAddon addonType="prepend">
|
||||
<Button onClick={this.props.decrementCallback} className="btn-width" color={this.props.decrementColor}
|
||||
outline={this.props.decrementOutline}>{this.props.decrementText}</Button>
|
||||
</InputGroupAddon>
|
||||
<Input className='font-weight-bold' value={this.props.value}
|
||||
disabled type='number'/>
|
||||
<InputGroupAddon addonType="append">
|
||||
<Button onClick={this.props.incrementCallback} className="btn-width" color={this.props.incrementColor}
|
||||
outline={this.props.incrementOutline}>{this.props.incrementText}</Button>
|
||||
</InputGroupAddon>
|
||||
</InputGroup>);
|
||||
}
|
||||
}
|
||||
|
||||
NumericInput.propTypes = {
|
||||
decrementText: PropTypes.string.isRequired,
|
||||
decrementCallback: PropTypes.func.isRequired,
|
||||
decrementColor: PropTypes.oneOf([
|
||||
'primary', 'secondary', 'success', 'info', 'warning', 'danger'
|
||||
]),
|
||||
decrementOutline: PropTypes.bool,
|
||||
|
||||
|
||||
incrementText: PropTypes.string.isRequired,
|
||||
incrementCallback: PropTypes.func.isRequired,
|
||||
incrementColor: PropTypes.oneOf([
|
||||
'primary', 'secondary', 'success', 'info', 'warning', 'danger'
|
||||
]),
|
||||
incrementOutline: PropTypes.bool,
|
||||
|
||||
value: PropTypes.number.isRequired
|
||||
};
|
||||
|
||||
NumericInput.defaultProps = {
|
||||
decrementColor: 'primary',
|
||||
decrementOutline: true,
|
||||
|
||||
incrementColor: 'primary',
|
||||
incrementOutline: true
|
||||
};
|
||||
|
|
@ -3,16 +3,15 @@ import React from 'react';
|
|||
import {notify} from 'react-notify-toast';
|
||||
import {connect} from 'react-redux';
|
||||
import posed from 'react-pose';
|
||||
import {Button, Card, CardBody, Container, CustomInput, Form, FormGroup,
|
||||
Input, InputGroup, InputGroupAddon, Label} from 'reactstrap';
|
||||
import {Button, Card, CardBody, Col, Container, CustomInput, Form, FormGroup, Input, Label} from 'reactstrap';
|
||||
import {TurniereNavigation} from '../js/components/Navigation';
|
||||
import {Footer} from '../js/components/Footer';
|
||||
import EditableStringList from '../js/components/EditableStringList';
|
||||
import {createTournament} from '../js/api';
|
||||
|
||||
import '../static/css/everypage.css';
|
||||
import '../static/css/create.css';
|
||||
import RequireLogin from '../js/components/RequireLogin';
|
||||
import NumericInput from '../js/components/NumericInput';
|
||||
|
||||
class CreatePage extends React.Component {
|
||||
render() {
|
||||
|
|
@ -109,34 +108,20 @@ class CreateTournamentForm extends React.Component {
|
|||
className="groupphasefader">
|
||||
<FormGroup>
|
||||
<Label for="teams-per-group">Anzahl Teams pro Gruppe</Label>
|
||||
<InputGroup>
|
||||
<InputGroupAddon addonType="prepend">
|
||||
<Button onClick={this.decreaseGroupSize} className="btn-width"
|
||||
color='primary' outline>-1</Button>
|
||||
</InputGroupAddon>
|
||||
<Input className='font-weight-bold' value={this.state.groupSize}
|
||||
disabled type='number' step='1' placeholder='0'/>
|
||||
<InputGroupAddon addonType="append">
|
||||
<Button onClick={this.increaseGroupSize} className="btn-width"
|
||||
color='primary' outline>+1</Button>
|
||||
</InputGroupAddon>
|
||||
</InputGroup>
|
||||
<Col xs="3" className="pl-0">
|
||||
<NumericInput value={this.state.groupSize}
|
||||
incrementText="+1" incrementCallback={this.increaseGroupSize}
|
||||
decrementText="-1" decrementCallback={this.decreaseGroupSize}/>
|
||||
</Col>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Label for="teams-group-to-playoff">Wie viele Teams sollen nach der Gruppenphase
|
||||
weiterkommen?</Label>
|
||||
<InputGroup>
|
||||
<InputGroupAddon addonType="prepend">
|
||||
<Button onClick={this.decreaseGroupAdvance} className="btn-width"
|
||||
color='primary' outline>÷2</Button>
|
||||
</InputGroupAddon>
|
||||
<Input className='font-weight-bold' value={this.state.groupAdvance}
|
||||
disabled type='number' step='1' placeholder='0'/>
|
||||
<InputGroupAddon addonType="append">
|
||||
<Button onClick={this.increaseGroupAdvance} className="btn-width"
|
||||
color='primary' outline>×2</Button>
|
||||
</InputGroupAddon>
|
||||
</InputGroup>
|
||||
<Col xs="3" className="pl-0">
|
||||
<NumericInput value={this.state.groupAdvance}
|
||||
incrementText="×2" incrementCallback={this.increaseGroupAdvance}
|
||||
decrementText="÷2" decrementCallback={this.decreaseGroupAdvance}/>
|
||||
</Col>
|
||||
</FormGroup>
|
||||
</GroupphaseFader>
|
||||
</Form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue