frontend: start working on "create channel" modal
This commit is contained in:
parent
6c3d6a09fb
commit
b1ff452732
7 changed files with 85 additions and 4 deletions
42
frontend/src/components/modals/CreateChannel.svelte
Normal file
42
frontend/src/components/modals/CreateChannel.svelte
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<script>
|
||||||
|
import { fade, fly } from "svelte/transition";
|
||||||
|
import { quintInOut } from "svelte/easing";
|
||||||
|
import { overlayStore } from "../../stores";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal-backdrop {
|
||||||
|
position: absolute;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 0;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: var(--space-xxs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
min-width: 450px;
|
||||||
|
min-height: 370px;
|
||||||
|
background-color: var(--background-color-2);
|
||||||
|
padding: var(--space-md);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="modal-backdrop" transition:fade="{{ duration: 350, easing: quintInOut }}" on:click="{() => overlayStore.close('createChannel')}">
|
||||||
|
<div class="modal" transition:fly="{{ duration: 350, easing: quintInOut, y: 15 }}">
|
||||||
|
<span class="h2 modal-header">Create Channel</span>
|
||||||
|
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus earum blanditiis, numquam debitis inventore, fugit quidem ipsa, cum quibusdam accusamus repudiandae aut vitae necessitatibus. Libero, sit! Ex placeat illum iure!
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,7 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { CloudIcon } from "svelte-feather-icons";
|
import { CloudIcon } from "svelte-feather-icons";
|
||||||
import { gatewayStatus, selectedChannel } from "../../../stores";
|
import { gatewayStatus, selectedChannel } from "../../../stores";
|
||||||
|
import CreateChannel from "../../modals/CreateChannel.svelte";
|
||||||
import ChannelView from "./ChannelView.svelte";
|
import ChannelView from "./ChannelView.svelte";
|
||||||
|
import OverlayProvider from "./OverlayProvider.svelte";
|
||||||
import Sidebar from "./Sidebar.svelte";
|
import Sidebar from "./Sidebar.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -23,6 +25,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
|
<OverlayProvider />
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
{#if $selectedChannel.id === -1}
|
{#if $selectedChannel.id === -1}
|
||||||
<div class="fullscreen-message">
|
<div class="fullscreen-message">
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script>
|
||||||
|
import { overlayStore } from "../../../stores";
|
||||||
|
import CreateChannel from "../../modals/CreateChannel.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if $overlayStore.createChannel}
|
||||||
|
<CreateChannel />
|
||||||
|
{/if}
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { HashIcon } from "svelte-feather-icons";
|
import { HashIcon, PlusIcon } from "svelte-feather-icons";
|
||||||
import { channels, selectedChannel } from "../../../stores";
|
import { channels, overlayStore, selectedChannel } from "../../../stores";
|
||||||
import UserTopBar from "./UserTopBar.svelte";
|
import UserTopBar from "./UserTopBar.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -15,6 +15,12 @@
|
||||||
<span>{ channel.name }</span>
|
<span>{ channel.name }</span>
|
||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
|
<button on:click="{ () => overlayStore.open('createChannel') }" class="sidebar-button">
|
||||||
|
<div>
|
||||||
|
<PlusIcon />
|
||||||
|
</div>
|
||||||
|
<span>Create Channel</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const GatewayEventType = {
|
||||||
Close: -4
|
Close: -4
|
||||||
}
|
}
|
||||||
|
|
||||||
const log = logging.logger("Gateway");
|
const log = logging.logger("Gateway", true);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ws: null,
|
ws: null,
|
||||||
|
@ -38,8 +38,10 @@ export default {
|
||||||
init() {
|
init() {
|
||||||
const token = getAuthToken();
|
const token = getAuthToken();
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
log("no auth token, skipping connection");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
log(`connecting to gateway - gatewayBase: ${getItem("gatewayBase")}`);
|
||||||
this.ws = new WebSocket(getItem("gatewayBase"));
|
this.ws = new WebSocket(getItem("gatewayBase"));
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
if (this.reconnectTimeout) {
|
if (this.reconnectTimeout) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const defaults = {
|
const defaults = {
|
||||||
apiBase: `${window.location.origin}/api/v1`,
|
apiBase: `${window.location.origin}/api/v1`,
|
||||||
gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`
|
gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`,
|
||||||
|
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjUwODQzMjY1LCJleHAiOjE2NTEwMTYwNjV9.ssu-MlMkwKQOcP5nmJ98KbqudcGW5XBYPc_d6et4oxo"
|
||||||
};
|
};
|
||||||
|
|
||||||
const dummyProvider = {
|
const dummyProvider = {
|
||||||
|
|
|
@ -219,8 +219,27 @@ class MessagesStoreProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OverlayStore extends Store {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
createChannel: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
open(name) {
|
||||||
|
this.value[name] = true;
|
||||||
|
this.updated();
|
||||||
|
}
|
||||||
|
|
||||||
|
close(name) {
|
||||||
|
this.value[name] = false;
|
||||||
|
this.updated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const channels = new ChannelsStore();
|
export const channels = new ChannelsStore();
|
||||||
export const gatewayStatus = new GatewayStatusStore();
|
export const gatewayStatus = new GatewayStatusStore();
|
||||||
export const messagesStoreProvider = new MessagesStoreProvider();
|
export const messagesStoreProvider = new MessagesStoreProvider();
|
||||||
export const userInfoStore = new UserInfoStore();
|
export const userInfoStore = new UserInfoStore();
|
||||||
|
export const overlayStore = new OverlayStore();
|
||||||
export const selectedChannel = writable({ id: -1, name: "none", creator_id: -1 });
|
export const selectedChannel = writable({ id: -1, name: "none", creator_id: -1 });
|
||||||
|
|
Loading…
Reference in a new issue