* Combine AddressSummary & Row * Cleanup address rendering * Tiny tags cleanups * Remove unused ui--AddressSummary overrides * Column component * Columar * Cleanups * Remove hot client * Backport data padding * Some small -> styled-components conversions * Move RecebtlyOffline styles * Cleanups
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
// Copyright 2017-2019 @polkadot/ui-app authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { BareProps } from './types';
|
|
|
|
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import ReactTooltip from 'react-tooltip';
|
|
|
|
import { classes } from './util';
|
|
|
|
const rootElement = document.getElementById('tooltips');
|
|
|
|
type Props = BareProps & {
|
|
dataFor?: string,
|
|
effect?: 'solid' | 'float'
|
|
offset?: { bottom?: number, left?: number, right?: number, top?: number },
|
|
place?: 'bottom' | 'top' | 'right' | 'left',
|
|
text: React.ReactNode,
|
|
trigger: string
|
|
};
|
|
|
|
export default class Tooltip extends React.PureComponent<Props> {
|
|
private tooltipContainer: HTMLElement;
|
|
|
|
constructor (props: Props) {
|
|
super(props);
|
|
|
|
this.tooltipContainer = document.createElement('div');
|
|
}
|
|
|
|
componentDidMount () {
|
|
if (rootElement !== null) {
|
|
rootElement.appendChild(this.tooltipContainer);
|
|
}
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
if (rootElement !== null) {
|
|
rootElement.removeChild(this.tooltipContainer);
|
|
}
|
|
}
|
|
|
|
render () {
|
|
const { className, effect = 'solid', offset, place = 'bottom', text, trigger } = this.props;
|
|
|
|
return ReactDOM.createPortal(
|
|
<ReactTooltip
|
|
id={trigger}
|
|
delayShow={250}
|
|
effect={effect}
|
|
offset={offset}
|
|
place={place}
|
|
className={classes('ui--Tooltip', className)}
|
|
>
|
|
{text}
|
|
</ReactTooltip>,
|
|
this.tooltipContainer
|
|
);
|
|
}
|
|
}
|