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

72 lines
2.1 KiB
TypeScript
Raw Normal View History

/**
* React component for the tickers configuration section of the Stock Market UI.
* This config lets you change the way stock tickers are displayed (watchlist,
* all/portoflio mode, etc)
*/
import * as React from "react";
import { StdButton } from "../../ui/React/StdButton";
export enum TickerDisplayMode {
AllStocks,
Portfolio,
}
type IProps = {
changeDisplayMode: () => void;
changeWatchlistFilter: (e: React.ChangeEvent<HTMLInputElement>) => void;
collapseAllTickers: () => void;
expandAllTickers: () => void;
tickerDisplayMode: TickerDisplayMode;
}
export class StockTickersConfig extends React.Component<IProps, any> {
constructor(props: IProps) {
super(props);
}
2021-05-01 09:17:31 +02:00
renderDisplayModeButton(): React.ReactNode {
2021-04-30 05:52:56 +02:00
let txt = "";
let tooltip = "";
if (this.props.tickerDisplayMode === TickerDisplayMode.Portfolio) {
txt = "Switch to 'All Stocks' Mode";
tooltip = "Displays all stocks on the WSE";
} else {
txt = "Switch to 'Portfolio' Mode";
tooltip = "Displays only the stocks for which you have shares or orders";
}
return (
<StdButton
onClick={this.props.changeDisplayMode}
text={txt}
tooltip={tooltip}
/>
)
}
2021-05-01 09:17:31 +02:00
render(): React.ReactNode {
return (
<div>
{this.renderDisplayModeButton()}
<StdButton
onClick={this.props.expandAllTickers}
text="Expand Tickers"
/>
<StdButton
onClick={this.props.collapseAllTickers}
text="Collapse Tickers"
/>
<input
className="text-input"
id="stock-market-watchlist-filter"
onChange={this.props.changeWatchlistFilter}
placeholder="Filter Stocks by symbol (comma-separated list)"
type="text"
/>
</div>
)
}
}