1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/app/components/tooltip-v2.js

67 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-09-09 01:06:19 +02:00
import PropTypes from 'prop-types'
import React, {PureComponent} from 'react'
import {Tooltip as ReactTippy} from 'react-tippy'
2018-09-09 01:06:19 +02:00
export default class Tooltip extends PureComponent {
static defaultProps = {
arrow: true,
children: null,
containerClassName: '',
hideOnClick: false,
onHidden: null,
position: 'left',
size: 'small',
title: null,
trigger: 'mouseenter',
wrapperClassName: '',
}
2018-09-09 01:06:19 +02:00
static propTypes = {
arrow: PropTypes.bool,
children: PropTypes.node,
containerClassName: PropTypes.string,
onHidden: PropTypes.func,
position: PropTypes.oneOf([
'top',
'right',
'bottom',
'left',
]),
size: PropTypes.oneOf([
'small', 'regular', 'big',
]),
title: PropTypes.string,
trigger: PropTypes.any,
wrapperClassName: PropTypes.string,
}
2018-09-09 01:06:19 +02:00
render () {
const {arrow, children, containerClassName, position, size, title, trigger, onHidden, wrapperClassName } = this.props
2018-09-09 01:13:19 +02:00
if (!title) {
return (
<div className={wrapperClassName}>
{children}
</div>
)
}
2018-09-09 01:06:19 +02:00
return (
<div className={wrapperClassName}>
<ReactTippy
className={containerClassName}
title={title}
position={position}
trigger={trigger}
hideOnClick={false}
size={size}
arrow={arrow}
onHidden={onHidden}
>
{children}
</ReactTippy>
</div>
)
}
}