mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-27 11:27:04 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
+44
-37
@@ -5,50 +5,57 @@
|
||||
import * as React from "react";
|
||||
|
||||
interface IStdButtonProps {
|
||||
addClasses?: string;
|
||||
disabled?: boolean;
|
||||
id?: string;
|
||||
onClick?: (e: React.MouseEvent<HTMLElement>) => any;
|
||||
style?: any;
|
||||
text: string | JSX.Element;
|
||||
tooltip?: string | JSX.Element;
|
||||
addClasses?: string;
|
||||
disabled?: boolean;
|
||||
id?: string;
|
||||
onClick?: (e: React.MouseEvent<HTMLElement>) => any;
|
||||
style?: any;
|
||||
text: string | JSX.Element;
|
||||
tooltip?: string | JSX.Element;
|
||||
}
|
||||
|
||||
type IInnerHTMLMarkup = {
|
||||
__html: string;
|
||||
}
|
||||
__html: string;
|
||||
};
|
||||
|
||||
export function StdButton(props: IStdButtonProps): React.ReactElement {
|
||||
const hasTooltip = props.tooltip != null && props.tooltip !== "";
|
||||
let className = props.disabled ? "std-button-disabled" : "std-button";
|
||||
if (hasTooltip) {
|
||||
className += " tooltip";
|
||||
}
|
||||
const hasTooltip = props.tooltip != null && props.tooltip !== "";
|
||||
let className = props.disabled ? "std-button-disabled" : "std-button";
|
||||
if (hasTooltip) {
|
||||
className += " tooltip";
|
||||
}
|
||||
|
||||
if (typeof props.addClasses === "string") {
|
||||
className += ` ${props.addClasses}`;
|
||||
}
|
||||
if (typeof props.addClasses === "string") {
|
||||
className += ` ${props.addClasses}`;
|
||||
}
|
||||
|
||||
// Tooltip will be set using inner HTML
|
||||
let tooltip;
|
||||
if (hasTooltip) {
|
||||
if(typeof props.tooltip === 'string') {
|
||||
const tooltipMarkup: IInnerHTMLMarkup = {
|
||||
__html: props.tooltip,
|
||||
}
|
||||
tooltip = <span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>
|
||||
} else {
|
||||
tooltip = <span className={"tooltiptext"}>{props.tooltip}</span>
|
||||
}
|
||||
// Tooltip will be set using inner HTML
|
||||
let tooltip;
|
||||
if (hasTooltip) {
|
||||
if (typeof props.tooltip === "string") {
|
||||
const tooltipMarkup: IInnerHTMLMarkup = {
|
||||
__html: props.tooltip,
|
||||
};
|
||||
tooltip = (
|
||||
<span
|
||||
className={"tooltiptext"}
|
||||
dangerouslySetInnerHTML={tooltipMarkup}
|
||||
></span>
|
||||
);
|
||||
} else {
|
||||
tooltip = <span className={"tooltiptext"}>{props.tooltip}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button className={className} id={props.id} onClick={props.onClick} style={props.style}>
|
||||
{props.text}
|
||||
{
|
||||
hasTooltip &&
|
||||
tooltip
|
||||
}
|
||||
</button>
|
||||
)
|
||||
return (
|
||||
<button
|
||||
className={className}
|
||||
id={props.id}
|
||||
onClick={props.onClick}
|
||||
style={props.style}
|
||||
>
|
||||
{props.text}
|
||||
{hasTooltip && tooltip}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user