bitburner-src/src/StockMarket/ui/StockTickerTxButton.tsx

30 lines
685 B
TypeScript
Raw Normal View History

/**
* React Component for a button that initiates a transaction on the Stock Market UI
* (Buy, Sell, Buy Max, etc.)
*/
import * as React from "react";
type IProps = {
2021-09-05 01:09:30 +02:00
onClick: () => void;
text: string;
tooltip?: JSX.Element | null;
};
export function StockTickerTxButton(props: IProps): React.ReactElement {
2021-09-05 01:09:30 +02:00
let className = "stock-market-input std-button";
2021-09-05 01:09:30 +02:00
const hasTooltip = props.tooltip != null;
if (hasTooltip) {
className += " tooltip";
}
2021-09-05 01:09:30 +02:00
return (
<button className={className} onClick={props.onClick}>
{props.text}
{props.tooltip != null && (
<span className={"tooltiptext"}>{props.tooltip}</span>
)}
</button>
);
}