forked from sjoerdapp/styleguide2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.js
More file actions
executable file
·48 lines (38 loc) · 940 Bytes
/
Copy pathButton.js
File metadata and controls
executable file
·48 lines (38 loc) · 940 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
40
41
42
43
44
45
46
47
48
var React = require('react');
import classNames from 'classnames/bind';
import styles from './Button.styl';
const cx = classNames.bind(styles);
var blacklist = require('blacklist');
module.exports = React.createClass({
propTypes: {
className: React.PropTypes.string,
},
getDefaultProps () {
return {
type: 'default',
size: 'default',
};
},
render () {
// classes
var componentClass = cx(
'button',
'button-' + this.props.type,
'button-' + this.props.size,
this.props.className
);
// props
var props = blacklist(this.props, 'type', 'size', 'className');
props.className = componentClass;
if (this.props.component) {
return React.cloneElement(this.props.component, props);
}
var tag = 'button';
props.type = this.props.submit ? 'submit' : 'button';
if (props.href) {
tag = 'a';
delete props.type;
}
return React.createElement(tag, props, this.props.children);
},
});