diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 8e11b07..8c0c521 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -65,33 +65,20 @@ { 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" }, - ]; - // CHANNELS let isChannelsOpen = false; function clickChannels() { isChannelsOpen = true; } let channels: Array = [ - { name: "My Imaginary Friends", id: "1" }, - { name: "Chamber of Secrets", id: "4" }, - { name: "Meme Team", id: "6" }, - { name: "Chat 8", id: "8" }, - { name: "F.R.I.E.N.D.S.", id: "2" }, - { name: "Chat 3", id: "3" }, + { id: "1", name: "General", messages: [] }, + { id: "2", name: "Lobby", messages: [] }, + { id: "3", name: "Game", messages: [] }, ]; + let selectedChannel: ChannelsType; + const handleSelectChannel = (channel: ChannelsType) => { + selectedChannel = channel; + };
@@ -100,31 +87,29 @@ {clickHistory} {clickFriends} {clickSpectate} - {clickChat} - {clickChannels} + {clickChannels} /> - {#if isChatOpen} -
(isChatOpen = false)} - on:keydown={() => (isChatOpen = false)} - > - -
- {/if} {#if isChannelsOpen} -
(isChannelsOpen = false)} - on:keydown={() => (isChannelsOpen = false)} - > - -
-{/if} + {#if selectedChannel} +
(selectedChannel = undefined)} on:keydown={() => (selectedChannel = undefined)}> + +
+ {/if} + {#if !selectedChannel} +
(isChannelsOpen = false)} + on:keydown={() => (isChannelsOpen = false)} + > + +
+ {/if} + {/if} {#if isSpectateOpen}
(isSpectateOpen = false)} on:keydown={() => (isSpectateOpen = false)} > - +
{/if} {#if isFriendOpen} @@ -132,7 +117,7 @@ on:click={() => (isFriendOpen = false)} on:keydown={() => (isFriendOpen = false)} > - + {/if} {#if isHistoryOpen} @@ -140,7 +125,7 @@ on:click={() => (isHistoryOpen = false)} on:keydown={() => (isHistoryOpen = false)} > - + {/if} {#if isProfileOpen} @@ -148,14 +133,14 @@ on:click={() => (isProfileOpen = false)} on:keydown={() => (isProfileOpen = false)} > - + {/if} diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index b42a788..9de639a 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -1,52 +1,73 @@ - + - + export let onSelectChannel: (channel: ChannelsType) => void; + const selectChat = (id: string) => { + const channel = channels.find(c => c.id === id); + if (channel) { + onSelectChannel(channel); + } + } + const createChannel = () => { + const name = prompt("Enter a name for the new channel:"); + if (name) { + const newChannel: ChannelsType = { + id: Math.random().toString(), + name, + messages: [] + }; + channels = [newChannel, ...channels]; + } + // TODO: save to database + }; + -
+
-
+
{#if channels.length > 0} -

Channels

- {#each channels.slice(0, 10) as _channels} +

Channels

+ {#each channels.slice(0, 10) as _channels}
  • - {_channels.name} - + {_channels.name} +
  • - {/each} + {/each} {:else} -

    No channels available

    +

    No channels available

    {/if} -
    + +
    -
    +
    - + diff --git a/front/volume/src/components/Chat2.svelte b/front/volume/src/components/Chat2.svelte index 12aec41..0a35519 100644 --- a/front/volume/src/components/Chat2.svelte +++ b/front/volume/src/components/Chat2.svelte @@ -1,23 +1,41 @@ +
    diff --git a/front/volume/src/components/NavBar.svelte b/front/volume/src/components/NavBar.svelte index dd67fc4..095b760 100644 --- a/front/volume/src/components/NavBar.svelte +++ b/front/volume/src/components/NavBar.svelte @@ -2,8 +2,7 @@ export let links = [ { text: "Home", url: "img/pong.png" }, { text: "Spectate" }, - { text: "Channels" }, - { text: "Chat" }, + { text: "Channels" }, { text: "History" }, { text: "Friends" }, { text: "Profile" }, @@ -33,13 +32,6 @@ {/if} - {#if link.text === "Chat"} -
  • - -
  • - {/if} {#if link.text === "Friends"}