Lint Code [skip actions]

This commit is contained in:
github-actions
2023-04-10 00:59:40 +00:00
parent 127d45f21f
commit 1239bc05b2
7 changed files with 103 additions and 87 deletions

View File

@@ -1,7 +1,5 @@
export type Page = "Home" | "Commands" | "Avatars" | "Items" export type Page = "Home" | "Commands" | "Avatars" | "Items" | "Scenes";
| "Scenes"; export type Days = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday";
export type Days = "Sunday" | "Monday" | "Tuesday"
| "Wednesday" | "Thursday" | "Friday" | "Saturday";
export type Command = { export type Command = {
name: string[]; name: string[];
@@ -113,13 +111,21 @@ export function isPage(page: string): page is Page {
*/ */
export function itemTypeToString(type: ItemType): string { export function itemTypeToString(type: ItemType): string {
switch (type) { switch (type) {
default: return "Unknown"; default:
case ItemType.None: return "None"; return "Unknown";
case ItemType.Virtual: return "Virtual"; case ItemType.None:
case ItemType.Material: return "Material"; return "None";
case ItemType.Reliquary: return "Reliquary"; case ItemType.Virtual:
case ItemType.Weapon: return "Weapon"; return "Virtual";
case ItemType.Display: return "Display"; case ItemType.Material:
case ItemType.Furniture: return "Furniture"; return "Material";
case ItemType.Reliquary:
return "Reliquary";
case ItemType.Weapon:
return "Weapon";
case ItemType.Display:
return "Display";
case ItemType.Furniture:
return "Furniture";
} }
} }

View File

@@ -97,7 +97,8 @@ class ItemsPage extends React.Component<{}, IState> {
* @private * @private
*/ */
private async setSelectedItem(item: ItemType): Promise<void> { private async setSelectedItem(item: ItemType): Promise<void> {
let data: ItemInfo | null = null; try { let data: ItemInfo | null = null;
try {
data = await fetchItemData(item); data = await fetchItemData(item);
} catch {} } catch {}
@@ -133,19 +134,15 @@ class ItemsPage extends React.Component<{}, IState> {
itemsPerRow={18} itemsPerRow={18}
gap={5} gap={5}
itemGap={5} itemGap={5}
render={(item) => <Item render={(item) => (
key={item.id} data={item} <Item key={item.id} data={item} onClick={() => this.setSelectedItem(item)} />
onClick={() => this.setSelectedItem(item)} )}
/>}
/> />
) : undefined} ) : undefined}
</div> </div>
<div className={"ItemsPage_Card"}> <div className={"ItemsPage_Card"}>
<ItemCard <ItemCard item={this.state.selected} info={this.state.selectedInfo} />
item={this.state.selected}
info={this.state.selectedInfo}
/>
</div> </div>
</div> </div>
); );

View File

@@ -14,14 +14,22 @@ import "@css/pages/ScenesPage.scss";
*/ */
function sceneTypeToString(type: SceneType): string { function sceneTypeToString(type: SceneType): string {
switch (type) { switch (type) {
default: return "Unknown"; default:
case SceneType.None: return "None"; return "Unknown";
case SceneType.World: return "World"; case SceneType.None:
case SceneType.Activity: return "Activity"; return "None";
case SceneType.Dungeon: return "Dungeon"; case SceneType.World:
case SceneType.Room: return "Room"; return "World";
case SceneType.HomeRoom: return "Home Room"; case SceneType.Activity:
case SceneType.HomeWorld: return "Home World"; return "Activity";
case SceneType.Dungeon:
return "Dungeon";
case SceneType.Room:
return "Room";
case SceneType.HomeRoom:
return "Home Room";
case SceneType.HomeWorld:
return "Home World";
} }
} }
@@ -45,11 +53,12 @@ class ScenesPage extends React.PureComponent {
key={command.identifier} key={command.identifier}
title={command.identifier} title={command.identifier}
alternate={`ID: ${command.id} | ${sceneTypeToString(command.type)}`} alternate={`ID: ${command.id} | ${sceneTypeToString(command.type)}`}
button={( button={
<button className={"ScenesPage_Button"} <button className={"ScenesPage_Button"} onClick={this.teleport.bind(this)}>
onClick={this.teleport.bind(this)} Teleport
>Teleport</button> </button>
)} rightOffset={13} }
rightOffset={13}
height={75} height={75}
/> />
))} ))}

View File

