2018-10-04 15:42:13 +00:00
|
|
|
import React from 'react';
|
2018-09-05 09:47:07 +00:00
|
|
|
import RcTooltip from 'rc-tooltip';
|
2018-09-05 09:52:38 +00:00
|
|
|
import colors from 'config/colors';
|
2018-09-27 11:03:50 +00:00
|
|
|
import Link from 'components/Link';
|
2018-09-05 09:47:07 +00:00
|
|
|
import styled from 'styled-components';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2018-10-04 15:42:13 +00:00
|
|
|
const Wrapper = styled.div``;
|
2018-09-05 09:52:38 +00:00
|
|
|
|
2018-09-27 11:03:50 +00:00
|
|
|
const Content = styled.div`
|
2018-10-04 15:42:13 +00:00
|
|
|
max-width: ${props => `${props.maxWidth}px` || 'auto'};
|
2018-09-27 11:03:50 +00:00
|
|
|
`;
|
|
|
|
|
2018-10-05 13:57:51 +00:00
|
|
|
const ContentWrapper = styled.div`
|
|
|
|
display: block;
|
|
|
|
`;
|
2018-10-04 15:52:58 +00:00
|
|
|
|
2018-09-27 11:03:50 +00:00
|
|
|
const ReadMore = styled.div`
|
2018-10-04 15:52:58 +00:00
|
|
|
margin-top: 15px;
|
2018-09-27 11:18:41 +00:00
|
|
|
padding: 10px 0 5px 0;
|
2018-09-27 11:03:50 +00:00
|
|
|
text-align: center;
|
|
|
|
width: 100%;
|
|
|
|
color: ${colors.WHITE};
|
|
|
|
border-top: 1px solid ${colors.TEXT_SECONDARY};
|
|
|
|
`;
|
|
|
|
|
2018-10-04 15:42:13 +00:00
|
|
|
const Tooltip = ({
|
|
|
|
maxWidth,
|
|
|
|
className,
|
|
|
|
placement,
|
|
|
|
content,
|
|
|
|
readMoreLink,
|
|
|
|
children,
|
|
|
|
}) => (
|
|
|
|
<Wrapper className={className}>
|
|
|
|
<RcTooltip
|
|
|
|
arrowContent={<div className="rc-tooltip-arrow-inner" />}
|
|
|
|
placement={placement}
|
|
|
|
overlay={() => (
|
|
|
|
<ContentWrapper>
|
|
|
|
<Content maxWidth={maxWidth}>{content}</Content>
|
|
|
|
{readMoreLink && (
|
2018-10-10 12:05:55 +00:00
|
|
|
<Link href={readMoreLink}>
|
2018-10-04 15:42:13 +00:00
|
|
|
<ReadMore>Read more</ReadMore>
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</ContentWrapper>)}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</RcTooltip>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
2018-09-05 09:47:07 +00:00
|
|
|
|
|
|
|
Tooltip.propTypes = {
|
2018-09-05 11:01:28 +00:00
|
|
|
className: PropTypes.string,
|
2018-09-05 09:47:07 +00:00
|
|
|
placement: PropTypes.string,
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.element,
|
|
|
|
PropTypes.string,
|
|
|
|
]),
|
2018-09-20 14:00:14 +00:00
|
|
|
maxWidth: PropTypes.number,
|
2018-09-05 09:47:07 +00:00
|
|
|
content: PropTypes.oneOfType([
|
|
|
|
PropTypes.element,
|
|
|
|
PropTypes.string,
|
|
|
|
]),
|
2018-09-27 11:03:50 +00:00
|
|
|
readMoreLink: PropTypes.string,
|
2018-09-05 09:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Tooltip;
|