2016-02-29 14:08:40 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { Row, Col } from '../../../';
|
|
|
|
import Demo from '../Demo';
|
|
|
|
import * as utils from '../utils';
|
|
|
|
|
|
|
|
export default class ComponentDoc extends React.Component {
|
|
|
|
render() {
|
|
|
|
const { demos = [], doc } = this.props;
|
2016-02-29 15:56:15 +08:00
|
|
|
const isSingleCol = doc.meta.cols === '1';
|
2016-02-29 14:08:40 +08:00
|
|
|
|
|
|
|
const leftChildren = [];
|
|
|
|
const rightChildren = [];
|
|
|
|
demos.forEach((demoData, index) => {
|
2016-02-29 15:56:15 +08:00
|
|
|
if (index % 2 === 0 || isSingleCol) {
|
2016-02-29 14:08:40 +08:00
|
|
|
leftChildren.push(<Demo {...demoData} key={index} />);
|
|
|
|
} else {
|
|
|
|
rightChildren.push(<Demo {...demoData} key={index} />);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2016-03-01 11:46:18 +08:00
|
|
|
<article>
|
2016-02-29 15:56:15 +08:00
|
|
|
<section className="markdown">
|
|
|
|
<h1>{doc.meta.title}</h1>
|
|
|
|
{ doc.description.map(utils.objectToComponent) }
|
|
|
|
<h2>代码演示</h2>
|
|
|
|
</section>
|
2016-02-29 14:08:40 +08:00
|
|
|
<Row>
|
2016-02-29 15:56:15 +08:00
|
|
|
<Col span={ isSingleCol ? '24' : '12' }>{ leftChildren }</Col>
|
|
|
|
{ isSingleCol ? null : <Col span="12">{ rightChildren }</Col> }
|
2016-02-29 14:08:40 +08:00
|
|
|
</Row>
|
2016-02-29 15:56:15 +08:00
|
|
|
<section className="markdown">
|
|
|
|
{ doc.api.map(utils.objectToComponent) }
|
|
|
|
</section>
|
2016-03-01 11:46:18 +08:00
|
|
|
</article>
|
2016-02-29 14:08:40 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|