import React from 'react'; import { Link } from 'react-router'; import classNames from 'classnames'; import { Row, Col, Icon, Affix } from 'antd'; 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] || []) .filter((demoData) => !demoData.meta.hidden); 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.title}
  • ); }); return (
      {jumper}

    {meta.english} {meta.chinese}

    { utils.jsonmlToComponent( location.pathname, ['section', { className: 'markdown' }] .concat(description) ) }

    代码演示

    {leftChildren} { isSingleCol ? null : {rightChildren} } { utils.jsonmlToComponent( location.pathname, ['section', { className: 'markdown api-container', }].concat(doc.api || []) ) }
    ); } }