2016-02-29 14:08:40 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { Link } from 'react-router';
|
|
|
|
import { Row, Col, Menu } from '../../../';
|
2016-03-01 17:05:24 +08:00
|
|
|
import * as utils from '../utils';
|
2016-02-29 14:08:40 +08:00
|
|
|
|
2016-03-02 11:57:37 +08:00
|
|
|
export default class MainContent extends React.Component {
|
2016-03-01 17:05:24 +08:00
|
|
|
getMenuItems() {
|
2016-03-02 11:57:37 +08:00
|
|
|
const props = this.props;
|
|
|
|
return props.menuItems.map((item) => {
|
|
|
|
const key = item.english.toLowerCase();
|
|
|
|
const text = item.chinese || item.english;
|
|
|
|
|
|
|
|
const child = !item.link ?
|
|
|
|
<Link to={`/${props.category}/${key}`}>
|
|
|
|
{ text }
|
|
|
|
</Link> :
|
|
|
|
<a href={item.link} target="_blank">
|
|
|
|
{ text }
|
|
|
|
</a>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Menu.Item key={key} disabled={item.disabled === 'true'}>
|
|
|
|
{ item.disabled ? <span>{text}</span> : child }
|
|
|
|
</Menu.Item>
|
|
|
|
);
|
|
|
|
});
|
2016-03-01 17:05:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-29 14:08:40 +08:00
|
|
|
render() {
|
2016-03-02 11:57:37 +08:00
|
|
|
const activeMenuItem = utils.getActiveMenuItem(this.props);
|
2016-03-01 17:05:24 +08:00
|
|
|
const menuItems = this.getMenuItems();
|
|
|
|
const { prev, next } = utils.getFooterNav(menuItems, activeMenuItem);
|
2016-03-01 16:20:32 +08:00
|
|
|
|
2016-02-29 14:08:40 +08:00
|
|
|
return (
|
|
|
|
<Row className="main-wrapper">
|
|
|
|
<Col span="4">
|
2016-03-01 16:20:32 +08:00
|
|
|
<Menu mode="inline" selectedKeys={[activeMenuItem]}>
|
2016-03-01 17:05:24 +08:00
|
|
|
{ menuItems }
|
2016-02-29 14:08:40 +08:00
|
|
|
</Menu>
|
|
|
|
</Col>
|
|
|
|
<Col span="20" className="main-container">
|
|
|
|
{ this.props.children }
|
2016-03-01 17:05:24 +08:00
|
|
|
<section className="prev-next-nav">
|
|
|
|
{ !!prev ? React.cloneElement(prev.props.children, { className: 'prev-page' }) : null }
|
|
|
|
{ !!next ? React.cloneElement(next.props.children, { className: 'next-page' }) : null }
|
|
|
|
</section>
|
2016-02-29 14:08:40 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|