import React from 'react';
import { Link } from 'react-router';
import enquire from 'enquire.js';
import { Select, Menu, Row, Col, Icon } from 'antd';
const Option = Select.Option;
import './index.less';
import componentsList from '../../../_data/react-components';
export default class Header extends React.Component {
static contextTypes = {
router: React.PropTypes.object.isRequired,
}
constructor(props) {
super(props);
this.state = {
menuVisible: false,
menuMode: 'horizontal',
};
}
componentDidMount() {
document.addEventListener('click', () => {
this.setState({
menuVisible: false,
});
});
enquire.register('only screen and (min-width: 320px) and (max-width: 767px)', {
match: () => {
this.setState({ menuMode: 'inline' });
},
unmatch: () => {
this.setState({ menuMode: 'horizontal' });
},
});
}
handleMenuIconClick = (e) => {
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
this.setState({
menuVisible: true,
});
}
handleSearch = (value) => {
this.context.router.push({ pathname: value });
}
handleSelectFilter = (value, option) => {
return option.props['data-label'].indexOf(value.toLowerCase()) > -1;
}
render() {
const routes = this.props.routes;
const activeMenuItem = routes[1].path || 'home';
const options = Object.keys(componentsList).map((key) => {
return componentsList[key];
}).filter(({ meta }) => {
return /^component/.test(meta.fileName);
}).map(({ meta }) => {
const pathSnippet = meta.fileName.split('/')[1];
const url = `/components/${pathSnippet}`;
return (
);
});
const menuStyle = {
display: this.state.menuVisible ? 'block' : '',
};
return (
);
}
}