From 1239bc05b2bb8e995125a7deffff4a3d1afd6687 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 00:59:40 +0000 Subject: [PATCH] Lint Code [skip actions] --- src/handbook/src/backend/types.ts | 30 +++++---- src/handbook/src/ui/pages/ItemsPage.tsx | 17 ++--- src/handbook/src/ui/pages/ScenesPage.tsx | 35 ++++++---- src/handbook/src/ui/views/SideBar.tsx | 14 ++-- src/handbook/src/ui/widgets/Card.tsx | 4 +- src/handbook/src/ui/widgets/Item.tsx | 4 +- src/handbook/src/ui/widgets/ItemCard.tsx | 86 +++++++++++++----------- 7 files changed, 103 insertions(+), 87 deletions(-) diff --git a/src/handbook/src/backend/types.ts b/src/handbook/src/backend/types.ts index 3470f4b98..3fc3d3f0d 100644 --- a/src/handbook/src/backend/types.ts +++ b/src/handbook/src/backend/types.ts @@ -1,7 +1,5 @@ -export type Page = "Home" | "Commands" | "Avatars" | "Items" - | "Scenes"; -export type Days = "Sunday" | "Monday" | "Tuesday" - | "Wednesday" | "Thursday" | "Friday" | "Saturday"; +export type Page = "Home" | "Commands" | "Avatars" | "Items" | "Scenes"; +export type Days = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; export type Command = { name: string[]; @@ -113,13 +111,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"; } } diff --git a/src/handbook/src/ui/pages/ItemsPage.tsx b/src/handbook/src/ui/pages/ItemsPage.tsx index f8cdd3e47..a8a3397e5 100644 --- a/src/handbook/src/ui/pages/ItemsPage.tsx +++ b/src/handbook/src/ui/pages/ItemsPage.tsx @@ -97,9 +97,10 @@ class ItemsPage extends React.Component<{}, IState> { * @private */ private async setSelectedItem(item: ItemType): Promise { - 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,15 @@ class ItemsPage extends React.Component<{}, IState> { itemsPerRow={18} gap={5} itemGap={5} - render={(item) => this.setSelectedItem(item)} - />} + render={(item) => ( + this.setSelectedItem(item)} /> + )} /> ) : undefined}
- +
); diff --git a/src/handbook/src/ui/pages/ScenesPage.tsx b/src/handbook/src/ui/pages/ScenesPage.tsx index f5a1c581f..4d8686128 100644 --- a/src/handbook/src/ui/pages/ScenesPage.tsx +++ b/src/handbook/src/ui/pages/ScenesPage.tsx @@ -14,14 +14,22 @@ import "@css/pages/ScenesPage.scss"; */ function sceneTypeToString(type: SceneType): string { switch (type) { - default: return "Unknown"; - case SceneType.None: return "None"; - case SceneType.World: return "World"; - case SceneType.Activity: return "Activity"; - case SceneType.Dungeon: return "Dungeon"; - case SceneType.Room: return "Room"; - case SceneType.HomeRoom: return "Home Room"; - case SceneType.HomeWorld: return "Home World"; + default: + return "Unknown"; + case SceneType.None: + return "None"; + case SceneType.World: + return "World"; + case SceneType.Activity: + 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} title={command.identifier} alternate={`ID: ${command.id} | ${sceneTypeToString(command.type)}`} - button={( - - )} rightOffset={13} + button={ + + } + rightOffset={13} height={75} /> ))} diff --git a/src/handbook/src/ui/views/SideBar.tsx b/src/handbook/src/ui/views/SideBar.tsx index 712a2a2dd..64f314b1c 100644 --- a/src/handbook/src/ui/views/SideBar.tsx +++ b/src/handbook/src/ui/views/SideBar.tsx @@ -40,12 +40,14 @@ class SideBar extends React.Component<{}, IState> { The Ultimate Anime Game Handbook -
+
diff --git a/src/handbook/src/ui/widgets/Card.tsx b/src/handbook/src/ui/widgets/Card.tsx index b8c93acf4..c8308bbcd 100644 --- a/src/handbook/src/ui/widgets/Card.tsx +++ b/src/handbook/src/ui/widgets/Card.tsx @@ -52,9 +52,7 @@ class Card extends React.PureComponent {
{this.props.button ? ( -
+
{this.props.button}
) : undefined} diff --git a/src/handbook/src/ui/widgets/Item.tsx b/src/handbook/src/ui/widgets/Item.tsx index 81ebbea05..94a6b5d3f 100644 --- a/src/handbook/src/ui/widgets/Item.tsx +++ b/src/handbook/src/ui/widgets/Item.tsx @@ -52,9 +52,7 @@ class Item extends React.Component { render() { return ( -
+
{this.state.icon && ( { - return

{line}

; - }); + return description.split("\\n").map((line, index) => { + return

{line}

; + }); } interface IProps { @@ -65,8 +64,7 @@ class ItemCard extends React.Component { 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; @@ -105,49 +103,57 @@ class ItemCard extends React.Component {

{data?.type ?? itemTypeToString(item.type)}

- { this.state.icon && {item.name} this.setState({ icon: false })} - /> } + {this.state.icon && ( + {item.name} this.setState({ icon: false })} + /> + )}
-
- {toDescription(data?.description)} -
+
{toDescription(data?.description)}
-
this.addCount(false, false)} - onContextMenu={(e) => { - e.preventDefault(); - this.addCount(false, true); - }} - className={"ItemCard_Operation"}>-
- { - if (this.state.count == "") { - this.setState({ count: 1 }); - } - }} +
this.addCount(false, false)} + onContextMenu={(e) => { + e.preventDefault(); + this.addCount(false, true); + }} + className={"ItemCard_Operation"} + > + - +
+ { + if (this.state.count == "") { + this.setState({ count: 1 }); + } + }} /> -
this.addCount(true, false)} - onContextMenu={(e) => { - e.preventDefault(); - this.addCount(true, true); - }} - className={"ItemCard_Operation"}>+
+
this.addCount(true, false)} + onContextMenu={(e) => { + e.preventDefault(); + this.addCount(true, true); + }} + className={"ItemCard_Operation"} + > + + +
- +
) : undefined;