1
0
mirror of https://github.com/yldio/copilot.git synced 2025-01-09 18:40:12 +02:00
copilot/ui/src/components/tooltip/index.js

77 lines
1.5 KiB
JavaScript
Raw Normal View History

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';
2016-12-20 14:02:47 +02:00
const ItemPadder = 9;
const WrapperPadder = 24;
const StyledList = styled.ul`
position: relative;
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;
padding: 0;
2016-12-20 14:02:47 +02:00
min-width: ${remcalc(200)};
2017-02-07 01:00:55 +02:00
${props => props.styles}
2016-12-20 14:02:47 +02:00
${baseBox()}
& > * {
padding: ${remcalc(ItemPadder)} ${remcalc(WrapperPadder)};
&:hover {
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);
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%'
},
...props
2017-02-15 03:19:26 +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,
children: React.PropTypes.node
2016-12-20 14:02:47 +02:00
};
2017-02-15 03:19:26 +02:00
export default Baseline(
2017-02-15 03:19:26 +02:00
Tooltip
);