@@ -40,12 +40,14 @@ class SideBar extends React.Component<{}, IState> {
The Ultimate Anime Game Handbook The Ultimate Anime Game Handbook
</h1> </h1>
<div style={{ <div
style={{
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
justifyContent: "space-between", justifyContent: "space-between",
height: "100%" height: "100%"
}}> }}
>
<div className={"SideBar_Buttons"}> <div className={"SideBar_Buttons"}>
<SideBarButton name={"Commands"} anchor={"Commands"} /> <SideBarButton name={"Commands"} anchor={"Commands"} />
<SideBarButton name={"Characters"} anchor={"Avatars"} /> <SideBarButton name={"Characters"} anchor={"Avatars"} />

View File

@@ -52,9 +52,7 @@ class Card extends React.PureComponent<IProps> {
</div> </div>
{this.props.button ? ( {this.props.button ? (
<div className={"Card_Button"} <div className={"Card_Button"} style={{ marginRight: this.props.rightOffset ?? 0 }}>
style={{ marginRight: this.props.rightOffset ?? 0 }}
>
{this.props.button} {this.props.button}
</div> </div>
) : undefined} ) : undefined}

View File

@@ -52,9 +52,7 @@ class Item extends React.Component<IProps, IState> {
render() { render() {
return ( return (
<div className={"Item"} <div className={"Item"} onClick={this.props.onClick}>
onClick={this.props.onClick}
>
<div className={"Item_Background"}> <div className={"Item_Background"}>
{this.state.icon && ( {this.state.icon && (
<img <img

View File

@@ -14,8 +14,7 @@ import "@css/widgets/ItemCard.scss";
function toDescription(description: string | undefined): JSX.Element[] { function toDescription(description: string | undefined): JSX.Element[] {
if (!description) return []; if (!description) return [];
return description.split("\\n") return description.split("\\n").map((line, index) => {
.map((line, index) => {
return <p key={index}>{line}</p>; return <p key={index}>{line}</p>;
}); });
} }
@@ -65,8 +64,7 @@ class ItemCard extends React.Component<IProps, IState> {
private addCount(positive: boolean, multiple: boolean) { private addCount(positive: boolean, multiple: boolean) {
let { count } = this.state; let { count } = this.state;
if (count === "") count = 1; if (count === "") count = 1;
if (typeof count == "string") if (typeof count == "string") count = parseInt(count);
count = parseInt(count);
if (count < 1) count = 1; if (count < 1) count = 1;
let increment = 1; let increment = 1;
@@ -105,28 +103,33 @@ class ItemCard extends React.Component<IProps, IState> {
<p>{data?.type ?? itemTypeToString(item.type)}</p> <p>{data?.type ?? itemTypeToString(item.type)}</p>
</div> </div>
{ this.state.icon && <img {this.state.icon && (
<img
className={"ItemCard_Icon"} className={"ItemCard_Icon"}
alt={item.name} alt={item.name}
src={itemIcon(item)} src={itemIcon(item)}
onError={() => this.setState({ icon: false })} onError={() => this.setState({ icon: false })}
/> } />
)}
</div> </div>
<div className={"ItemCard_Description"}> <div className={"ItemCard_Description"}>{toDescription(data?.description)}</div>
{toDescription(data?.description)}
</div>
</div> </div>
<div className={"ItemCard_Actions"}> <div className={"ItemCard_Actions"}>
<div className={"ItemCard_Counter"}> <div className={"ItemCard_Counter"}>
<div onClick={() => this.addCount(false, false)} <div
onClick={() => this.addCount(false, false)}
onContextMenu={(e) => { onContextMenu={(e) => {
e.preventDefault(); e.preventDefault();
this.addCount(false, true); this.addCount(false, true);
}} }}
className={"ItemCard_Operation"}>-</div> className={"ItemCard_Operation"}
<input type={"text"} >
-
</div>
<input
type={"text"}
value={this.state.count} value={this.state.count}
className={"ItemCard_Count"} className={"ItemCard_Count"}
onChange={this.updateCount.bind(this)} onChange={this.updateCount.bind(this)}
@@ -136,18 +139,21 @@ class ItemCard extends React.Component<IProps, IState> {
} }
}} }}
/> />
<div onClick={() => this.addCount(true, false)} <div
onClick={() => this.addCount(true, false)}
onContextMenu={(e) => { onContextMenu={(e) => {
e.preventDefault(); e.preventDefault();
this.addCount(true, true); this.addCount(true, true);
}} }}
className={"ItemCard_Operation"}>+</div> className={"ItemCard_Operation"}
>
+
</div>
</div> </div>
<button <button className={"ItemCard_Submit"} onClick={this.addToInventory.bind(this)}>
className={"ItemCard_Submit"} Add to Inventory
onClick={this.addToInventory.bind(this)} </button>
>Add to Inventory</button>
</div> </div>
</div> </div>
) : undefined; ) : undefined;