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" export type Page = "Home" | "Commands" | "Avatars" | "Items" | "Entities" | "Scenes";
| "Entities" | "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[];
@ -136,13 +134,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

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

View File

@ -97,9 +97,10 @@ 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 {}
this.setState({ this.setState({
selected: item, selected: item,
@ -133,19 +134,20 @@ class ItemsPage extends React.Component<{}, IState> {
itemsPerRow={18} itemsPerRow={18}
gap={5} gap={5}
itemGap={5} itemGap={5}
render={(item) => <MiniCard render={(item) => (
key={item.id} data={item} icon={itemIcon(item)} <MiniCard
key={item.id}
data={item}
icon={itemIcon(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

@ -13,8 +13,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>;
}); });
} }
@ -64,8 +63,7 @@ class EntityCard 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;
@ -104,28 +102,33 @@ class EntityCard extends React.Component<IProps, IState> {
<p>{data?.type ?? ""}</p> <p>{data?.type ?? ""}</p>
</div> </div>
{ this.state.icon && <img {this.state.icon && (
<img
className={"ItemCard_Icon"} className={"ItemCard_Icon"}
alt={entity.name} alt={entity.name}
src={entityIcon(entity)} src={entityIcon(entity)}
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)}
@ -135,18 +138,21 @@ class EntityCard 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.summonAtPlayer.bind(this)}>
className={"ItemCard_Submit"} Summon
onClick={this.summonAtPlayer.bind(this)} </button>
>Summon</button>
</div> </div>
</div> </div>
) : undefined; ) : undefined;

View File

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