2017-11-19 23:56:50 +00:00
|
|
|
// @flow
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
|
|
|
import type { Location } from 'react-router-dom';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import { observer, inject } from 'mobx-react';
|
|
|
|
import Flex from 'shared/components/Flex';
|
|
|
|
import { color, layout } from 'shared/styles/constants';
|
|
|
|
|
|
|
|
import AccountMenu from 'menus/AccountMenu';
|
|
|
|
import Scrollable from 'components/Scrollable';
|
|
|
|
import HomeIcon from 'components/Icon/HomeIcon';
|
|
|
|
import SearchIcon from 'components/Icon/SearchIcon';
|
|
|
|
import StarredIcon from 'components/Icon/StarredIcon';
|
|
|
|
import Collections from './components/Collections';
|
|
|
|
import SidebarLink from './components/SidebarLink';
|
|
|
|
import HeaderBlock from './components/HeaderBlock';
|
|
|
|
|
|
|
|
import AuthStore from 'stores/AuthStore';
|
|
|
|
import UiStore from 'stores/UiStore';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
history: Object,
|
|
|
|
location: Location,
|
|
|
|
auth: AuthStore,
|
|
|
|
ui: UiStore,
|
|
|
|
};
|
|
|
|
|
|
|
|
@observer
|
|
|
|
class Sidebar extends Component {
|
|
|
|
props: Props;
|
|
|
|
|
|
|
|
handleCreateCollection = () => {
|
|
|
|
this.props.ui.setActiveModal('collection-new');
|
|
|
|
};
|
|
|
|
|
|
|
|
handleEditCollection = () => {
|
|
|
|
this.props.ui.setActiveModal('collection-edit');
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { auth, ui } = this.props;
|
|
|
|
const { user, team } = auth;
|
|
|
|
if (!user || !team) return;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container column editMode={ui.editMode}>
|
|
|
|
<AccountMenu
|
|
|
|
label={
|
2017-11-27 02:09:55 +00:00
|
|
|
<HeaderBlock
|
|
|
|
subheading={user.name}
|
|
|
|
teamName={team.name}
|
|
|
|
logoUrl={team.avatarUrl}
|
|
|
|
/>
|
2017-11-19 23:56:50 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Flex auto column>
|
2017-12-05 08:16:05 +00:00
|
|
|
<Scrollable>
|
2017-11-19 23:56:50 +00:00
|
|
|
<Section>
|
|
|
|
<SidebarLink to="/dashboard" icon={<HomeIcon />}>
|
|
|
|
Home
|
|
|
|
</SidebarLink>
|
|
|
|
<SidebarLink to="/search" icon={<SearchIcon />}>
|
|
|
|
Search
|
|
|
|
</SidebarLink>
|
|
|
|
<SidebarLink to="/starred" icon={<StarredIcon />}>
|
|
|
|
Starred
|
|
|
|
</SidebarLink>
|
|
|
|
</Section>
|
|
|
|
<Section>
|
|
|
|
<Collections
|
|
|
|
history={this.props.history}
|
|
|
|
location={this.props.location}
|
|
|
|
onCreateCollection={this.handleCreateCollection}
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
</Scrollable>
|
|
|
|
</Flex>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const Container = styled(Flex)`
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)};
|
|
|
|
width: ${layout.sidebarWidth};
|
|
|
|
background: ${color.smoke};
|
|
|
|
transition: left 200ms ease-in-out;
|
2017-12-03 00:27:45 +00:00
|
|
|
|
|
|
|
@media print {
|
|
|
|
display: none;
|
|
|
|
left: 0;
|
|
|
|
}
|
2017-11-19 23:56:50 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
const Section = styled(Flex)`
|
|
|
|
flex-direction: column;
|
|
|
|
margin: 24px 0;
|
|
|
|
padding: 0 24px;
|
|
|
|
position: relative;
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default withRouter(inject('user', 'auth', 'ui')(Sidebar));
|