import React from 'react'; import classNames from 'classnames'; import { Row, Col, Icon } from '../../../'; import Demo from '../Demo'; import * as utils from '../utils'; import demosList from '../../../_site/data/demos-list'; export default class ComponentDoc extends React.Component { constructor(props) { super(props); this.state = { expandAll: false, }; } handleExpandToggle() { this.setState({ expandAll: !this.state.expandAll, }); } render() { const { doc } = this.props; const { description, meta } = doc; const demos = demosList[meta.fileName] || []; const expand = this.state.expandAll; const parentId = meta.fileName.split('/').slice(0, 2).join('-'); const isSingleCol = meta.cols === '1'; const leftChildren = []; const rightChildren = []; demos.sort((a, b) => { return a.order - b.order; }).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, }); const jumper = demos.map((demo) => { return (
  • { demo.title }
  • ); }); return (
      { jumper }

    {meta.chinese || meta.english}

    { description.map(utils.objectToComponent) }

    代码演示

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