diff --git a/src/components/ResourcesSidebar/index.tsx b/src/components/ResourcesSidebar/index.tsx index e2affd9..6c68493 100644 --- a/src/components/ResourcesSidebar/index.tsx +++ b/src/components/ResourcesSidebar/index.tsx @@ -85,7 +85,7 @@ function Folder({ item }: { item: IFolder }) { {item.title}} + nodeLabel={{item.title}} > {item.children.map(node => plantTree(node))} @@ -100,8 +100,17 @@ function FirstLevelFolder({ item, index }: { item: IFolder; index: number }) { return ( setCurrent(index)}>{item.title}} + nodeLabel={ + setCurrent(index)} + > + {item.title} + + + } > {item.children.map(node => plantTree(node))} diff --git a/src/components/ResourcesSidebar/styles.tsx b/src/components/ResourcesSidebar/styles.tsx index d64f582..0bd74f8 100644 --- a/src/components/ResourcesSidebar/styles.tsx +++ b/src/components/ResourcesSidebar/styles.tsx @@ -1,5 +1,6 @@ import styled from "styled-components" import { Link } from "gatsby" +import ChevronUp from "../../icons/chevron-up.svg" export const ResourcesSidebarWrapper = styled.div` box-sizing: border-box; @@ -14,20 +15,96 @@ export const Banner = styled.img` export const TreeWrapper = styled.div` width: 100%; - padding: 12px 0; & + & { border-top: 1px solid #dbdbdb; } ` +export const Label = styled.div` + padding: 4px 0; +` + +export const FirstLabel = styled.div` + display: flex; + align-items: center; + width: 100%; + padding: 12px 15px 12px 0; + font-weight: 700; + color: #a9a9a9; + + &.active { + color: #000; + } + + svg { + margin-left: auto; + transform: rotate(90deg); + transition: transform 0.3s; + + path { + fill: #a9a9a9; + } + } + + &.active svg { + transform: rotate(0); + + path { + fill: #000; + } + } +` + +export const CollapseToggler = styled(ChevronUp)`` + export const Inner = styled.div` padding-top: 30px; padding-left: 20px; - /* TODO: change this.. */ - & > ${TreeWrapper} > .tree-view > .tree-view_item > div { - font-weight: 700; + .tree-view { + overflow-y: hidden; + } + + .tree-view_item { + display: flex; + cursor: pointer; + } + + .tree-view_children { + margin-left: 16px; + display: flex; + flex-direction: column; + align-items: flex-start; + } + + .tree-view_children-collapsed { + height: 0px; + } + + .tree-view_arrow { + cursor: pointer; + margin-right: 6px; + display: inline-block; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + + .tree-view_arrow:after { + content: "▾"; + } + + .tree-view_arrow.firstLevel { + display: none; + } + + .tree-view_arrow-collapsed { + -webkit-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); + -ms-transform: rotate(-90deg); + transform: rotate(-90deg); } ` diff --git a/src/globalStyles.tsx b/src/globalStyles.tsx index 7c257c7..074f345 100644 --- a/src/globalStyles.tsx +++ b/src/globalStyles.tsx @@ -34,51 +34,4 @@ export const GlobalStyles = createGlobalStyle` padding-left: 2.8em; overflow: initial; } - - /* TODO: probably extract this */ - .tree-view { - overflow-y: hidden; - } - - .tree-view_item { - display: flex; - cursor: pointer; - } - - .tree-view_item, - .tree-view_children > div { - padding: 4px 0; - } - - .tree-view_children { - margin-left: 16px; - display: flex; - flex-direction: column; - align-items: flex-start; - } - - .tree-view_children-collapsed { - height: 0px; - } - - .tree-view_arrow { - cursor: pointer; - margin-right: 6px; - display: inline-block; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - } - - .tree-view_arrow:after { - content: "▾"; - } - - .tree-view_arrow-collapsed { - -webkit-transform: rotate(-90deg); - -moz-transform: rotate(-90deg); - -ms-transform: rotate(-90deg); - transform: rotate(-90deg); - } ` diff --git a/src/icons/chevron-up.svg b/src/icons/chevron-up.svg new file mode 100644 index 0000000..0eb6bd8 --- /dev/null +++ b/src/icons/chevron-up.svg @@ -0,0 +1,3 @@ + + +