UNPKG

cjd-parkball

Version:

> 中后台业务组件库,中后台就像公园,进入需要买门票(登录),所以以 Parkball(公园球) 命名,公园内必定捕获!作为一个组件库,提供使用方法文档,方便开发者的调用

108 lines (94 loc) 2.54 kB
--- category: 2 title: 栅格配置器 title_en: Playground --- zh-CN 可以简单配置几种等分栅格和间距。 en-US A simple playground for column count and gutter. ````jsx import { Row, Col, Slider } from 'parkball'; class App extends React.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 ( <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> ); } } ReactDOM.render(<App />, mountNode); ```` ````css #components-grid-demo-playground [class^="ant-col-"] { background: transparent; border: 2; } #components-grid-demo-playground [class^="ant-col-"] > div { background: #00A0E9; height: 120px; line-height: 120px; font-size: 13px; } #components-grid-demo-playground pre { background: #f9f9f9; border-radius: 6px; font-size: 13px; padding: 8px 16px; } ````