2022-04-16 04:17:48 +03:00
|
|
|
<script>
|
2022-04-26 03:01:21 +03:00
|
|
|
import { HashIcon, PlusIcon, MoreVerticalIcon } from "svelte-feather-icons";
|
2022-04-27 17:03:35 +03:00
|
|
|
import { quadInOut } from "svelte/easing";
|
|
|
|
import { fly } from "svelte/transition";
|
|
|
|
import { channels, overlayStore, selectedChannel, showChannelView, showSidebar, smallViewport } from "../stores";
|
2022-04-23 03:38:19 +03:00
|
|
|
import UserTopBar from "./UserTopBar.svelte";
|
2022-04-27 17:03:35 +03:00
|
|
|
|
|
|
|
let pendingSelectChannel = null;
|
|
|
|
|
|
|
|
const selectChannel = (channel) => $selectedChannel = channel;
|
|
|
|
|
|
|
|
// janky code to hide the channel view during animation
|
|
|
|
// this will make a smooth sidebar animation on smaller viewports (such as a phone, where you switch between sidebar being active)
|
|
|
|
|
|
|
|
const scheduleSelectChannel = (channel) => {
|
|
|
|
if ($smallViewport) {
|
|
|
|
$showChannelView = false;
|
|
|
|
pendingSelectChannel = channel;
|
|
|
|
$showSidebar = false;
|
|
|
|
} else {
|
|
|
|
selectChannel(channel);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const outroEnd = () => {
|
|
|
|
if (pendingSelectChannel) {
|
|
|
|
selectChannel(pendingSelectChannel);
|
|
|
|
pendingSelectChannel = null;
|
|
|
|
$showChannelView = true;
|
|
|
|
}
|
|
|
|
};
|
2022-04-16 04:17:48 +03:00
|
|
|
</script>
|
|
|
|
|
2022-04-27 17:03:35 +03:00
|
|
|
<div class="sidebar-container" transition:fly="{{ duration: 200, easing: quadInOut, x: -10 }}" on:outroend="{ outroEnd }">
|
2022-04-23 03:38:19 +03:00
|
|
|
<UserTopBar />
|
|
|
|
<div class="sidebar">
|
|
|
|
{#each $channels as channel (channel.id)}
|
2022-04-27 17:03:35 +03:00
|
|
|
<button on:click="{ scheduleSelectChannel(channel) }" class="sidebar-button" class:selected={ channel.id === $selectedChannel.id }>
|
2022-04-23 03:38:19 +03:00
|
|
|
<div>
|
|
|
|
<HashIcon />
|
|
|
|
</div>
|
|
|
|
<span>{ channel.name }</span>
|
2022-04-27 05:03:47 +03:00
|
|
|
<button class="icon-button icon-button-auto" on:click|stopPropagation="{ () => overlayStore.open('editChannel', { channel }) }">
|
2022-04-26 03:01:21 +03:00
|
|
|
<MoreVerticalIcon />
|
|
|
|
</button>
|
2022-04-23 03:38:19 +03:00
|
|
|
</button>
|
|
|
|
{/each}
|
2022-04-25 18:47:27 +03:00
|
|
|
<button on:click="{ () => overlayStore.open('createChannel') }" class="sidebar-button">
|
|
|
|
<div>
|
|
|
|
<PlusIcon />
|
|
|
|
</div>
|
|
|
|
<span>Create Channel</span>
|
|
|
|
</button>
|
2022-04-23 03:38:19 +03:00
|
|
|
</div>
|
2022-04-17 04:08:40 +03:00
|
|
|
</div>
|
|
|
|
|
2022-04-15 02:39:13 +03:00
|
|
|
<style>
|
2022-04-23 03:38:19 +03:00
|
|
|
.sidebar-container {
|
|
|
|
background-color: var(--background-color-1);
|
|
|
|
border-right: 1px solid var(--background-color-2);
|
2022-04-15 02:39:13 +03:00
|
|
|
height: 100%;
|
2022-04-27 05:03:47 +03:00
|
|
|
min-width: 255px;
|
2022-04-17 04:08:40 +03:00
|
|
|
max-width: 255px;
|
2022-04-23 03:38:19 +03:00
|
|
|
}
|
|
|
|
|
2022-04-27 05:03:47 +03:00
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
.sidebar-container {
|
|
|
|
flex-basis: 100%;
|
|
|
|
min-width: unset;
|
|
|
|
max-width: unset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-23 03:38:19 +03:00
|
|
|
.sidebar {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
padding: var(--space-xs);
|
2022-04-16 04:17:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
.sidebar-button {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2022-04-17 04:08:40 +03:00
|
|
|
justify-content: left;
|
2022-04-16 04:17:48 +03:00
|
|
|
border: none;
|
|
|
|
background-color: var(--background-color-1);
|
2022-04-23 03:38:19 +03:00
|
|
|
padding: var(--space-xs);
|
2022-04-16 04:17:48 +03:00
|
|
|
margin-bottom: var(--space-xxs);
|
|
|
|
color: currentColor;
|
|
|
|
font: inherit;
|
|
|
|
border-radius: var(--radius-md);
|
2022-04-17 04:08:40 +03:00
|
|
|
width: 100%;
|
2022-04-23 03:38:19 +03:00
|
|
|
max-height: 3.4em;
|
2022-04-16 04:17:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
.sidebar-button span {
|
|
|
|
margin-left: var(--space-xxs);
|
2022-04-17 04:08:40 +03:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidebar-button div {
|
|
|
|
display: inline;
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
|
|
/* TODO: HACK! */
|
|
|
|
width: 24px;
|
|
|
|
height: 24px;
|
2022-04-16 04:17:48 +03:00
|
|
|
}
|
|
|
|
|
2022-04-26 03:01:21 +03:00
|
|
|
.sidebar-button .icon-button {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
2022-04-27 20:13:14 +03:00
|
|
|
.sidebar-button.selected .icon-button,
|
2022-04-26 03:01:21 +03:00
|
|
|
.sidebar-button:hover .icon-button {
|
|
|
|
visibility: visible;
|
|
|
|
}
|
|
|
|
|
2022-04-17 20:50:04 +03:00
|
|
|
.sidebar-button.selected,
|
2022-04-16 04:17:48 +03:00
|
|
|
.sidebar-button:hover {
|
|
|
|
background-color: var(--background-color-2);
|
2022-04-15 02:39:13 +03:00
|
|
|
}
|
|
|
|
</style>
|