From cf9f96970e053b581428512080b18be64d145d89 Mon Sep 17 00:00:00 2001 From: WalidMoovin Date: Mon, 27 Feb 2023 18:21:01 +0100 Subject: [PATCH] simplified version of chat, easier to work with and responsive, fixed some bugs --- front/volume/src/App.svelte | 38 +++++- front/volume/src/components/Chat.svelte | 123 -------------------- front/volume/src/components/Chat2.svelte | 68 +++++++++++ front/volume/src/components/NavBar.svelte | 8 ++ front/volume/src/components/Play.svelte | 12 -- front/volume/src/components/Spectate.svelte | 2 +- 6 files changed, 112 insertions(+), 139 deletions(-) delete mode 100644 front/volume/src/components/Chat.svelte create mode 100644 front/volume/src/components/Chat2.svelte diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index fa119e7..e670ec4 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -9,12 +9,18 @@ import type { SpectateType } from "./components/Spectate.svelte"; import Play from "./components/Play.svelte"; import Pong from "./components/Pong/Pong.svelte"; - import Chat from "./components/Chat.svelte"; + import Chat2 from "./components/Chat2.svelte"; + import type { chatMessagesType } from "./components/Chat2.svelte"; + + // PROFILE let isProfileOpen = false; function clickProfile() { isProfileOpen = true; } + + // HISTORY + let isHistoryOpen = false; function clickHistory() { isHistoryOpen = true; @@ -27,6 +33,9 @@ { winner: "Alice", loser: "Bob", points: 10, rank: "24" }, { winner: "Alice", loser: "Bob", points: 10, rank: "24" }, ]; + + // FRIENDS + let isFriendOpen = false; function clickFriends() { isFriendOpen = true; @@ -39,6 +48,8 @@ { username: "Eve", status: "in a game" }, { username: "Frank", status: "online" }, ]; + + // SPECTATE let isSpectateOpen = false; function clickSpectate() { isSpectateOpen = true; @@ -51,10 +62,32 @@ { player1: "Alice", player2: "Bob", id: "2" }, { player1: "Alice", player2: "Bob", id: "3" }, ]; + + // CHAT + let isChatOpen = false; + function clickChat() { + isChatOpen = true; + } + let chatMessages: Array = [ + { name: "Alice", text: "Bob" }, + { name: "Alice", text: "Bob" }, + { name: "Alice", text: "Bob" }, + { name: "Alice", text: "Bob" }, + { name: "Alice", text: "Bob" }, + { name: "Alice", text: "Bob" }, + ];
- + + {#if isChatOpen} +
(isChatOpen = false)} + on:keydown={() => (isChatOpen = false)} + > + +
+ {/if} {#if isSpectateOpen}
(isSpectateOpen = false)} @@ -96,7 +129,6 @@ {/if} -
diff --git a/front/volume/src/components/Chat2.svelte b/front/volume/src/components/Chat2.svelte new file mode 100644 index 0000000..0abfac7 --- /dev/null +++ b/front/volume/src/components/Chat2.svelte @@ -0,0 +1,68 @@ + + + + +
+
+
+ {#each chatMessages as message} +

+ + {message.name} + : {message.text} +

+ {/each} +
+
+ + +
+
+
+ + diff --git a/front/volume/src/components/NavBar.svelte b/front/volume/src/components/NavBar.svelte index 9604f56..95e61ec 100644 --- a/front/volume/src/components/NavBar.svelte +++ b/front/volume/src/components/NavBar.svelte @@ -11,6 +11,7 @@ export let clickHistory = () => {}; export let clickFriends = () => {}; export let clickSpectate = () => {}; + export let clickChat = () => {};