2017-02-27 17:41:08 +02:00
|
|
|
import { Subscriber } from 'react-broadcast';
|
2017-02-20 18:15:36 +02:00
|
|
|
import styled from 'styled-components';
|
2017-05-18 21:21:33 +03:00
|
|
|
import { Nav } from 'normalized-styled-components';
|
|
|
|
import Baseline from '../baseline';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
import is from 'styled-is';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-02-20 18:15:36 +02:00
|
|
|
import Button from '../button';
|
|
|
|
import React from 'react';
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const StyledNav = Nav.extend`
|
2017-01-09 14:13:12 +02:00
|
|
|
flex: 0 0 ${remcalc(47)};
|
2017-05-18 21:21:33 +03:00
|
|
|
border-left: ${remcalc(1)} solid ${props => props.theme.grey};
|
2017-02-27 17:41:08 +02:00
|
|
|
box-sizing: border-box;
|
2017-02-20 18:15:36 +02:00
|
|
|
|
|
|
|
${is('fromHeader')`
|
2017-05-18 21:21:33 +03:00
|
|
|
border-left-color: ${props => props.theme.primaryDesaturatedActive};
|
2017-02-20 18:15:36 +02:00
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const StyledButton = Button.extend`
|
2017-03-20 17:58:47 +02:00
|
|
|
position: relative;
|
2017-01-09 14:13:12 +02:00
|
|
|
border-width: 0;
|
|
|
|
box-shadow: none;
|
|
|
|
width: 100%;
|
2017-06-06 13:57:12 +03:00
|
|
|
min-width: ${remcalc(46)} !important;
|
2017-02-20 18:15:36 +02:00
|
|
|
height: ${remcalc(124)};
|
|
|
|
|
2017-02-27 17:41:08 +02:00
|
|
|
display: flex;
|
2017-05-18 21:21:33 +03:00
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
|
2017-02-27 17:41:08 +02:00
|
|
|
overflow-x: visible;
|
|
|
|
overflow-y: visible;
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
${is('collapsed')`
|
|
|
|
height: ${remcalc(46)};
|
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
|
|
|
|
&:focus {
|
|
|
|
border-width: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
border-width: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active,
|
|
|
|
&:active:hover,
|
|
|
|
&:active:focus {
|
|
|
|
border-width: 0;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2017-03-20 17:58:47 +02:00
|
|
|
const StyledContainer = styled.div`
|
|
|
|
position: absolute;
|
|
|
|
left: 50%;
|
2017-03-22 14:15:09 +02:00
|
|
|
top: 35%; /* I don't know why this doesn't center with 50% */
|
2017-03-20 17:58:47 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledCircle = styled.div`
|
2017-03-22 14:15:09 +02:00
|
|
|
margin: 0 0 ${remcalc(2)} ${remcalc(-2)};
|
2017-03-20 17:58:47 +02:00
|
|
|
border-radius: 50%;
|
2017-05-18 21:21:33 +03:00
|
|
|
background-color: ${props => props.theme.white};
|
2017-03-22 14:15:09 +02:00
|
|
|
width: ${remcalc(4)};
|
|
|
|
height: ${remcalc(4)};
|
2017-05-18 21:21:33 +03:00
|
|
|
|
|
|
|
${is('secondary')`
|
|
|
|
background-color: ${props => props.theme.secondary};
|
|
|
|
`};
|
2017-03-20 17:58:47 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const Options = ({ children, ...rest }) => {
|
|
|
|
const render = ({ fromHeader = false, collapsed = false }) => (
|
|
|
|
<StyledNav fromHeader={fromHeader} name="card-options">
|
2017-02-27 17:41:08 +02:00
|
|
|
<StyledButton
|
|
|
|
secondary={!fromHeader}
|
|
|
|
collapsed={collapsed}
|
|
|
|
rect
|
2017-05-18 21:21:33 +03:00
|
|
|
{...rest}
|
2017-02-27 17:41:08 +02:00
|
|
|
>
|
2017-03-20 17:58:47 +02:00
|
|
|
<StyledContainer>
|
2017-05-18 21:21:33 +03:00
|
|
|
<StyledCircle secondary={!fromHeader} />
|
|
|
|
<StyledCircle secondary={!fromHeader} />
|
|
|
|
<StyledCircle secondary={!fromHeader} />
|
2017-03-20 17:58:47 +02:00
|
|
|
</StyledContainer>
|
2017-02-27 17:41:08 +02:00
|
|
|
</StyledButton>
|
2017-05-18 21:21:33 +03:00
|
|
|
</StyledNav>
|
2017-02-27 17:41:08 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2017-05-18 21:21:33 +03:00
|
|
|
<Subscriber channel="card">
|
2017-02-27 17:41:08 +02:00
|
|
|
{render}
|
|
|
|
</Subscriber>
|
|
|
|
);
|
|
|
|
};
|
2017-01-09 14:13:12 +02:00
|
|
|
|
|
|
|
Options.propTypes = {
|
2017-05-18 21:21:33 +03:00
|
|
|
collapsed: PropTypes.bool,
|
|
|
|
fromHeader: PropTypes.bool
|
2017-01-09 14:13:12 +02:00
|
|
|
};
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
export default Baseline(Options);
|