2017-10-30 13:52:53 +02:00
|
|
|
import React from 'react';
|
2017-11-02 17:18:25 +02:00
|
|
|
import styled, { css } from 'styled-components';
|
|
|
|
import { Link as BaseLink } from 'react-router-dom';
|
|
|
|
import { A } from 'normalized-styled-components';
|
2017-10-30 13:52:53 +02:00
|
|
|
import remcalc from 'remcalc';
|
|
|
|
|
2017-11-02 17:18:25 +02:00
|
|
|
const Ul = styled.ul`
|
2017-10-30 13:52:53 +02:00
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
display: flex;
|
|
|
|
list-style: none;
|
2017-11-02 17:18:25 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
const style = css`
|
|
|
|
padding: ${remcalc(15)};
|
|
|
|
line-height: ${remcalc(24)};
|
|
|
|
font-size: ${remcalc(15)};
|
|
|
|
color: ${props => props.theme.white};
|
|
|
|
text-decoration: none;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
transition: all 200ms ease;
|
|
|
|
max-height: ${remcalc(53)};
|
|
|
|
min-height: ${remcalc(53)};
|
|
|
|
box-sizing: border-box;
|
2017-10-30 13:52:53 +02:00
|
|
|
|
2017-11-02 17:18:25 +02:00
|
|
|
&:hover,
|
|
|
|
&.active {
|
|
|
|
background: rgba(255, 255, 255, 0.15);
|
2017-10-30 13:52:53 +02:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2017-11-02 17:18:25 +02:00
|
|
|
const StyledAnchor = A.extend`
|
|
|
|
/* trick prettier */
|
|
|
|
${style};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledLink = styled(BaseLink)`
|
|
|
|
/* trick prettier */
|
|
|
|
${style};
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const Anchor = ({ children, ...rest }) => {
|
|
|
|
const { to = '' } = rest;
|
|
|
|
|
|
|
|
const Views = [() => (to ? StyledLink : null), () => StyledAnchor];
|
|
|
|
const View = Views.reduce((sel, view) => (sel ? sel : view()), null);
|
|
|
|
|
|
|
|
return <View {...rest}>{children}</View>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ({ children, ...rest }) => <Ul {...rest}>{children}</Ul>;
|