// @flow import React from 'react'; import { browserHistory, Link } from 'react-router'; import Helmet from 'react-helmet'; import styled from 'styled-components'; import { observer, inject } from 'mobx-react'; import _ from 'lodash'; import keydown from 'react-keydown'; import classNames from 'classnames/bind'; import searchIcon from 'assets/icons/search.svg'; import { Flex } from 'reflexbox'; import styles from './Layout.scss'; import DropdownMenu, { MenuItem } from 'components/DropdownMenu'; import LoadingIndicator from 'components/LoadingIndicator'; import UserStore from 'stores/UserStore'; const cx = classNames.bind(styles); type Props = { children?: ?React.Element, actions?: ?React.Element, title?: ?React.Element, titleText?: string, loading?: boolean, user: UserStore, search: ?boolean, notifications?: React.Element, }; @observer class Layout extends React.Component { props: Props; static defaultProps = { search: true, }; @keydown(['/', 't']) search() { // if (!this.props.user) return; _.defer(() => browserHistory.push('/search')); } @keydown(['d']) dashboard() { // if (!this.props.user) return; _.defer(() => browserHistory.push('/')); } render() { const user = this.props.user; return (
{this.props.loading && } {this.props.notifications}
Atlas {this.props.title}
{this.props.actions} {user.user && {this.props.search &&
Search
} }> Settings Keyboard shortcuts API Logout
}
{this.props.children}
); } } const Avatar = styled.img` width: 24px; height: 24px; border-radius: 50%; `; export default inject('user')(Layout);