mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +02:00
all the lints
This commit is contained in:
@@ -5,7 +5,7 @@ import * as React from "react";
|
||||
|
||||
interface IStdButtonPurchasedProps {
|
||||
onClick?: (e: React.MouseEvent<HTMLElement>) => any;
|
||||
style?: object;
|
||||
style?: any;
|
||||
text: string;
|
||||
tooltip?: string;
|
||||
}
|
||||
@@ -15,18 +15,35 @@ type IInnerHTMLMarkup = {
|
||||
}
|
||||
|
||||
export class StdButtonPurchased extends React.Component<IStdButtonPurchasedProps, any> {
|
||||
render() {
|
||||
const hasTooltip = this.props.tooltip != null && this.props.tooltip !== "";
|
||||
|
||||
constructor(props: IStdButtonPurchasedProps) {
|
||||
super(props);
|
||||
this.hasTooltip = this.hasTooltip.bind(this);
|
||||
this.tooltip = this.tooltip.bind(this);
|
||||
}
|
||||
|
||||
hasTooltip(): boolean {
|
||||
return this.props.tooltip != null && this.props.tooltip !== "";
|
||||
}
|
||||
|
||||
tooltip(): string {
|
||||
if(!this.props.tooltip) return "";
|
||||
return this.props.tooltip;
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
let className = "std-button-bought";
|
||||
if (hasTooltip) {
|
||||
if (this.hasTooltip()) {
|
||||
className += " tooltip";
|
||||
}
|
||||
|
||||
// Tooltip will be set using inner HTML
|
||||
let tooltipMarkup: IInnerHTMLMarkup | null;
|
||||
if (hasTooltip) {
|
||||
let tooltipMarkup: IInnerHTMLMarkup = {
|
||||
__html: "",
|
||||
}
|
||||
if (this.hasTooltip()) {
|
||||
tooltipMarkup = {
|
||||
__html: this.props.tooltip!,
|
||||
__html: this.tooltip(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +51,8 @@ export class StdButtonPurchased extends React.Component<IStdButtonPurchasedProps
|
||||
<button className={className} onClick={this.props.onClick} style={this.props.style}>
|
||||
{this.props.text}
|
||||
{
|
||||
hasTooltip &&
|
||||
<span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup!}></span>
|
||||
this.hasTooltip() &&
|
||||
<span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>
|
||||
}
|
||||
</button>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user