Playground.js
1.99 KB
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
import React, { Component, Fragment } from 'react'
import { Row, Col ,Slider } from 'antd'
class Playground extends Component {
gutters = {};
colCounts = {};
constructor() {
super();
this.state = {
gutterKey: 1,
colCountKey: 2,
};
[8, 16, 24, 32, 40, 48].forEach((value, i) => { this.gutters[i] = value; });
[2, 3, 4, 6, 8, 12].forEach((value, i) => { this.colCounts[i] = value; });
}
onGutterChange = (gutterKey) => {
this.setState({ gutterKey });
}
onColCountChange = (colCountKey) => {
this.setState({ colCountKey });
}
render() {
const { gutterKey, colCountKey } = this.state;
const cols = [];
const colCount = this.colCounts[colCountKey];
let colCode = '';
for (let i = 0; i < colCount; i++) {
cols.push(
<Col key={i.toString()} span={24 / colCount}>
<div>Column</div>
</Col>
);
colCode += ` <Col span={${24 / colCount}} />\n`;
}
return (
<Fragment>
<div>
<div style={{ marginBottom: 16 }}>
<span style={{ marginRight: 6 }}>Gutter (px): </span>
<div style={{ width: '50%' }}>
<Slider
min={0}
max={Object.keys(this.gutters).length - 1}
value={gutterKey}
onChange={this.onGutterChange}
marks={this.gutters}
step={null}
/>
</div>
<span style={{ marginRight: 6 }}>Column Count:</span>
<div style={{ width: '50%' }}>
<Slider
min={0}
max={Object.keys(this.colCounts).length - 1}
value={colCountKey}
onChange={this.onColCountChange}
marks={this.colCounts}
step={null}
/>
</div>
</div>
<Row gutter={this.gutters[gutterKey]}>{cols}</Row>
<pre>{`<Row gutter={${this.gutters[gutterKey]}}>\n${colCode}</Row>`}</pre>
</div>
</Fragment>
);
}
}
export default Playground