mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
more convert
This commit is contained in:
parent
07c0b708d7
commit
3d2aeb63a0
@ -1,3 +1,5 @@
|
||||
import { IOfficeSpace } from "./IOfficeSpace";
|
||||
import { IMap } from "../types";
|
||||
|
||||
export interface IDivision {
|
||||
name: string;
|
||||
|
20
src/Corporation/ui/CityTab.tsx
Normal file
20
src/Corporation/ui/CityTab.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
interface IProps {
|
||||
onClick: () => void;
|
||||
name: string;
|
||||
current: boolean;
|
||||
}
|
||||
|
||||
export function CityTab(props: IProps): React.ReactElement {
|
||||
let className = "cmpy-mgmt-city-tab";
|
||||
if (props.current) {
|
||||
className += " current";
|
||||
}
|
||||
|
||||
return (
|
||||
<button className={className} onClick={props.onClick}>
|
||||
{props.name}
|
||||
</button>
|
||||
)
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
// React Components for the Corporation UI's City navigation tabs
|
||||
// These allow player to navigate between different cities for each industry
|
||||
import React from "react";
|
||||
import { BaseReactComponent } from "./BaseReactComponent";
|
||||
|
||||
export class CityTabs extends BaseReactComponent {
|
||||
constructor(props) {
|
||||
// An object with [key = city name] and [value = click handler]
|
||||
// needs to be passed into the constructor as the "onClicks" property.
|
||||
// We'll make sure that that happens here
|
||||
if (props.onClicks == null) {
|
||||
throw new Error(`CityTabs component constructed without onClick handlers`);
|
||||
}
|
||||
if (props.city == null) {
|
||||
throw new Error(`CityTabs component constructed without 'city' property`)
|
||||
}
|
||||
if (props.cityStateSetter == null) {
|
||||
throw new Error(`CityTabs component constructed without 'cityStateSetter' property`)
|
||||
}
|
||||
|
||||
super(props);
|
||||
}
|
||||
|
||||
renderTab(props) {
|
||||
let className = "cmpy-mgmt-city-tab";
|
||||
if (props.current) {
|
||||
className += " current";
|
||||
}
|
||||
|
||||
return (
|
||||
<button className={className} onClick={props.onClick} key={props.key}>
|
||||
{props.key}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
const division = this.routing().currentDivision;
|
||||
|
||||
const tabs = [];
|
||||
|
||||
// Tabs for each city
|
||||
for (const cityName in this.props.onClicks) {
|
||||
tabs.push(this.renderTab({
|
||||
current: this.props.city === cityName,
|
||||
key: cityName,
|
||||
onClick: this.props.onClicks[cityName],
|
||||
}));
|
||||
}
|
||||
|
||||
// Tab to "Expand into new City"
|
||||
const newCityOnClick = this.eventHandler().createNewCityPopup.bind(this.eventHandler(), division, this.props.cityStateSetter);
|
||||
|
||||
tabs.push(this.renderTab({
|
||||
current: false,
|
||||
key: "Expand into new City",
|
||||
onClick: newCityOnClick,
|
||||
}));
|
||||
|
||||
return tabs;
|
||||
}
|
||||
}
|
36
src/Corporation/ui/CityTabs.tsx
Normal file
36
src/Corporation/ui/CityTabs.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
// React Components for the Corporation UI's City navigation tabs
|
||||
// These allow player to navigate between different cities for each industry
|
||||
import React from "react";
|
||||
import { CityTab } from "./CityTab";
|
||||
|
||||
interface IProps {
|
||||
eventHandler: any;
|
||||
routing: any;
|
||||
onClicks: {[key: string]: () => void};
|
||||
city: string; // currentCity
|
||||
cityStateSetter: any;
|
||||
}
|
||||
|
||||
export function CityTabs(props: IProps): React.ReactElement {
|
||||
const division = props.routing.currentDivision;
|
||||
|
||||
const tabs = [];
|
||||
|
||||
// Tabs for each city
|
||||
for (const cityName in props.onClicks) {
|
||||
tabs.push(
|
||||
<CityTab current={props.city === cityName} key={cityName} name={cityName} onClick={props.onClicks[cityName]} />
|
||||
);
|
||||
}
|
||||
|
||||
tabs.push(
|
||||
<CityTab
|
||||
current={false}
|
||||
key={"Expand into new City"}
|
||||
name={"Expand into new City"}
|
||||
onClick={() => props.eventHandler.createNewCityPopup(division, props.cityStateSetter)}
|
||||
/>
|
||||
);
|
||||
|
||||
return <>{tabs}</>;
|
||||
}
|
@ -12,7 +12,6 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function HeaderTabs(props: IProps): React.ReactElement {
|
||||
console.log(props);
|
||||
function overviewOnClick() {
|
||||
props.routing.routeToOverviewPage();
|
||||
props.corp.rerender();
|
||||
|
Loading…
Reference in New Issue
Block a user