colouring-montreal/app/src/frontend/tooltip.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-02 16:48:27 -04:00
import React, { Component } from 'react';
2018-09-11 15:59:37 -04:00
import './tooltip.css';
2018-10-01 12:20:25 -04:00
import { InfoIcon } from './icons';
2018-09-11 15:59:37 -04:00
2018-10-01 11:59:39 -04:00
class Tooltip extends Component {
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">
<button className={(this.state.active? "active ": "") + "tooltip-hint icon-button"}
title={this.props.text}
2018-10-01 11:59:39 -04:00
onClick={this.handleClick}>
Hint
2018-10-01 12:20:25 -04:00
<InfoIcon />
2018-10-01 11:59:39 -04:00
</button>
{
this.state.active?
(
<div className="tooltip bs-tooltip-bottom">
<div className="arrow"></div>
<div className="tooltip-inner">{this.props.text}</div>
</div>
)
: null
}
</div>
);
}
}
2018-09-11 15:59:37 -04:00
export default Tooltip;