import React from 'react'; import { Link } from 'react-router'; import classNames from 'classnames'; import { Row, Col, Icon, Affix } from '../../../'; import Demo from '../Demo'; import * as utils from '../utils'; import demosList from '../../../_data/demos-list'; export default class ComponentDoc extends React.Component { constructor(props) { super(props); this.state = { expandAll: false, }; } componentDidMount() { this.componentDidUpdate(); } componentDidUpdate() { const { chinese, english } = this.props.doc.meta; utils.setTitle(`${chinese} ${english} - Ant Design`); } handleExpandToggle = () => { this.setState({ expandAll: !this.state.expandAll, }); } render() { const { doc, location } = this.props; const scrollTo = location.query.scrollTo; const { description, meta } = doc; const demos = demosList[meta.fileName] || []; const expand = this.state.expandAll; const isSingleCol = meta.cols === 1; const leftChildren = []; const rightChildren = []; demos.sort((a, b) => { return parseInt(a.meta.order, 10) - parseInt(b.meta.order, 10); }).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.meta.chinese || demo.meta.english }
  • ); }); return (
      { jumper }

    {meta.chinese || meta.english}

    { description.map(utils.objectToComponent.bind(null, location.pathname)) }

    代码演示

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