import * as React from "react"; /** A help tooltip that shows information about a feature when hovered over. Example: "". */ export class Help extends React.Component { constructor(props: HelpProps) { super(props); this.state = {isHovered: false}; } /** The output of this function is what the user will see when the Help icon is hovered over. */ isHovered({text}: {text: string}) { return
{ text }
; } /** This is what the user sees when the icon is not hovered over. */ notHovered(props: HelpProps) { // We probably don't need to show anything when not hovered. // SEE: render(); for default stuff. return
; } render() { let Comp = (this.state.isHovered ? this.isHovered : this.notHovered); return
{ this.setState({isHovered: true});}} onMouseLeave={() => { this.setState({isHovered: false});}}>
; }; } interface HelpProps { text: string; } interface HelpState { isHovered: boolean; }