zepio/app/components/sidebar.js

74 lines
1.7 KiB
JavaScript
Raw Normal View History

// @flow
2018-12-11 15:43:27 -08:00
import React, { type Element } from 'react';
import styled from 'styled-components';
2018-12-11 16:15:38 -08:00
import { Link, type Location } from 'react-router-dom';
import { MENU_OPTIONS } from '../constants/sidebar';
2018-12-11 15:43:27 -08:00
import { ZCashLogo } from './zcash-logo';
2018-11-26 18:52:47 -08:00
const Wrapper = styled.div`
display: flex;
flex-direction: column;
width: 200px;
height: 100vh;
2018-12-04 20:26:03 -08:00
font-family: ${props => props.theme.fontFamily}
background-color: ${props => props.theme.colors.sidebarBg};
2018-12-11 15:43:27 -08:00
`;
const LogoWrapper = styled.div`
height: 60px;
width: 200px;
margin-bottom: 20px;
background-image: linear-gradient(
to right,
${props => props.theme.colors.sidebarLogoGradientBegin},
${props => props.theme.colors.sidebarLogoGradientEnd}
);
`;
const StyledLink = styled(Link)`
2018-12-11 15:43:27 -08:00
color: ${props => (props.isActive ? props.theme.colors.sidebarItemActive : props.theme.colors.sidebarItem)};
font-size: 0.9em;
2018-12-04 20:26:03 -08:00
text-decoration: none;
2018-12-11 15:43:27 -08:00
font-weight: ${props => (props.isActive ? 700 : 400)};
padding: 15px 20px;
display: flex;
align-items: center;
&:hover {
color: ${props => props.theme.colors.sidebarItemActive};
}
2018-11-26 18:52:47 -08:00
`;
type MenuItem = {
route: string,
label: string,
2018-12-11 15:43:27 -08:00
icon: Element<*>,
};
2018-11-26 18:52:47 -08:00
type Props = {
options?: MenuItem[],
2018-12-11 16:15:38 -08:00
location: Location,
2018-11-26 18:52:47 -08:00
};
2018-12-11 16:15:38 -08:00
export const SidebarComponent = ({ options, location }: Props) => (
<Wrapper>
2018-12-11 15:43:27 -08:00
<LogoWrapper>
<ZCashLogo />
</LogoWrapper>
2018-11-26 18:52:47 -08:00
{(options || []).map(item => (
2018-12-11 16:15:38 -08:00
<StyledLink isActive={location.pathname === item.route} key={item.route} to={item.route}>
2018-12-11 15:43:27 -08:00
{React.cloneElement(item.icon, {
style: { marginRight: '15px' },
size: 20,
})}
{item.label}
</StyledLink>
))}
</Wrapper>
);
2018-11-26 18:52:47 -08:00
2018-12-11 16:15:38 -08:00
SidebarComponent.defaultProps = {
2018-11-26 18:52:47 -08:00
options: MENU_OPTIONS,
};