forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueish-badge.js
42 lines (37 loc) · 1022 Bytes
/
issueish-badge.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
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import Octicon from '../atom/octicon';
const typeAndStateToIcon = {
Issue: {
OPEN: 'issue-opened',
CLOSED: 'issue-closed',
},
PullRequest: {
OPEN: 'git-pull-request',
CLOSED: 'git-pull-request',
MERGED: 'git-merge',
},
};
export default class IssueishBadge extends React.Component {
static propTypes = {
type: PropTypes.oneOf([
'Issue', 'PullRequest', 'Unknown',
]).isRequired,
state: PropTypes.oneOf([
'OPEN', 'CLOSED', 'MERGED', 'UNKNOWN',
]).isRequired,
}
render() {
const {type, state, ...others} = this.props;
const icons = typeAndStateToIcon[type] || {};
const icon = icons[state] || 'question';
const {className, ...otherProps} = others;
return (
<span className={cx(className, 'github-IssueishBadge', state.toLowerCase())} {...otherProps}>
<Octicon icon={icon} />
{state.toLowerCase()}
</span>
);
}
}