forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
112 lines (98 loc) · 3.41 KB
/
index.jsx
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import '../../../src/demo-helper/style.js';
import { Demo, DemoGroup, initDemo } from '../../../src/demo-helper';
import '../../../src/range/style.js';
import Range from '../../../src/range';
const i18nMap = {
'zh-cn': {
title: '范围'
},
'en-us': {
title: 'Range'
}
};
function ItemDemo({title, marksPosition, ...others}) {
return (<Demo title={title}>
<DemoGroup label="Normal">
<div style={{width: '400px', margin: '10px'}}>
<Range {...others} marksPosition={marksPosition} />
</div>
</DemoGroup>
<DemoGroup label="Hover">
<div style={{width: '400px', margin: '10px'}}>
<Range {...others} marksPosition={marksPosition} className="simulation-hover" />
</div>
</DemoGroup>
<DemoGroup label="Clicked">
<div style={{width: '400px', margin: '10px'}}>
<Range {...others} marksPosition={marksPosition} className="simulation-click" />
</div>
</DemoGroup>
<DemoGroup label="Disabled">
<div style={{width: '400px', margin: '10px'}}>
<Range {...others} disabled marksPosition={marksPosition} />
</div>
</DemoGroup>
</Demo>);
}
ItemDemo.propTypes = {
title: PropTypes.string,
marksPosition: PropTypes.bool
};
class OriginalDemo extends Component {
constructor(props) {
super(props);
this.state = {
demoFunction: {
marksPosition: {
label: '刻度显示位置',
value: 'above',
enum: [
{label: '上', value: 'above'},
{label: '下', value: 'below'}
]
}
}
};
this.onFunctionChange = this.onFunctionChange.bind(this);
}
onFunctionChange(demoFunction) {
this.setState({
demoFunction
});
}
render() {
const { demoFunction } = this.state;
const marksPosition = demoFunction.marksPosition.value;
return (
<Demo title="With Scale" demoFunction={demoFunction} onFunctionChange={this.onFunctionChange}>
<ItemDemo marksPosition={marksPosition} title="Single" defaultValue={3} max={10} scales={5} marks={5} />
<ItemDemo marksPosition={marksPosition} title="Double" defaultValue={[20, 40]} slider="double" scales={10} marks={10} />
<ItemDemo fixedWidth marksPosition={marksPosition} title="Double - fixedWidth" defaultValue={[20, 40]} slider="double" scales={10} marks={10} />
</Demo>
);
}
}
function NormalRange() {
return (<Demo title="Basic">
<ItemDemo title="Single" defaultValue={3} max={10} />
<ItemDemo title="Double" defaultValue={[20, 40]} slider="double" />
<ItemDemo fixedWidth title="Double - fixedWidth" defaultValue={[20, 40]} slider="double" />
</Demo>);
}
const render = i18n => {
ReactDOM.render((
<div className="demo-container">
<NormalRange />
<OriginalDemo />
</div>
), document.getElementById('container'));
};
window.renderDemo = function(lang) {
lang = lang || 'en-us';
render(i18nMap[lang]);
};
window.renderDemo();
initDemo('range');