2018-10-02 16:48:27 -04:00
|
|
|
import React, { Component } from 'react';
|
2018-09-11 15:59:37 -04:00
|
|
|
|
2018-10-01 12:20:25 -04:00
|
|
|
import { InfoIcon } from './icons';
|
2018-09-11 15:59:37 -04:00
|
|
|
|
2019-11-07 02:39:26 -05:00
|
|
|
import './tooltip.css';
|
|
|
|
|
2019-11-05 15:13:10 -05:00
|
|
|
interface TooltipProps {
|
|
|
|
text: string;
|
|
|
|
}
|
2019-08-14 03:45:00 -04:00
|
|
|
|
2019-11-05 15:13:10 -05:00
|
|
|
interface TooltipState {
|
|
|
|
active: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Tooltip extends Component<TooltipProps, TooltipState> {
|
2018-10-01 11:59:39 -04:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
active: false
|
|
|
|
};
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
2018-09-11 15:59:37 -04:00
|
|
|
|
2018-10-01 11:59:39 -04:00
|
|
|
handleClick(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
this.setState({
|
|
|
|
active: !this.state.active
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="tooltip-wrap">
|
2019-05-27 11:31:48 -04:00
|
|
|
<button className={(this.state.active? 'active ': '') + 'tooltip-hint icon-button'}
|
2019-05-27 11:39:16 -04:00
|
|
|
title={this.props.text}
|
|
|
|
onClick={this.handleClick}>
|
2018-10-25 06:48:25 -04:00
|
|
|
Hint
|
2018-10-01 12:20:25 -04:00
|
|
|
<InfoIcon />
|
2018-10-01 11:59:39 -04:00
|
|
|
</button>
|
|
|
|
{
|
|
|
|
this.state.active?
|
2019-05-27 11:39:16 -04:00
|
|
|
(
|
|
|
|
<div className="tooltip bs-tooltip-bottom">
|
|
|
|
<div className="arrow"></div>
|
|
|
|
<div className="tooltip-inner">{this.props.text}</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
: null
|
2018-10-01 11:59:39 -04:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-05-27 13:26:29 -04:00
|
|
|
|
2018-09-11 15:59:37 -04:00
|
|
|
export default Tooltip;
|