forked from mu29/react-stepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
65 lines (59 loc) · 1.59 KB
/
example.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
'use strict';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Stepper from '../src/index.js';
class App extends Component {
constructor() {
super();
this.state = {
steps: [{
title: 'Step One',
href: 'http://example1.com',
onClick: (e) => {
e.preventDefault()
console.log('onClick', 1)
}
}, {
title: 'Step Two',
href: 'http://example2.com',
onClick: (e) => {
e.preventDefault()
console.log('onClick', 2)
}
}, {
title: 'Step Three (Disabled)',
href: 'http://example3.com',
onClick: (e) => {
e.preventDefault()
console.log('onClick', 3)
}
}, {
title: 'Step Four',
href: 'http://example4.com',
onClick: (e) => {
e.preventDefault()
console.log('onClick', 4)
}
}],
currentStep: 0,
};
this.onClickNext = this.onClickNext.bind(this);
}
onClickNext() {
const { steps, currentStep } = this.state;
this.setState({
currentStep: currentStep + 1,
});
}
render() {
const { steps, currentStep } = this.state;
const buttonStyle = { background: '#E0E0E0', width: 200, padding: 16, textAlign: 'center', margin: '0 auto', marginTop: 32 };
return (
<div>
<Stepper steps={ steps } activeStep={ currentStep } disabledSteps={ [2] } />
<div style={ buttonStyle } onClick={ this.onClickNext }>Next</div>
</div>
);
}
};
ReactDOM.render(<App />, document.getElementById('content'));