2023-10-08 15:34:37 +01:00
|
|
|
<script lang="ts">
|
2023-10-15 04:38:37 +00:00
|
|
|
import { onMount } from 'svelte';
|
2021-07-18 19:12:39 +03:00
|
|
|
import hotkeys from 'hotkeys-js';
|
2023-10-15 04:38:37 +00:00
|
|
|
import { fade } from 'svelte/transition';
|
2023-08-02 19:35:27 +01:00
|
|
|
import SendAlt from 'carbon-icons-svelte/lib/SendAlt.svelte';
|
|
|
|
|
import ChartPie from 'carbon-icons-svelte/lib/ChartPie.svelte';
|
|
|
|
|
import IconButton from '$lib/components/IconButton/index.svelte';
|
2023-09-14 20:59:51 +00:00
|
|
|
import Settings from 'carbon-icons-svelte/lib/Settings.svelte';
|
|
|
|
|
import { apps } from './store';
|
2021-05-29 20:47:46 +03:00
|
|
|
|
2023-10-08 15:34:37 +01:00
|
|
|
import Chip from '$lib/components/Chip/index.svelte';
|
2021-07-18 19:12:39 +03:00
|
|
|
import QandA from './components/QandA/index.svelte';
|
2023-10-08 15:34:37 +01:00
|
|
|
import Comments from './components/Comments/index.svelte';
|
2021-07-18 19:12:39 +03:00
|
|
|
import Notes from './components/Notes/index.svelte';
|
|
|
|
|
import Poll from './components/Poll/index.svelte';
|
|
|
|
|
import APPS_CONSTANTS from './constants';
|
2023-10-03 14:51:02 +00:00
|
|
|
import { browser } from '$app/environment';
|
2023-10-08 15:34:37 +01:00
|
|
|
import { lesson } from '$lib/components/Course/components/Lesson/store/lessons';
|
2021-05-29 20:47:46 +03:00
|
|
|
|
2023-10-08 15:34:37 +01:00
|
|
|
let appBarRef: HTMLDivElement;
|
|
|
|
|
let appContentRef: HTMLDivElement;
|
2023-10-06 12:49:40 +00:00
|
|
|
let topPadding = $apps.isStudent ? '48px' : '109px';
|
|
|
|
|
|
2023-10-04 08:18:33 +01:00
|
|
|
const getResizableSidebar = () => {
|
|
|
|
|
if (!browser) return;
|
|
|
|
|
|
|
|
|
|
return window.innerWidth >= 1024;
|
|
|
|
|
};
|
2021-05-29 20:47:46 +03:00
|
|
|
|
|
|
|
|
function handleClose() {
|
2023-10-08 15:34:37 +01:00
|
|
|
$apps.selectedApp = undefined;
|
2023-10-15 04:38:37 +00:00
|
|
|
if ($apps.isStudent) {
|
2023-10-06 12:49:40 +00:00
|
|
|
$apps.open = false;
|
2023-10-03 14:51:02 +00:00
|
|
|
}
|
2021-05-29 20:47:46 +03:00
|
|
|
}
|
|
|
|
|
|
2023-10-08 15:34:37 +01:00
|
|
|
function handleAppClick(appName?: string) {
|
2023-10-06 12:49:40 +00:00
|
|
|
if (appName === $apps.selectedApp) {
|
2021-05-29 20:47:46 +03:00
|
|
|
handleClose();
|
|
|
|
|
} else {
|
2023-10-06 12:49:40 +00:00
|
|
|
$apps.selectedApp = appName;
|
2021-05-29 20:47:46 +03:00
|
|
|
}
|
2023-11-01 09:45:40 +00:00
|
|
|
$apps.dropdown = !$apps.dropdown;
|
2021-05-29 20:47:46 +03:00
|
|
|
}
|
2023-10-03 14:51:02 +00:00
|
|
|
|
2023-10-08 15:34:37 +01:00
|
|
|
function updateTopPadding(isStudent: boolean) {
|
2023-10-06 12:49:40 +00:00
|
|
|
topPadding = isStudent ? '48px' : '109px';
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-15 04:38:37 +00:00
|
|
|
function getAppClass(appName: string, selected: string | undefined) {
|
|
|
|
|
return `transition duration-500 delay-150 ease-in-out border-t-0 border-b-0 border-r-0 ${
|
|
|
|
|
appName === selected ? 'border-l-4 border-indigo-600 focus:border-indigo-600' : 'border-l-0'
|
|
|
|
|
}`;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 11:28:46 +03:00
|
|
|
onMount(() => {
|
2023-10-06 12:49:40 +00:00
|
|
|
updateTopPadding($apps.isStudent);
|
2023-10-15 04:38:37 +00:00
|
|
|
|
|
|
|
|
hotkeys('A+1,A+2', function (event, handler) {
|
2021-05-31 11:28:46 +03:00
|
|
|
event.preventDefault();
|
|
|
|
|
switch (handler.key) {
|
2021-07-18 19:12:39 +03:00
|
|
|
case 'A+1':
|
2023-10-08 15:34:37 +01:00
|
|
|
handleAppClick(APPS_CONSTANTS.APPS.COMMENTS);
|
2021-05-31 11:28:46 +03:00
|
|
|
break;
|
2021-07-18 19:12:39 +03:00
|
|
|
case 'A+2':
|
2021-05-31 11:28:46 +03:00
|
|
|
handleAppClick(APPS_CONSTANTS.APPS.POLL);
|
|
|
|
|
break;
|
2023-10-15 04:38:37 +00:00
|
|
|
// case 'A+3':
|
|
|
|
|
// handleAppClick(APPS_CONSTANTS.APPS.NOTES);
|
|
|
|
|
// break;
|
|
|
|
|
// case 'A+4':
|
|
|
|
|
// handleAppClick(APPS_CONSTANTS.APPS.QANDA);
|
|
|
|
|
// break;
|
2021-05-31 11:28:46 +03:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-10-03 14:51:02 +00:00
|
|
|
|
2023-10-06 12:49:40 +00:00
|
|
|
$: updateTopPadding($apps.isStudent);
|
2023-10-04 08:18:33 +01:00
|
|
|
$: getResizableSidebar();
|
2021-05-22 22:25:33 +03:00
|
|
|
</script>
|
|
|
|
|
|
2023-10-03 14:51:02 +00:00
|
|
|
<div
|
2023-10-06 12:49:40 +00:00
|
|
|
style={`--top-padding:${topPadding}`}
|
2023-10-08 15:34:37 +01:00
|
|
|
class={`${$apps.open ? 'open ' : 'close'} root bg-white dark:bg-black`}
|
2023-10-03 14:51:02 +00:00
|
|
|
bind:this={appBarRef}
|
|
|
|
|
>
|
2023-10-04 08:18:33 +01:00
|
|
|
<div class="apps">
|
2023-10-08 15:34:37 +01:00
|
|
|
<div class="lg:hidden mb-2">
|
2023-09-14 20:59:51 +00:00
|
|
|
<IconButton
|
|
|
|
|
buttonClassName="lg:hidden"
|
|
|
|
|
toolTipProps={{ title: 'Settings', hotkeys: ['A', '0'] }}
|
|
|
|
|
onClick={() => {
|
2023-10-04 08:18:33 +01:00
|
|
|
handleAppClick();
|
2023-09-14 20:59:51 +00:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Settings size={24} class="carbon-icon dark:text-white lg:hidden" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-10-15 04:38:37 +00:00
|
|
|
<div class="mb-2 relative {getAppClass(APPS_CONSTANTS.APPS.COMMENTS, $apps.selectedApp)}">
|
2023-10-08 15:34:37 +01:00
|
|
|
<IconButton
|
|
|
|
|
toolTipProps={{ title: 'Comments', hotkeys: ['A', '1'] }}
|
|
|
|
|
value={APPS_CONSTANTS.APPS.COMMENTS}
|
|
|
|
|
onClick={handleAppClick}
|
|
|
|
|
buttonClassName="relative"
|
|
|
|
|
>
|
2023-10-15 04:38:37 +00:00
|
|
|
<Chip
|
|
|
|
|
value={$lesson.totalComments}
|
|
|
|
|
className="absolute -top-1 right-0 bg-primary-600 text-white"
|
|
|
|
|
/>
|
2023-10-08 15:34:37 +01:00
|
|
|
<SendAlt size={24} class="carbon-icon dark:text-white" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
2023-10-15 04:38:37 +00:00
|
|
|
<div class="mb-2 {getAppClass(APPS_CONSTANTS.APPS.POLL, $apps.selectedApp)}">
|
|
|
|
|
<IconButton
|
|
|
|
|
toolTipProps={{ title: 'Poll', hotkeys: ['A', '2'] }}
|
|
|
|
|
value={APPS_CONSTANTS.APPS.POLL}
|
|
|
|
|
onClick={handleAppClick}
|
|
|
|
|
>
|
|
|
|
|
<ChartPie size={24} class="carbon-icon dark:text-white" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
2023-10-08 18:14:13 +01:00
|
|
|
<!-- <div class="mb-2">
|
2023-10-08 15:34:37 +01:00
|
|
|
<IconButton
|
2023-10-15 04:38:37 +00:00
|
|
|
toolTipProps={{ title: 'QandA', hotkeys: ['A', '3'] }}
|
2023-10-08 15:34:37 +01:00
|
|
|
value={APPS_CONSTANTS.APPS.QANDA}
|
|
|
|
|
onClick={handleAppClick}
|
|
|
|
|
contained={APPS_CONSTANTS.APPS.QANDA === $apps.selectedApp}
|
|
|
|
|
>
|
|
|
|
|
<Forum size={24} class="carbon-icon dark:text-white" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-2">
|
|
|
|
|
<IconButton
|
|
|
|
|
toolTipProps={{ title: 'Notes', hotkeys: ['A', '3'] }}
|
|
|
|
|
value={APPS_CONSTANTS.APPS.NOTES}
|
|
|
|
|
onClick={handleAppClick}
|
|
|
|
|
contained={APPS_CONSTANTS.APPS.NOTES === $apps.selectedApp}
|
|
|
|
|
>
|
|
|
|
|
<AlignBoxTopLeft size={24} class="carbon-icon dark:text-white" />
|
|
|
|
|
</IconButton>
|
2023-10-08 18:14:13 +01:00
|
|
|
</div> -->
|
2021-05-31 11:28:46 +03:00
|
|
|
</div>
|
|
|
|
|
|
2023-10-06 12:49:40 +00:00
|
|
|
{#if !!$apps.selectedApp}
|
2023-10-03 14:51:02 +00:00
|
|
|
<div
|
2023-10-21 07:44:57 +00:00
|
|
|
class="app max-w-[350px] transition ease-in-out delay-150 duration-100"
|
2023-10-03 14:51:02 +00:00
|
|
|
bind:this={appContentRef}
|
|
|
|
|
>
|
2023-10-15 04:38:37 +00:00
|
|
|
{#key $apps.selectedApp}
|
|
|
|
|
<div class="h-full w-full" transition:fade={{ duration: 200 }}>
|
|
|
|
|
{#if $apps.selectedApp === APPS_CONSTANTS.APPS.QANDA}
|
|
|
|
|
<QandA {handleClose} />
|
|
|
|
|
{:else if $apps.selectedApp === APPS_CONSTANTS.APPS.COMMENTS}
|
|
|
|
|
<Comments {handleClose} />
|
|
|
|
|
{:else if $apps.selectedApp === APPS_CONSTANTS.APPS.POLL}
|
|
|
|
|
<Poll {handleClose} />
|
|
|
|
|
{:else if $apps.selectedApp === APPS_CONSTANTS.APPS.NOTES}
|
|
|
|
|
<Notes {handleClose} />
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/key}
|
2021-05-31 11:28:46 +03:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2021-06-26 21:32:42 +03:00
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.root {
|
2023-09-14 20:59:51 +00:00
|
|
|
height: calc(100vh - 48px);
|
2021-06-26 21:32:42 +03:00
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
border-left: 1px solid var(--border-color);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
|
|
|
|
& .apps {
|
|
|
|
|
padding-top: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 60px;
|
|
|
|
|
border-right: 1px solid var(--border-color);
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& .app {
|
2023-10-03 14:51:02 +00:00
|
|
|
width: 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
|
|
|
|
.app {
|
2023-11-01 09:45:40 +00:00
|
|
|
width: 50vw;
|
2023-10-03 14:51:02 +00:00
|
|
|
position: relative;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 767px) {
|
|
|
|
|
.app {
|
2023-11-01 09:45:40 +00:00
|
|
|
width: 100vw;
|
|
|
|
|
min-width: calc(100vw - 60px);
|
2021-06-26 21:32:42 +03:00
|
|
|
position: relative;
|
2021-07-05 10:52:20 +00:00
|
|
|
overflow: auto;
|
2021-06-26 21:32:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-09-14 20:59:51 +00:00
|
|
|
|
2023-09-24 13:20:04 +00:00
|
|
|
@media screen and (max-width: 1023px) {
|
2023-09-14 20:59:51 +00:00
|
|
|
.root {
|
|
|
|
|
position: absolute;
|
2023-10-06 12:49:40 +00:00
|
|
|
height: calc(100vh - var(--top-padding));
|
|
|
|
|
top: var(--top-padding);
|
2023-09-14 20:59:51 +00:00
|
|
|
right: 0;
|
|
|
|
|
z-index: 999;
|
|
|
|
|
}
|
|
|
|
|
.open {
|
|
|
|
|
position: absolute;
|
|
|
|
|
transform: translateX(0);
|
2023-10-06 12:49:40 +00:00
|
|
|
|
2023-09-14 20:59:51 +00:00
|
|
|
transition: all 0.2s ease-in-out;
|
|
|
|
|
}
|
|
|
|
|
.close {
|
|
|
|
|
position: absolute;
|
|
|
|
|
transform: translateX(100%);
|
|
|
|
|
display: none;
|
|
|
|
|
transition: all 0.2s ease-in-out;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-24 13:20:04 +00:00
|
|
|
|
|
|
|
|
@media screen and (min-width: 1024px) {
|
|
|
|
|
.root {
|
|
|
|
|
height: calc(100vh - 48px);
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
border-left: 1px solid var(--border-color);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
|
|
|
|
& .apps {
|
|
|
|
|
padding-top: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 60px;
|
|
|
|
|
border-right: 1px solid var(--border-color);
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& .app {
|
2023-10-03 14:51:02 +00:00
|
|
|
width: 100%;
|
2023-09-24 13:20:04 +00:00
|
|
|
position: relative;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 21:32:42 +03:00
|
|
|
</style>
|