refact: rename Column components to be generic

This commit is contained in:
Jean-Philippe Sirois
2019-11-11 17:18:09 -08:00
parent ba88927304
commit 711da3c517
25 changed files with 553 additions and 555 deletions
+49
View File
@@ -0,0 +1,49 @@
import { Link } from "gatsby"
import React, { FC, HTMLAttributes, PropsWithChildren } from "react"
import Scrollbar from "react-perfect-scrollbar"
import "react-perfect-scrollbar/dist/css/styles.css"
import Banner from "../../images/tph-banner.svg"
import { ThemeToggler } from "../ThemeToggler"
import * as SC from "./styles"
interface IMenuItemProps {
to: string
}
const MenuItem: FC<IMenuItemProps> = ({ children, to }) => {
return (
<SC.MenuItem to={to} activeClassName="active">
{children}
</SC.MenuItem>
)
}
export const Sidebar: FC<
PropsWithChildren<HTMLAttributes<HTMLDivElement>>
> = props => {
const { children, ...restProps } = props
return (
<SC.SidebarWrapper {...restProps}>
<Scrollbar>
<Link to="/">
<Banner />
</Link>
<SC.Inner>
{children}
<SC.Menu>
<MenuItem to="/about">about</MenuItem>
<MenuItem to="/rules">rules</MenuItem>
<MenuItem to="/faq">faq</MenuItem>
<MenuItem to="/">hotbot</MenuItem>
<MenuItem to="/resources">resources</MenuItem>
<MenuItem to="/archives">tech spotlights</MenuItem>
</SC.Menu>
<ThemeToggler />
</SC.Inner>
</Scrollbar>
</SC.SidebarWrapper>
)
}
+56
View File
@@ -0,0 +1,56 @@
import { Link } from "gatsby"
import styled from "styled-components"
export const SidebarWrapper = styled.div`
box-sizing: border-box;
flex: 0 0 320px;
background: ${props => props.theme.sidebar.background};
color: ${props => props.theme.sidebar.foreground};
position: fixed;
top: 0;
bottom: 0;
width: 320px;
@media screen and (max-width: 767px) {
z-index: 100;
width: auto;
/* TODO: maybe find a less "awkward" way to animate this */
left: calc(-100% - 100px);
right: calc(100% - 0px);
transition: left 0.3s, right 0.3s;
}
&.is-open {
left: 0;
right: 100px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
`
export const Inner = styled.div`
padding: 30px 0 30px 20px;
`
export const Menu = styled.nav`
display: flex;
flex-direction: column;
border-top: 1px dashed #a5a5a5;
margin: 20px 0 40px;
padding-top: 20px;
`
export const MenuItem = styled(Link)`
padding: 4px 0;
font-size: 20px;
color: ${props => props.theme.sidebar.foreground};
text-decoration: none;
&:hover,
&:active {
text-decoration: underline;
}
&.active {
font-weight: 700;
}
`