Sidebar work

This commit is contained in:
Jori Lallo
2017-06-15 20:39:08 -07:00
parent 42e54a3a54
commit aa0ddd94bf
21 changed files with 250 additions and 368 deletions

View File

@ -0,0 +1,39 @@
// @flow
import React from 'react';
import { observer } from 'mobx-react';
import { Flex } from 'reflexbox';
import styled from 'styled-components';
import SidebarLink from '../SidebarLink';
import Collection from 'models/Collection';
type Props = {
collection: Collection,
};
const SidebarCollection = ({ collection }: Props) => {
if (collection) {
return (
<Flex column>
<Header>{collection.name}</Header>
{collection.documents.map(document => (
<SidebarLink key={document.id} to={document.url}>
{document.title}
</SidebarLink>
))}
</Flex>
);
}
return null;
};
const Header = styled(Flex)`
font-size: 11px;
font-weight: 500;
text-transform: uppercase;
color: #9FA6AB;
letter-spacing: 0.04em;
`;
export default observer(SidebarCollection);

View File

@ -0,0 +1,3 @@
// @flow
import SidebarCollection from './SidebarCollection';
export default SidebarCollection;

View File

@ -0,0 +1,36 @@
// @flow
import React from 'react';
import { observer, inject } from 'mobx-react';
import { Flex } from 'reflexbox';
import styled from 'styled-components';
import SidebarLink from '../SidebarLink';
import CollectionsStore from 'stores/CollectionsStore';
type Props = {
collections: CollectionsStore,
};
const SidebarCollectionList = observer(({ collections }: Props) => {
return (
<Flex column>
<Header>Collections</Header>
{collections.data.map(collection => (
<SidebarLink key={collection.id} to={collection.url}>
{collection.name}
</SidebarLink>
))}
</Flex>
);
});
const Header = styled(Flex)`
font-size: 11px;
font-weight: 500;
text-transform: uppercase;
color: #9FA6AB;
letter-spacing: 0.04em;
`;
export default inject('collections')(SidebarCollectionList);

View File

@ -0,0 +1,3 @@
// @flow
import SidebarCollectionList from './SidebarCollectionList';
export default SidebarCollectionList;

View File

@ -0,0 +1,26 @@
// @flow
import React from 'react';
import { observer } from 'mobx-react';
import { NavLink } from 'react-router-dom';
import { Flex } from 'reflexbox';
import styled from 'styled-components';
const activeStyle = {
color: '#000000',
};
const SidebarLink = observer(props => (
<LinkContainer>
<NavLink {...props} activeStyle={activeStyle} />
</LinkContainer>
));
const LinkContainer = styled(Flex)`
padding: 5px 0;
a {
color: #848484;
}
`;
export default SidebarLink;

View File

@ -0,0 +1,3 @@
// @flow
import SidebarLink from './SidebarLink';
export default SidebarLink;