2017-06-06 22:08:08 +03:00
|
|
|
import React from 'react';
|
2017-11-09 13:27:32 +02:00
|
|
|
import styled, { css } from 'styled-components';
|
2017-06-06 22:08:08 +03:00
|
|
|
import remcalc from 'remcalc';
|
2017-11-09 13:27:32 +02:00
|
|
|
import { Link as BaseLink } from 'react-router-dom';
|
|
|
|
import { A } from 'normalized-styled-components';
|
2017-06-06 22:08:08 +03:00
|
|
|
|
|
|
|
import P from '../text/p';
|
|
|
|
|
2017-11-09 13:27:32 +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;
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
&.active {
|
|
|
|
background: rgba(255, 255, 255, 0.15);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2017-06-06 22:08:08 +03:00
|
|
|
const Text = P.extend`
|
|
|
|
text-align: center;
|
|
|
|
color: ${props => props.theme.white};
|
|
|
|
margin: 0;
|
|
|
|
`;
|
|
|
|
|
2017-10-30 13:52:53 +02:00
|
|
|
const Box = styled.section`
|
2017-06-06 22:08:08 +03:00
|
|
|
flex: 0 1 auto;
|
|
|
|
align-self: auto;
|
|
|
|
order: 0;
|
2017-10-30 13:52:53 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
svg {
|
|
|
|
margin-right: ${remcalc(6)};
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(:last-of-type) {
|
2017-11-02 17:18:25 +02:00
|
|
|
border-right: ${remcalc(1)} solid rgba(255, 255, 255, 0.15);
|
2017-10-30 13:52:53 +02:00
|
|
|
}
|
2017-06-06 22:08:08 +03:00
|
|
|
|
2017-10-30 13:52:53 +02:00
|
|
|
&:first-of-type {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
2017-06-06 22:08:08 +03:00
|
|
|
`;
|
|
|
|
|
2017-11-09 13:27:32 +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>;
|
|
|
|
};
|
|
|
|
|
2017-08-28 22:21:08 +03:00
|
|
|
export default ({ children, ...rest }) => (
|
2017-06-07 12:32:06 +03:00
|
|
|
<Box {...rest}>
|
2017-08-28 22:21:08 +03:00
|
|
|
<Text>{children}</Text>
|
|
|
|
</Box>
|
|
|
|
);
|