From 127d45f21fa31ef1a8138abab837c8082e8d4b79 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sun, 9 Apr 2023 20:58:03 -0400 Subject: [PATCH] Implement the scenes page --- src/handbook/src/backend/types.ts | 5 +- src/handbook/src/css/pages/ScenesPage.scss | 44 +++++++++++++++ src/handbook/src/css/widgets/Card.scss | 16 +++++- src/handbook/src/ui/pages/HomePage.tsx | 2 +- src/handbook/src/ui/pages/ScenesPage.tsx | 62 ++++++++++++++++++++++ src/handbook/src/ui/views/Content.tsx | 3 ++ src/handbook/src/ui/views/SideBar.tsx | 2 +- src/handbook/src/ui/widgets/Card.tsx | 44 +++++++++------ 8 files changed, 157 insertions(+), 21 deletions(-) create mode 100644 src/handbook/src/css/pages/ScenesPage.scss create mode 100644 src/handbook/src/ui/pages/ScenesPage.tsx diff --git a/src/handbook/src/backend/types.ts b/src/handbook/src/backend/types.ts index cd56e935f..3470f4b98 100644 --- a/src/handbook/src/backend/types.ts +++ b/src/handbook/src/backend/types.ts @@ -1,4 +1,5 @@ -export type Page = "Home" | "Commands" | "Avatars" | "Items"; +export type Page = "Home" | "Commands" | "Avatars" | "Items" + | "Scenes"; export type Days = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday"; @@ -18,7 +19,7 @@ export type Avatar = { export type Scene = { identifier: string; - type: string; + type: SceneType; id: number; }; diff --git a/src/handbook/src/css/pages/ScenesPage.scss b/src/handbook/src/css/pages/ScenesPage.scss new file mode 100644 index 000000000..8762741d4 --- /dev/null +++ b/src/handbook/src/css/pages/ScenesPage.scss @@ -0,0 +1,44 @@ +.ScenesPage { + display: flex; + height: 100%; + width: 100%; + + background-color: var(--background-color); + flex-direction: column; + + padding: 24px; +} + +.ScenesPage_Title { + max-width: 180px; + max-height: 60px; + + font-size: 48px; + font-weight: bold; + text-align: center; + + margin-bottom: 30px; +} + +.ScenesPage_List { + display: flex; + flex-direction: column; + + gap: 15px; + margin-bottom: 28px; + overflow-y: scroll; +} + +.ScenesPage_Button { + width: 94px; + height: 34px; + + margin: 0; + border-radius: 10px; + border: transparent; + + font-size: 20px; + + color: var(--text-primary-color); + background-color: var(--background-color); +} diff --git a/src/handbook/src/css/widgets/Card.scss b/src/handbook/src/css/widgets/Card.scss index 7f2fae1f1..538b55f05 100644 --- a/src/handbook/src/css/widgets/Card.scss +++ b/src/handbook/src/css/widgets/Card.scss @@ -1,6 +1,6 @@ .Card { display: flex; - flex-direction: column; + flex-direction: row; justify-content: space-between; width: 100%; @@ -14,6 +14,12 @@ background-color: var(--secondary-color); } +.Card_Content { + display: flex; + flex-direction: column; + justify-content: space-between; +} + .Card_Header { display: flex; flex-direction: row; @@ -40,3 +46,11 @@ overflow-y: scroll; max-height: 24px; } + +.Card_Button { + display: flex; + margin-right: 13px; + + align-self: center; + justify-content: center; +} diff --git a/src/handbook/src/ui/pages/HomePage.tsx b/src/handbook/src/ui/pages/HomePage.tsx index 75d750659..c90ab526a 100644 --- a/src/handbook/src/ui/pages/HomePage.tsx +++ b/src/handbook/src/ui/pages/HomePage.tsx @@ -22,7 +22,7 @@ class HomePage extends React.Component { - +
diff --git a/src/handbook/src/ui/pages/ScenesPage.tsx b/src/handbook/src/ui/pages/ScenesPage.tsx new file mode 100644 index 000000000..f5a1c581f --- /dev/null +++ b/src/handbook/src/ui/pages/ScenesPage.tsx @@ -0,0 +1,62 @@ +import React from "react"; + +import Card from "@widgets/Card"; + +import { SceneType } from "@backend/types"; +import { getScenes } from "@backend/data"; + +import "@css/pages/ScenesPage.scss"; + +/** + * Converts a scene type to a string. + * + * @param type The scene type. + */ +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"; + } +} + +class ScenesPage extends React.PureComponent { + /** + * Teleports the player to the specified scene. + * @private + */ + private async teleport(): Promise { + // TODO: Implement teleporting. + } + + render() { + return ( +
+

Scenes

+ +
+ {getScenes().map((command) => ( + Teleport + )} rightOffset={13} + height={75} + /> + ))} +
+
+ ); + } +} + +export default ScenesPage; diff --git a/src/handbook/src/ui/views/Content.tsx b/src/handbook/src/ui/views/Content.tsx index 4d0f8b687..a30789d5a 100644 --- a/src/handbook/src/ui/views/Content.tsx +++ b/src/handbook/src/ui/views/Content.tsx @@ -4,6 +4,7 @@ import HomePage from "@pages/HomePage"; import CommandsPage from "@pages/CommandsPage"; import AvatarsPage from "@pages/AvatarsPage"; import ItemsPage from "@pages/ItemsPage"; +import ScenesPage from "@pages/ScenesPage"; import type { Page } from "@backend/types"; import { addNavListener, removeNavListener } from "@backend/events"; @@ -57,6 +58,8 @@ class Content extends React.Component { return ; case "Items": return ; + case "Scenes": + return ; } } } diff --git a/src/handbook/src/ui/views/SideBar.tsx b/src/handbook/src/ui/views/SideBar.tsx index 5d908b8bc..712a2a2dd 100644 --- a/src/handbook/src/ui/views/SideBar.tsx +++ b/src/handbook/src/ui/views/SideBar.tsx @@ -51,7 +51,7 @@ class SideBar extends React.Component<{}, IState> { - +
diff --git a/src/handbook/src/ui/widgets/Card.tsx b/src/handbook/src/ui/widgets/Card.tsx index 57f2505a6..b8c93acf4 100644 --- a/src/handbook/src/ui/widgets/Card.tsx +++ b/src/handbook/src/ui/widgets/Card.tsx @@ -8,6 +8,8 @@ interface IProps { description?: string | string[]; height?: number | string; + button?: React.ReactNode; + rightOffset?: number; onClick?: () => void; onOver?: () => void; @@ -28,24 +30,34 @@ class Card extends React.PureComponent { onMouseOut={this.props.onOut} style={{ height: this.props.height }} > -
-

{this.props.title}

- {this.props.alternate &&

{this.props.alternate}

} +
+
+

{this.props.title}

+ {this.props.alternate &&

{this.props.alternate}

} +
+ +
+ {this.props.description ? ( + Array.isArray(this.props.description) ? ( + this.props.description.map((line, index) => ( +

+ {line} +

+ )) + ) : ( +

{this.props.description}

+ ) + ) : undefined} +
-
- {this.props.description ? ( - Array.isArray(this.props.description) ? ( - this.props.description.map((line, index) => ( -

- {line} -

- )) - ) : ( -

{this.props.description}

- ) - ) : undefined} -
+ {this.props.button ? ( +
+ {this.props.button} +
+ ) : undefined}
); }