Merge pull request #82 from the-programmers-hangout/feat-add-scrollbar-to-sidebar

feat(resources): add scrollbar to sidebar
This commit is contained in:
Jean-Philippe Sirois
2019-09-09 18:23:19 -04:00
committed by GitHub
3 changed files with 25 additions and 17 deletions
@@ -30,9 +30,11 @@ export const Overlay = styled.div`
export const MainContent = styled.main` export const MainContent = styled.main`
flex: 1 1 auto; flex: 1 1 auto;
margin-top: 128px; margin-top: 128px;
margin-left: 320px;
width: calc(100% - 320px); width: calc(100% - 320px);
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
margin-left: 0;
width: 100%; width: 100%;
} }
+18 -14
View File
@@ -1,5 +1,7 @@
import { graphql, Link, useStaticQuery } from "gatsby" import { graphql, Link, useStaticQuery } from "gatsby"
import React, { memo, PropsWithChildren, useState } from "react" import React, { memo, PropsWithChildren, useState } from "react"
import Scrollbar from "react-perfect-scrollbar"
import "react-perfect-scrollbar/dist/css/styles.css"
import TriangleDown from "../../icons/triangle-down.svg" import TriangleDown from "../../icons/triangle-down.svg"
import Banner from "../../images/tph-banner.svg" import Banner from "../../images/tph-banner.svg"
import useSidebar from "./../../hooks/useSidebar" import useSidebar from "./../../hooks/useSidebar"
@@ -123,21 +125,23 @@ export function ResourcesSidebar(props: React.HTMLAttributes<HTMLDivElement>) {
return ( return (
<SC.ResourcesSidebarWrapper {...props}> <SC.ResourcesSidebarWrapper {...props}>
<Link to="/"> <Scrollbar>
<Banner /> <Link to="/">
</Link> <Banner />
<SC.Inner> </Link>
{tree.map((node, index) => plantTree(node, index, true))} <SC.Inner>
{tree.map((node, index) => plantTree(node, index, true))}
<SC.Menu> <SC.Menu>
<MenuItem to="/about">about</MenuItem> <MenuItem to="/about">about</MenuItem>
<MenuItem to="/rules">rules</MenuItem> <MenuItem to="/rules">rules</MenuItem>
<MenuItem to="/faq">faq</MenuItem> <MenuItem to="/faq">faq</MenuItem>
<MenuItem to="/">hotbot</MenuItem> <MenuItem to="/">hotbot</MenuItem>
<MenuItem to="/resources">resources</MenuItem> <MenuItem to="/resources">resources</MenuItem>
<MenuItem to="/">tech</MenuItem> <MenuItem to="/">tech</MenuItem>
</SC.Menu> </SC.Menu>
</SC.Inner> </SC.Inner>
</Scrollbar>
</SC.ResourcesSidebarWrapper> </SC.ResourcesSidebarWrapper>
) )
} }
+5 -3
View File
@@ -6,12 +6,14 @@ export const ResourcesSidebarWrapper = styled.div`
box-sizing: border-box; box-sizing: border-box;
flex: 0 0 320px; flex: 0 0 320px;
background: #f9f9f9; background: #f9f9f9;
position: fixed;
top: 0;
bottom: 0;
width: 320px;
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
z-index: 100; z-index: 100;
position: fixed; width: auto;
top: 0;
bottom: 0;
/* TODO: maybe find a less "awkward" way to animate this */ /* TODO: maybe find a less "awkward" way to animate this */
left: calc(-100% - 100px); left: calc(-100% - 100px);
right: calc(100% - 0px); right: calc(100% - 0px);