MCPcopy Index your code
hub / github.com/Lobos/react-ui / Button

Class Button

src/Button.js:9–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7requireCss('buttons');
8
9class Button extends Component {
10 constructor (props) {
11 super(props);
12 this.state = {
13 disabled: props.disabled,
14 show: null
15 };
16 this.handleClick = this.handleClick.bind(this);
17 }
18
19 componentWillReceiveProps(nextProps) {
20 if (nextProps.disabled !== this.props.disabled) {
21 this.setState({ disabled: nextProps.disabled });
22 }
23 }
24
25 disable(elem) {
26 this.setState({ disabled: true, show: elem });
27 }
28
29 enable(elem) {
30 this.setState({ disabled: false, show: elem });
31 }
32
33 handleClick() {
34 if (this.props.onClick) {
35 this.props.onClick();
36 }
37 if (this.props.once) {
38 this.disable();
39 }
40 }
41
42 render() {
43 let status = this.props.status;
44 if (status) {
45 status = `rct-button-${status}`;
46 }
47
48 const className = classnames(
49 this.props.className,
50 getGrid(this.props.grid),
51 'rct-button',
52 status
53 );
54
55 return (
56 <button onClick={this.handleClick}
57 style={this.props.style}
58 disabled={this.state.disabled}
59 className={className}
60 type={this.props.type || 'button'}>
61 { this.state.show || this.props.children }
62 </button>
63 );
64 }
65}
66

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…