2017-06-29 12:54:02 -06:00
|
|
|
import * as React from "react";
|
2018-06-21 15:04:21 -06:00
|
|
|
import { DocSlug, docLink } from ".";
|
2019-04-02 13:59:37 -06:00
|
|
|
import { t } from "../i18next_wrapper";
|
2017-06-29 12:54:02 -06:00
|
|
|
|
2019-09-24 03:12:33 -06:00
|
|
|
export interface ToolTipProps {
|
2018-03-19 06:57:49 -06:00
|
|
|
children?: React.ReactNode;
|
2017-06-29 12:54:02 -06:00
|
|
|
className?: string;
|
|
|
|
helpText: string;
|
2018-06-21 15:04:21 -06:00
|
|
|
docPage?: DocSlug;
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
|
2019-09-24 03:12:33 -06:00
|
|
|
interface State {
|
|
|
|
isOpen: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ToolTip extends React.Component<ToolTipProps, Partial<State>> {
|
|
|
|
state: State = { isOpen: false };
|
|
|
|
|
|
|
|
private toggle = (property: keyof State) => () =>
|
|
|
|
this.setState({ [property]: !this.state[property] });
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
const isOpen = this.state.isOpen ? "open" : "";
|
|
|
|
let { className } = this.props;
|
|
|
|
const { helpText } = this.props;
|
|
|
|
const cn = className ? className += " title-help" : "title-help";
|
|
|
|
return <div className={cn}>
|
2019-09-26 04:44:51 -06:00
|
|
|
<i className={`fa fa-question-circle title-help-icon`}
|
|
|
|
onClick={this.toggle("isOpen")} />
|
|
|
|
<div className={`title-help-text ${isOpen}`}>
|
|
|
|
<i>{t(helpText)}</i>
|
|
|
|
{this.props.docPage &&
|
|
|
|
<a
|
|
|
|
href={docLink(this.props.docPage)}
|
|
|
|
target="_blank">
|
|
|
|
{" " + t("Documentation")}
|
|
|
|
<i className="fa fa-external-link" />
|
|
|
|
</a>}
|
2019-09-24 03:12:33 -06:00
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
}
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|