// @flow import React from 'react'; import { Link, withRouter } from 'react-router-dom'; 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 Flex from 'components/Flex'; import { color, layout } from 'styles/constants'; import DropdownMenu, { MenuItem } from 'components/DropdownMenu'; import { LoadingIndicatorBar } from 'components/LoadingIndicator'; import Scrollable from 'components/Scrollable'; import Avatar from 'components/Avatar'; import SidebarCollection from './components/SidebarCollection'; import SidebarCollectionList from './components/SidebarCollectionList'; import SidebarLink from './components/SidebarLink'; import UserStore from 'stores/UserStore'; import AuthStore from 'stores/AuthStore'; import UiStore from 'stores/UiStore'; import CollectionsStore from 'stores/CollectionsStore'; type Props = { history: Object, collections: CollectionsStore, children?: ?React.Element, actions?: ?React.Element, title?: ?React.Element, user: UserStore, auth: AuthStore, ui: UiStore, search: ?boolean, notifications?: React.Element, }; @observer class Layout extends React.Component { props: Props; static defaultProps = { search: true, }; @keydown(['/', 't']) search() { if (this.props.auth.authenticated) _.defer(() => this.props.history.push('/search')); } @keydown(['d']) dashboard() { if (this.props.auth.authenticated) _.defer(() => this.props.history.push('/')); } handleLogout = () => { this.props.auth.logout(() => this.props.history.push('/')); }; render() { const { user, auth, ui } = this.props; return ( {this.props.ui.progressBarVisible && } {this.props.notifications} {auth.authenticated && user &&
Atlas }> Settings Keyboard shortcuts API Logout
Search Home Starred {ui.activeCollection ? : }
} {this.props.children}
); } } const Container = styled(Flex)` position: relative; width: 100%; height: 100%; `; const LogoLink = styled(Link)` margin-top: 15px; font-family: 'Atlas Grotesk'; font-weight: bold; color: ${color.text}; text-decoration: none; font-size: 16px; `; const MenuLink = styled(Link)` color: ${color.text}; `; const Content = styled(Flex)` overflow: scroll; position: absolute; top: 0; bottom: 0; right: 0; left: ${props => (props.editMode ? 0 : layout.sidebarWidth)}; transition: left 200ms ease-in-out; `; const Sidebar = styled(Flex)` width: ${layout.sidebarWidth}; margin-left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)}; background: rgba(250, 251, 252, 0.71); border-right: 1px solid #eceff3; transition: margin-left 200ms ease-in-out; `; const Header = styled(Flex)` flex-shrink: 0; padding: ${layout.padding}; padding-bottom: 10px; `; const LinkSection = styled(Flex)` flex-direction: column; padding: 10px 0; `; export default withRouter(inject('user', 'auth', 'ui', 'collections')(Layout));