import React from 'react'; import classNames from 'classnames'; import { Row, Col, Icon } from '../../../'; import Demo from '../Demo'; import * as utils from '../utils'; export default class ComponentDoc extends React.Component { constructor(props) { super(props); this.state = { expandAll: false, }; } handleExpandToggle() { this.setState({ expandAll: !this.state.expandAll, }); } render() { const { demos = [], doc } = this.props; const expand = this.state.expandAll; const isSingleCol = doc.meta.cols === '1'; const leftChildren = []; const rightChildren = []; demos.forEach((demoData, index) => { if (index % 2 === 0 || isSingleCol) { leftChildren.push(); } else { rightChildren.push(); } }); const expandTriggerClass = classNames({ 'code-box-expand-trigger': true, 'code-box-expand-trigger-active': expand, }); return (

{doc.meta.chinese || doc.meta.english}

{ doc.description.map(utils.objectToComponent) }

代码演示

{ leftChildren } { isSingleCol ? null : { rightChildren } }
{ (doc.api || []).map(utils.objectToComponent) }
); } }