// @flow import React from 'react'; import Flex from 'components/Flex'; import styled from 'styled-components'; import SidebarLink from '../SidebarLink'; import Collection from 'models/Collection'; import Document from 'models/Document'; import type { NavigationNode } from 'types'; type Props = { collection: ?Collection, document: ?Document, }; class SidebarCollection extends React.Component { props: Props; renderDocuments(documentList: Array) { const { document } = this.props; if (document) { return documentList.map(doc => ( {doc.title} {(document.pathToDocument.includes(doc.id) || document.id === doc.id) && {doc.children && this.renderDocuments(doc.children)} } )); } } render() { const { collection } = this.props; if (collection) { return (
{collection.name}
{this.renderDocuments(collection.documents)}
); } 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 SidebarCollection;