1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 21:08:57 +00:00
trezor-wallet/src/components/Tooltip/index.js

71 lines
1.7 KiB
JavaScript
Raw Normal View History

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';
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
const Content = styled.div`
2018-10-04 15:42:13 +00:00
max-width: ${props => `${props.maxWidth}px` || 'auto'};
`;
const ContentWrapper = styled.div`
display: block;
`;
2018-10-04 15:52:58 +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;
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 && (
<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,
]),
readMoreLink: PropTypes.string,
2018-09-05 09:47:07 +00:00
};
export default Tooltip;