lbry-desktop/src/renderer/component/common/tooltip.jsx

44 lines
1,005 B
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import * as React from 'react';
2018-03-26 23:32:43 +02:00
import classnames from 'classnames';
type Props = {
body: string,
label?: string,
children: ?React.Node,
icon: ?boolean,
direction: string,
2018-06-15 22:11:02 +02:00
noPadding?: boolean,
2018-03-26 23:32:43 +02:00
};
class ToolTip extends React.PureComponent<Props> {
static defaultProps = {
direction: 'bottom',
};
2018-03-26 23:32:43 +02:00
render() {
2018-06-15 22:11:02 +02:00
const { children, label, body, icon, direction, noPadding } = this.props;
const tooltipContent = children || label;
2018-03-26 23:32:43 +02:00
return (
<span
className={classnames('tooltip', {
'tooltip--label': label && !icon,
'tooltip--icon': icon,
'tooltip--top': direction === 'top',
'tooltip--right': direction === 'right',
'tooltip--bottom': direction === 'bottom',
'tooltip--left': direction === 'left',
2018-06-15 22:11:02 +02:00
'tooltip--no-padding': noPadding
})}
>
{tooltipContent}
<span className="tooltip__body">{body}</span>
2018-03-26 23:32:43 +02:00
</span>
);
}
}
export default ToolTip;