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

85 lines
2.4 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) {
console.log(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">
<Select combobox searchPlaceholder="搜索组件..." onChange={this.handleSearch.bind(this)}>
{options}
</Select>
</div>
<Menu mode="horizontal" selectedKeys={[activeMenuItem]} id="nav">
<Menu.Item key="home">
<Link to="/">
首页
</Link>
</Menu.Item>
<Menu.Item key="practice">
2016-03-02 11:57:37 +08:00
<Link to="practice">
实践
</Link>
2016-03-01 16:33:19 +08:00
</Menu.Item>
<Menu.Item key="pattern">
2016-03-02 11:57:37 +08:00
<Link to="pattern">
模式
</Link>
2016-03-01 16:33:19 +08:00
</Menu.Item>
<Menu.Item key="components">
<Link to="/components">
组件
</Link>
</Menu.Item>
<Menu.Item key="spec">
<Link to="/spec">
语言
</Link>
</Menu.Item>
<Menu.Item key="resource">
<Link to="/resource">
资源
</Link>
</Menu.Item>
</Menu>
</Col>
</Row>
2016-03-01 16:20:32 +08:00
</header>
);
}
2016-02-29 14:08:40 +08:00
}