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

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-01 11:59:39 -04:00
import React, { Component, Fragment } 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() {
console.log(this.state, this.props)
return (
<div className="tooltip-wrap">
<button className="tooltip-hint icon-button" title={this.props.text}
onClick={this.handleClick}>
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;