Merge pull request #5223 from whymarrh/tx-error-tooltips
Show transaction error message tooltips for statusesfeature/default_network_editable
commit
a43e71693f
@ -1,33 +1,66 @@ |
|||||||
const Component = require('react').Component |
import PropTypes from 'prop-types' |
||||||
const h = require('react-hyperscript') |
import React, {PureComponent} from 'react' |
||||||
const inherits = require('util').inherits |
import {Tooltip as ReactTippy} from 'react-tippy' |
||||||
const ReactTippy = require('react-tippy').Tooltip |
|
||||||
|
|
||||||
module.exports = Tooltip |
export default class Tooltip extends PureComponent { |
||||||
|
static defaultProps = { |
||||||
inherits(Tooltip, Component) |
arrow: true, |
||||||
function Tooltip () { |
children: null, |
||||||
Component.call(this) |
containerClassName: '', |
||||||
|
hideOnClick: false, |
||||||
|
onHidden: null, |
||||||
|
position: 'left', |
||||||
|
size: 'small', |
||||||
|
title: null, |
||||||
|
trigger: 'mouseenter', |
||||||
|
wrapperClassName: '', |
||||||
} |
} |
||||||
|
|
||||||
Tooltip.prototype.render = function () { |
static propTypes = { |
||||||
const props = this.props |
arrow: PropTypes.bool, |
||||||
const { position, title, children, wrapperClassName, containerClassName, onHidden } = props |
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, |
||||||
|
} |
||||||
|
|
||||||
return h('div', { |
render () { |
||||||
className: wrapperClassName, |
const {arrow, children, containerClassName, position, size, title, trigger, onHidden, wrapperClassName } = this.props |
||||||
}, [ |
|
||||||
|
|
||||||
h(ReactTippy, { |
if (!title) { |
||||||
title, |
return ( |
||||||
position: position || 'left', |
<div className={wrapperClassName}> |
||||||
trigger: 'mouseenter', |
{children} |
||||||
hideOnClick: false, |
</div> |
||||||
size: 'small', |
) |
||||||
arrow: true, |
} |
||||||
className: containerClassName, |
|
||||||
onHidden, |
|
||||||
}, children), |
|
||||||
|
|
||||||
]) |
return ( |
||||||
|
<div className={wrapperClassName}> |
||||||
|
<ReactTippy |
||||||
|
className={containerClassName} |
||||||
|
title={title} |
||||||
|
position={position} |
||||||
|
trigger={trigger} |
||||||
|
hideOnClick={false} |
||||||
|
size={size} |
||||||
|
arrow={arrow} |
||||||
|
onHidden={onHidden} |
||||||
|
> |
||||||
|
{children} |
||||||
|
</ReactTippy> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue