-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathtoken.js
More file actions
39 lines (34 loc) · 936 Bytes
/
token.js
File metadata and controls
39 lines (34 loc) · 936 Bytes
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
var React = require('react');
class Token extends React.Component {
handleClick = () => {
this.props.onRemove(this.props.value)
};
handleKeyDown = (key) => {
var enterKey = 13;
if(key.keyCode === enterKey) this.props.onRemove(this.props.value)
};
ariaLabelRemove = () => {
return this.props.tokenAriaFunc ? this.props.tokenAriaFunc(this.props.name) :
'Remove \'' + this.props.name + '\'';
};
render() {
return (
<li className="ic-token inline-flex">
<span className="ic-token-label">
{this.props.name}
</span>
<span
role="button"
onClick={this.handleClick}
onFocus={this.props.onFocus}
onKeyDown={this.handleKeyDown}
aria-label={this.ariaLabelRemove()}
className="ic-token-delete-button"
tabIndex={0}>
✕
</span>
</li>
);
}
}
module.exports = Token;