Lint Code [skip actions]

This commit is contained in:
github-actions 2023-04-10 05:06:53 +00:00
parent 65532ffd90
commit 5ac93645e4
5 changed files with 94 additions and 78 deletions

View File

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

View File

@ -93,9 +93,10 @@ class EntitiesPage extends React.Component<{}, IState> {
* @private
*/
private async setSelectedItem(entity: EntityType): Promise<void> {
let data: EntityInfo | null = null; try {
let data: EntityInfo | null = null;
try {
data = await fetchEntityData(entity);
} catch { }
} catch {}
this.setState({
selected: entity,
@ -124,24 +125,25 @@ class EntitiesPage extends React.Component<{}, IState> {
{entities.length > 0 ? (
<VirtualizedGrid
list={entities.filter(entity => this.showEntity(entity))}
list={entities.filter((entity) => this.showEntity(entity))}
itemHeight={64}
itemsPerRow={18}
gap={5}
itemGap={5}
render={(entity) => <MiniCard
key={entity.id} data={entity} icon={entityIcon(entity)}
onClick={() => this.setSelectedItem(entity)}
/>}
render={(entity) => (
<MiniCard
key={entity.id}
data={entity}
icon={entityIcon(entity)}
onClick={() => this.setSelectedItem(entity)}
/>
)}
/>
) : undefined}
</div>
<div className={"EntitiesPage_Card"}>
<EntityCard
entity={this.state.selected}
info={this.state.selectedInfo}
/>
<EntityCard entity={this.state.selected} info={this.state.selectedInfo} />
</div>
</div>
);

View File

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

View File

@ -13,10 +13,9 @@ import "@css/widgets/ItemCard.scss";
function toDescription(description: string | undefined): JSX.Element[] {
if (!description) return [];
return description.split("\\n")
.map((line, index) => {
return <p key={index}>{line}</p>;
});
return description.split("\\n").map((line, index) => {
return <p key={index}>{line}</p>;
});
}
interface IProps {
@ -64,8 +63,7 @@ class EntityCard extends React.Component<IProps, IState> {
private addCount(positive: boolean, multiple: boolean) {
let { count } = this.state;
if (count === "") count = 1;
if (typeof count == "string")
count = parseInt(count);
if (typeof count == "string") count = parseInt(count);
if (count < 1) count = 1;
let increment = 1;
@ -104,49 +102,57 @@ class EntityCard extends React.Component<IProps, IState> {
<p>{data?.type ?? ""}</p>
</div>
{ this.state.icon && <img
className={"ItemCard_Icon"}
alt={entity.name}
src={entityIcon(entity)}
onError={() => this.setState({ icon: false })}
/> }
{this.state.icon && (
<img
className={"ItemCard_Icon"}
alt={entity.name}
src={entityIcon(entity)}
onError={() => this.setState({ icon: false })}
/>
)}
</div>
<div className={"ItemCard_Description"}>
{toDescription(data?.description)}
</div>
<div className={"ItemCard_Description"}>{toDescription(data?.description)}</div>
</div>
<div className={"ItemCard_Actions"}>
<div className={"ItemCard_Counter"}>
<div onClick={() => this.addCount(false, false)}
onContextMenu={(e) => {
e.preventDefault();
this.addCount(false, true);
}}
className={"ItemCard_Operation"}>-</div>
<input type={"text"}
value={this.state.count}
className={"ItemCard_Count"}
onChange={this.updateCount.bind(this)}
onBlur={() => {
if (this.state.count == "") {
this.setState({ count: 1 });
}
}}
<div
onClick={() => this.addCount(false, false)}
onContextMenu={(e) => {
e.preventDefault();
this.addCount(false, true);
}}
className={"ItemCard_Operation"}
>
-
</div>
<input
type={"text"}
value={this.state.count}
className={"ItemCard_Count"}
onChange={this.updateCount.bind(this)}
onBlur={() => {
if (this.state.count == "") {
this.setState({ count: 1 });
}
}}
/>
<div onClick={() => this.addCount(true, false)}
onContextMenu={(e) => {
e.preventDefault();
this.addCount(true, true);
}}
className={"ItemCard_Operation"}>+</div>
<div
onClick={() => this.addCount(true, false)}
onContextMenu={(e) => {
e.preventDefault();
this.addCount(true, true);
}}
className={"ItemCard_Operation"}
>
+
</div>
</div>
<button
className={"ItemCard_Submit"}
onClick={this.summonAtPlayer.bind(this)}
>Summon</button>
<button className={"ItemCard_Submit"} onClick={this.summonAtPlayer.bind(this)}>
Summon
</button>
</div>
</div>
) : undefined;

View File

@ -5,7 +5,7 @@ import { itemIcon } from "@app/utils";
import "@css/widgets/MiniCard.scss";
interface IProps {
data: { name: string; };
data: { name: string };
icon: string;
onClick?: () => void;
@ -53,9 +53,7 @@ class MiniCard extends React.Component<IProps, IState> {
render() {
return (
<div className={"MiniCard"}
onClick={this.props.onClick}
>
<div className={"MiniCard"} onClick={this.props.onClick}>
<div className={"MiniCard_Background"}>
{this.state.icon && (
<img
@ -67,7 +65,9 @@ class MiniCard extends React.Component<IProps, IState> {
/>
)}
{(!this.state.loaded || !this.state.icon) && <p className={"MiniCard_Label"}>{this.props.data.name}</p>}
{(!this.state.loaded || !this.state.icon) && (
<p className={"MiniCard_Label"}>{this.props.data.name}</p>
)}
</div>
</div>
);