This also tries to make the autoscroll functionality a bit more consistent, where all items are always shown in the list, but items which have not yet occurred will be partially transparent until they happen. Due to that change, autoscroll behavior which previously always went all the way to the bottom of a list didn't make sense anymore, so now it scrolls to the current item.
51 lines
No EOL
1 KiB
TypeScript
51 lines
No EOL
1 KiB
TypeScript
import React from 'react';
|
|
import { Popup } from 'UI';
|
|
|
|
interface Props {
|
|
timeout: number
|
|
position: string
|
|
tooltip: string
|
|
trigger: React.ReactNode
|
|
}
|
|
|
|
export default class Tooltip extends React.PureComponent<Props> {
|
|
static defaultProps = {
|
|
timeout: 500,
|
|
}
|
|
state = {
|
|
open: false,
|
|
}
|
|
mouseOver = false
|
|
onMouseEnter = () => {
|
|
this.mouseOver = true;
|
|
setTimeout(() => {
|
|
if (this.mouseOver) this.setState({ open: true });
|
|
}, this.props.timeout)
|
|
}
|
|
onMouseLeave = () => {
|
|
this.mouseOver = false;
|
|
this.setState({
|
|
open: false,
|
|
});
|
|
}
|
|
|
|
render() {
|
|
const { trigger, tooltip, position } = this.props;
|
|
const { open } = this.state;
|
|
return (
|
|
<Popup
|
|
open={open}
|
|
content={tooltip}
|
|
disabled={!tooltip}
|
|
position={position}
|
|
>
|
|
<span //TODO: no wrap component around
|
|
onMouseEnter={ this.onMouseEnter }
|
|
onMouseLeave={ this.onMouseLeave }
|
|
>
|
|
{ trigger }
|
|
</span>
|
|
</Popup>
|
|
);
|
|
}
|
|
} |