diff --git a/app/components/Sidebar/components/Collections.js b/app/components/Sidebar/components/Collections.js index dcafa20ee..0ad66df5a 100644 --- a/app/components/Sidebar/components/Collections.js +++ b/app/components/Sidebar/components/Collections.js @@ -5,7 +5,7 @@ import { observer, inject } from 'mobx-react'; import type { Location } from 'react-router-dom'; import Flex from 'shared/components/Flex'; import styled from 'styled-components'; -import { color, fontWeight } from 'shared/styles/constants'; +import { color } from 'shared/styles/constants'; import Header from './Header'; import SidebarLink from './SidebarLink'; @@ -84,14 +84,32 @@ class CollectionLink extends Component { this.dropzoneRef.open(); }; - render() { + renderDocuments() { const { history, collection, activeDocument, - ui, prefetchDocument, } = this.props; + + return ( + + {collection.documents.map(document => ( + + ))} + + ); + } + + render() { + const { history, collection, ui } = this.props; const expanded = collection.id === ui.activeCollectionId; return ( @@ -108,6 +126,9 @@ class CollectionLink extends Component { to={collection.url} icon={} iconColor={collection.color} + expandedContent={this.renderDocuments()} + hideExpandToggle + expand={expanded} > {collection.name} @@ -123,21 +144,6 @@ class CollectionLink extends Component { /> - - {expanded && ( - - {collection.documents.map(document => ( - - ))} - - )} ); @@ -194,7 +200,7 @@ const DocumentLink = observer( expand={showChildren} expandedContent={ document.children.length ? ( - + {document.children.map(childDocument => ( ))} - + ) : ( undefined ) @@ -223,7 +229,7 @@ const CollectionName = styled(Flex)` padding: 0 0 4px; `; -const CollectionAction = styled.a` +const CollectionAction = styled.span` position: absolute; right: 0; color: ${color.slate}; @@ -250,10 +256,14 @@ const StyledDropToImport = styled(DropToImport)` } `; -const Children = styled(Flex)` +const CollectionChildren = styled(Flex)` + margin-top: -4px; + margin-left: 36px; +`; + +const DocumentChildren = styled(Flex)` + margin-top: -4px; margin-left: 12px; - font-weight: ${fontWeight.regular}; - color: ${color.slateDark}; `; export default inject('collections', 'ui', 'documents')(Collections); diff --git a/app/components/Sidebar/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.js index fe43ff2d2..d52b8dd5a 100644 --- a/app/components/Sidebar/components/SidebarLink.js +++ b/app/components/Sidebar/components/SidebarLink.js @@ -33,7 +33,7 @@ const StyledNavLink = styled(NavLink)` overflow: hidden; text-overflow: ellipsis; padding: 4px 0; - margin-left: ${({ hasChildren }) => (hasChildren ? '-20px;' : '0')}; + margin-left: ${({ iconVisible }) => (iconVisible ? '-20px;' : '0')}; color: ${color.slateDark}; font-size: 15px; cursor: pointer; @@ -52,6 +52,7 @@ type Props = { icon?: React$Element<*>, expand?: boolean, expandedContent?: React$Element<*>, + hideExpandToggle?: boolean, iconColor?: string, }; @@ -81,25 +82,35 @@ class SidebarLink extends Component { }; render() { - const { icon, children, onClick, to, expandedContent } = this.props; + const { + icon, + children, + onClick, + to, + expandedContent, + expand, + hideExpandToggle, + } = this.props; const Component = to ? StyledNavLink : StyledDiv; + const showExpandIcon = expandedContent && !hideExpandToggle; return ( {icon && {icon}} - {expandedContent && ( + {showExpandIcon && ( )} {children} - {this.expanded && expandedContent} + {/* Collection */ expand && hideExpandToggle && expandedContent} + {/* Document */ this.expanded && !hideExpandToggle && expandedContent} ); }