This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/components/Layout/components/SidebarCollection/SidebarCollection.js
2017-06-26 23:48:59 -07:00

60 lines
1.2 KiB
JavaScript

// @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,
document: ?Document,
};
class SidebarCollection extends React.Component {
props: Props;
renderDocuments(documentList) {
return documentList.map(document => (
<Flex column key={document.id}>
<SidebarLink key={document.id} to={document.url}>
{document.title}
</SidebarLink>
<Children>
{document.children && this.renderDocuments(document.children)}
</Children>
</Flex>
));
}
render() {
const { collection } = this.props;
if (collection) {
return (
<Flex column>
<Header>{collection.name}</Header>
{this.renderDocuments(collection.documents)}
</Flex>
);
}
return null;
}
}
const Header = styled(Flex)`
font-size: 11px;
font-weight: 500;
text-transform: uppercase;
color: #9FA6AB;
letter-spacing: 0.04em;
`;
const Children = styled(Flex)`
margin-left: 20px;
`;
export default observer(SidebarCollection);