forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic-badge-maker.js
65 lines (59 loc) · 1.64 KB
/
static-badge-maker.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
57
58
59
60
61
62
63
64
65
import React from 'react'
import PropTypes from 'prop-types'
import { staticBadgeUrl } from '../lib/badge-url'
import { InlineInput } from './common'
export default class StaticBadgeMaker extends React.Component {
static propTypes = {
baseUrl: PropTypes.string,
}
state = {
subject: '',
status: '',
color: '',
}
handleSubmit(e) {
e.preventDefault()
const { baseUrl } = this.props
const { subject, status, color } = this.state
const badgeUrl = staticBadgeUrl(
baseUrl || window.location.href,
subject,
status,
color
)
document.location = badgeUrl
}
render() {
return (
<form onSubmit={e => this.handleSubmit(e)}>
<InlineInput
value={this.state.subject}
onChange={event => this.setState({ subject: event.target.value })}
placeholder="subject"
/>
<InlineInput
value={this.state.status}
onChange={event => this.setState({ status: event.target.value })}
placeholder="status"
/>
<InlineInput
value={this.state.color}
onChange={event => this.setState({ color: event.target.value })}
list="default-colors"
placeholder="color"
/>
<datalist id="default-colors">
<option value="brightgreen" />
<option value="green" />
<option value="yellowgreen" />
<option value="yellow" />
<option value="orange" />
<option value="red" />
<option value="lightgrey" />
<option value="blue" />
</datalist>
<button>Make Badge</button>
</form>
)
}
}