Added sidebar chevrons
This commit is contained in:
@ -173,6 +173,7 @@ const Sidebar = styled(Flex)`
|
|||||||
const LinkSection = styled(Flex)`
|
const LinkSection = styled(Flex)`
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin: 24px 0;
|
margin: 24px 0;
|
||||||
|
padding: 0 ${layout.hpadding};
|
||||||
position: relative;
|
position: relative;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -87,16 +87,19 @@ type Props = {
|
|||||||
/>
|
/>
|
||||||
</CollectionAction>}
|
</CollectionAction>}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{collection.id === ui.activeCollectionId &&
|
{collection.id === ui.activeCollectionId &&
|
||||||
collection.documents.map(document => (
|
<Children column>
|
||||||
<DocumentLink
|
{collection.documents.map(document => (
|
||||||
key={document.id}
|
<DocumentLink
|
||||||
history={history}
|
key={document.id}
|
||||||
document={document}
|
history={history}
|
||||||
activeDocument={activeDocument}
|
document={document}
|
||||||
depth={0}
|
activeDocument={activeDocument}
|
||||||
/>
|
depth={0}
|
||||||
))}
|
/>
|
||||||
|
))}
|
||||||
|
</Children>}
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
</DropToImport>
|
</DropToImport>
|
||||||
);
|
);
|
||||||
@ -111,27 +114,32 @@ type DocumentLinkProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DocumentLink = observer((props: DocumentLinkProps) => {
|
const DocumentLink = observer((props: DocumentLinkProps) => {
|
||||||
const { history, document, activeDocument, depth } = props;
|
const { document, activeDocument, depth } = props;
|
||||||
const canDropToImport = depth === 0;
|
|
||||||
|
const showChildren =
|
||||||
|
activeDocument &&
|
||||||
|
(activeDocument.pathToDocument
|
||||||
|
.map(entry => entry.id)
|
||||||
|
.includes(document.id) ||
|
||||||
|
activeDocument.id === document.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex column key={document.id}>
|
<Flex column key={document.id}>
|
||||||
{canDropToImport &&
|
<DropToImport
|
||||||
<DropToImport
|
history={history}
|
||||||
history={history}
|
documentId={document.id}
|
||||||
documentId={document.id}
|
activeStyle="activeDropZone"
|
||||||
activeClassName="activeDropZone"
|
>
|
||||||
|
<SidebarLink
|
||||||
|
to={document.url}
|
||||||
|
hasChildren={document.children.length > 0}
|
||||||
|
expanded={showChildren}
|
||||||
>
|
>
|
||||||
<SidebarLink to={document.url}>{document.title}</SidebarLink>
|
{document.title}
|
||||||
</DropToImport>}
|
</SidebarLink>
|
||||||
{!canDropToImport &&
|
</DropToImport>
|
||||||
<SidebarLink to={document.url}>{document.title}</SidebarLink>}
|
|
||||||
|
|
||||||
{activeDocument &&
|
{showChildren &&
|
||||||
(activeDocument.pathToDocument
|
|
||||||
.map(entry => entry.id)
|
|
||||||
.includes(document.id) ||
|
|
||||||
activeDocument.id === document.id) &&
|
|
||||||
<Children column>
|
<Children column>
|
||||||
{document.children &&
|
{document.children &&
|
||||||
document.children.map(childDocument => (
|
document.children.map(childDocument => (
|
||||||
@ -139,6 +147,7 @@ const DocumentLink = observer((props: DocumentLinkProps) => {
|
|||||||
key={childDocument.id}
|
key={childDocument.id}
|
||||||
history={history}
|
history={history}
|
||||||
document={childDocument}
|
document={childDocument}
|
||||||
|
activeDocument={activeDocument}
|
||||||
depth={depth + 1}
|
depth={depth + 1}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@ -153,7 +162,6 @@ const Header = styled(Flex)`
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: ${color.slate};
|
color: ${color.slate};
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
padding: 0 24px;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const CollectionAction = styled.a`
|
const CollectionAction = styled.a`
|
||||||
|
@ -4,6 +4,9 @@ import { NavLink } from 'react-router-dom';
|
|||||||
import { color, fontWeight } from 'styles/constants';
|
import { color, fontWeight } from 'styles/constants';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import Flex from 'components/Flex';
|
||||||
|
import ChevronIcon from 'components/Icon/ChevronIcon';
|
||||||
|
|
||||||
const activeStyle = {
|
const activeStyle = {
|
||||||
color: color.black,
|
color: color.black,
|
||||||
fontWeight: fontWeight.semiBold,
|
fontWeight: fontWeight.semiBold,
|
||||||
@ -14,9 +17,11 @@ const StyleableDiv = props => <div {...props} />;
|
|||||||
|
|
||||||
const styleComponent = component => styled(component)`
|
const styleComponent = component => styled(component)`
|
||||||
display: block;
|
display: block;
|
||||||
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin: 5px 24px;
|
margin: 5px 0;
|
||||||
|
margin-left: ${({ hasChildren }) => (hasChildren ? '-20px;' : '0')};
|
||||||
color: ${color.slateDark};
|
color: ${color.slateDark};
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -24,11 +29,37 @@ const styleComponent = component => styled(component)`
|
|||||||
&:hover {
|
&:hover {
|
||||||
color: ${color.text};
|
color: ${color.text};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.active svg {
|
||||||
|
fill: ${activeStyle.color};
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function SidebarLink(props: Object) {
|
function SidebarLink(props: Object) {
|
||||||
const Component = styleComponent(props.to ? NavLink : StyleableDiv);
|
const Component = styleComponent(props.to ? NavLink : StyleableDiv);
|
||||||
return <Component exact activeStyle={activeStyle} {...props} />;
|
|
||||||
|
return (
|
||||||
|
<Flex>
|
||||||
|
<Component exact activeStyle={activeStyle} {...props}>
|
||||||
|
{props.hasChildren && <StyledChevron expanded={props.expanded} />}
|
||||||
|
{props.children}
|
||||||
|
</Component>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const StyledChevron = styled(ChevronIcon)`
|
||||||
|
margin-right: -10px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
height: 18px;
|
||||||
|
margin-bottom: -4px;
|
||||||
|
margin-right: 6px;
|
||||||
|
|
||||||
|
fill: ${color.slateDark};
|
||||||
|
|
||||||
|
${({ expanded }) => expanded && 'transform: rotate(90deg);'}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export default SidebarLink;
|
export default SidebarLink;
|
||||||
|
Reference in New Issue
Block a user