ant-design/site/component/Header/index.jsx

87 lines
2.5 KiB
React
Raw Normal View History

2016-02-29 14:08:40 +08:00
import React from 'react';
import { Link } from 'react-router';
2016-03-01 16:33:19 +08:00
import { Select, Menu, Row, Col } from '../../../';
2016-02-29 14:08:40 +08:00
const Option = Select.Option;
import './index.less';
2016-03-04 18:06:34 +08:00
import componentsList from '../../../_site/data/react-components';
2016-03-01 16:20:32 +08:00
export default class Header extends React.Component {
handleSearch(value) {
2016-03-10 16:01:39 +08:00
this.props.history.push({ pathname: value });
2016-02-29 14:08:40 +08:00
}
2016-03-01 16:20:32 +08:00
render() {
const routes = this.props.routes;
const activeMenuItem = routes[1].path || 'home';
const options = [];
2016-03-04 18:06:34 +08:00
Object.keys(componentsList).map((key) => {
return componentsList[key];
}).forEach(({ meta }) => {
const url = `/components/${meta.english.toLowerCase()}`;
2016-03-01 16:20:32 +08:00
2016-03-04 18:06:34 +08:00
options.push(
<Option value={url} key={url}>
<strong>{meta.english}</strong>
<span className="ant-component-decs">{meta.chinese}</span>
</Option>
);
});
2016-03-01 16:20:32 +08:00
return (
<header id="header" className="clearfix">
2016-03-01 16:33:19 +08:00
<Row>
<Col span="4">
<Link to="/" id="logo">
<img src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" />
<span>Ant Design</span>
2016-03-01 16:20:32 +08:00
</Link>
2016-03-01 16:33:19 +08:00
</Col>
<Col span="20">
<div id="search-box">
2016-03-10 16:01:39 +08:00
<Select combobox
searchPlaceholder="搜索组件..." optionLabelProp="nothing"
onChange={this.handleSearch.bind(this)}>
2016-03-01 16:33:19 +08:00
{options}
</Select>
</div>
<Menu mode="horizontal" selectedKeys={[activeMenuItem]} id="nav">
<Menu.Item key="home">
<Link to="/">
首页
</Link>
</Menu.Item>
2016-03-10 16:56:17 +08:00
<Menu.Item key="docs/practice">
<Link to="/docs/practice">
2016-03-02 11:57:37 +08:00
实践
</Link>
2016-03-01 16:33:19 +08:00
</Menu.Item>
2016-03-10 16:56:17 +08:00
<Menu.Item key="docs/pattern">
<Link to="/docs/pattern">
2016-03-02 11:57:37 +08:00
模式
</Link>
2016-03-01 16:33:19 +08:00
</Menu.Item>
<Menu.Item key="components">
<Link to="/components">
组件
</Link>
</Menu.Item>
2016-03-10 16:56:17 +08:00
<Menu.Item key="docs/spec">
<Link to="/docs/spec">
2016-03-01 16:33:19 +08:00
语言
</Link>
</Menu.Item>
2016-03-10 16:56:17 +08:00
<Menu.Item key="docs/resource">
<Link to="/docs/resource">
2016-03-01 16:33:19 +08:00
资源
</Link>
</Menu.Item>
</Menu>
</Col>
</Row>
2016-03-01 16:20:32 +08:00
</header>
);
}
2016-02-29 14:08:40 +08:00
}