-
Notifications
You must be signed in to change notification settings - Fork 489
/
Copy pathNewCardForm.js
56 lines (50 loc) · 1.52 KB
/
NewCardForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {
CardForm,
CardHeader,
CardRightContent,
CardTitle,
CardWrapper,
Detail
} from 'rt/styles/Base'
import {AddButton, CancelButton} from 'rt/styles/Elements'
import EditableLabel from 'rt/widgets/EditableLabel'
class NewCardForm extends Component {
updateField = (field, value) => {
this.setState({[field]: value})
}
handleAdd = () => {
this.props.onAdd(this.state)
}
render() {
const {onCancel, t} = this.props
return (
<CardForm>
<CardWrapper>
<CardHeader>
<CardTitle>
<EditableLabel placeholder={t('placeholder.title')} onChange={val => this.updateField('title', val)} autoFocus />
</CardTitle>
<CardRightContent>
<EditableLabel placeholder={t('placeholder.label')} onChange={val => this.updateField('label', val)} />
</CardRightContent>
</CardHeader>
<Detail>
<EditableLabel placeholder={t('placeholder.description')} onChange={val => this.updateField('description', val)} />
</Detail>
</CardWrapper>
<AddButton onClick={this.handleAdd}>{t('button.Add card')}</AddButton>
<CancelButton onClick={onCancel}>{t('button.Cancel')}</CancelButton>
</CardForm>
)
}
}
NewCardForm.propTypes = {
onCancel: PropTypes.func.isRequired,
onAdd: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
}
NewCardForm.defaultProps = {
}
export default NewCardForm