2017-02-20 18:15:36 +02:00
|
|
|
import { remcalc } from '../../shared/functions';
|
|
|
|
import { baseBox, pseudoEl, Baseline } from '../../shared/composers';
|
|
|
|
import { colors } from '../../shared/constants';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import React from 'react';
|
2017-01-24 19:27:01 +02:00
|
|
|
|
2016-12-20 14:02:47 +02:00
|
|
|
const ItemPadder = 9;
|
|
|
|
const WrapperPadder = 24;
|
|
|
|
|
|
|
|
const StyledList = styled.ul`
|
|
|
|
position: relative;
|
2017-02-27 18:33:42 +02:00
|
|
|
background: ${colors.base.white};
|
|
|
|
color: ${colors.base.text};
|
2016-12-20 14:02:47 +02:00
|
|
|
display: inline-block;
|
|
|
|
font-family: sans-serif;
|
|
|
|
list-style-type: none;
|
|
|
|
margin: 0;
|
2017-02-27 18:33:42 +02:00
|
|
|
padding: 0;
|
2016-12-20 14:02:47 +02:00
|
|
|
min-width: ${remcalc(200)};
|
2017-02-07 01:00:55 +02:00
|
|
|
|
2017-02-09 15:56:29 +02:00
|
|
|
${props => props.styles}
|
2016-12-20 14:02:47 +02:00
|
|
|
|
|
|
|
${baseBox()}
|
|
|
|
|
|
|
|
& > * {
|
|
|
|
|
|
|
|
padding: ${remcalc(ItemPadder)} ${remcalc(WrapperPadder)};
|
|
|
|
|
|
|
|
&:hover {
|
2017-02-15 15:59:49 +02:00
|
|
|
background: ${colors.base.grey};
|
2016-12-20 14:02:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:after, &:before {
|
|
|
|
border: solid transparent;
|
|
|
|
height: 0;
|
|
|
|
width: 0;
|
|
|
|
|
|
|
|
${ props => pseudoEl(props.arrowPosition) }
|
|
|
|
}
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
border-color: rgba(255, 255, 255, 0);
|
2017-02-27 18:33:42 +02:00
|
|
|
border-bottom-color: ${colors.base.white};
|
2017-01-12 21:04:52 +02:00
|
|
|
border-width: ${remcalc(10)};
|
|
|
|
margin-left: ${remcalc(-10)};
|
2016-12-20 14:02:47 +02:00
|
|
|
}
|
|
|
|
&:before {
|
|
|
|
border-color: rgba(216, 216, 216, 0);
|
2017-02-07 01:00:55 +02:00
|
|
|
border-bottom-color: ${colors.base.greyDark};
|
2017-01-12 21:04:52 +02:00
|
|
|
border-width: ${remcalc(12)};
|
|
|
|
margin-left: ${remcalc(-12)};
|
2016-12-20 14:02:47 +02:00
|
|
|
}
|
|
|
|
`;
|
2017-02-15 03:19:26 +02:00
|
|
|
|
|
|
|
const Tooltip = ({
|
2016-12-20 14:02:47 +02:00
|
|
|
children,
|
|
|
|
arrowPosition = {
|
|
|
|
bottom: '100%',
|
|
|
|
left: '10%'
|
2017-02-20 18:15:36 +02:00
|
|
|
},
|
|
|
|
...props
|
2017-02-15 03:19:26 +02:00
|
|
|
}) => (
|
2017-02-20 18:15:36 +02:00
|
|
|
<StyledList arrowPosition={arrowPosition} {...props}>
|
2017-02-15 03:19:26 +02:00
|
|
|
{children}
|
|
|
|
</StyledList>
|
|
|
|
);
|
|
|
|
|
|
|
|
Tooltip.propTypes = {
|
2016-12-20 14:02:47 +02:00
|
|
|
arrowPosition: React.PropTypes.object,
|
2017-02-20 18:15:36 +02:00
|
|
|
children: React.PropTypes.node
|
2016-12-20 14:02:47 +02:00
|
|
|
};
|
2017-02-15 03:19:26 +02:00
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
export default Baseline(
|
2017-02-15 03:19:26 +02:00
|
|
|
Tooltip
|
|
|
|
);
|