Skip to content

A self-hosted media server and file management system

feat: crude drawer system for mobile sidebars

aminnausin1323ae188172
diff --git a/resources/js/App.vue b/resources/js/App.vue
index 89d9d978..6ab58b14 100755
--- a/resources/js/App.vue
+++ b/resources/js/App.vue
@@ -2,6 +2,7 @@
import type { ToastPostion } from '@aminnausin/cedar-ui';
import { onMounted, onUnmounted, ref, watch } from 'vue';
+import { DrawerController } from './components/cedar-ui/drawer';
import { ToastController } from '@/components/cedar-ui/toast';
import { useFullscreen } from '@/composables/useFullscreen';
import { getScreenSize } from '@/service/util';
@@ -62,6 +63,7 @@ watch(usingPlayerModernUI, setPlayerModernUI, { immediate: false });
<template>
<RouterView />
<GlobalModal />
+ <DrawerController :teleportTarget="'body'" />
<ToastController v-if="toastPosition && !isFullscreen" :position="toastPosition" />
<ContextMenu
v-if="!isFullscreen"
diff --git a/resources/js/components/cedar-ui/drawer/BaseDrawer.vue b/resources/js/components/cedar-ui/drawer/BaseDrawer.vue
index 724ec463..16d8a1ee 100644
--- a/resources/js/components/cedar-ui/drawer/BaseDrawer.vue
+++ b/resources/js/components/cedar-ui/drawer/BaseDrawer.vue
@@ -13,16 +13,23 @@ const drawer = useDrawer();
const props = withDefaults(defineProps<DrawerProps>(), { direction: 'bottom' });
const swipeDirections = ref<SwipeDirection[]>([props.direction]);
+const closeDrawer = () => {
+ drawer.close();
+ emit('close');
+};
+
const { offset, isSwiping, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, isTapGesture } = useSwipeHandler({
directions: swipeDirections,
swipeThreshold: { px: SWIPE_THRESHOLD },
velocityThreshold: VELOCITY_THRESHOLD,
- onSwipeOut: drawer.close,
+ onSwipeOut: closeDrawer,
});
+
+const emit = defineEmits<(e: 'close') => void>();
</script>
<template>
<RootDrawer
- @keydown.esc="drawer.close"
+ @keydown.esc="closeDrawer"
@pointerdown="onPointerDown"
@pointermove="onPointerMove"
@pointerup="onPointerUp"
@@ -35,25 +42,29 @@ const { offset, isSwiping, onPointerDown, onPointerMove, onPointerUp, onPointerC
}"
id="drawer"
>
- <div class="flex flex-col items-center justify-center">
- <div class="group flex w-full cursor-pointer pt-4">
+ <div class="flex flex-col items-center justify-center gap-3 p-4 md:p-3">
+ <div class="group flex w-full cursor-pointer pb-1 sm:p-0">
<slot name="handle">
<DrawerHandle
:aria-expanded="drawer.isOpen.value"
@keydown.enter.prevent="drawer.close"
@keydown.space.prevent="drawer.close"
+ @pointerdown="onPointerDown"
+ @pointermove="onPointerMove"
+ @dragend="onPointerUp"
+ @pointercancel="onPointerCancel"
@pointerup="
() => {
onPointerUp();
- if (isTapGesture()) drawer.close();
+ if (isTapGesture()) closeDrawer();
}
"
/>
</slot>
</div>
- <div class="flex w-full flex-col gap-3 p-3">
+ <div class="flex w-full flex-col gap-3" v-if="$slots.header || drawer.props.value.title || drawer.props.value.description">
<slot name="header">
- <div class="flex w-full flex-col gap-1.5">
+ <div class="flex w-full flex-col gap-1.5" v-if="drawer.props.value.title || drawer.props.value.description">
<h2 id="drawerTitle" class="text-foreground flex-1 text-xl font-semibold">
<slot name="title">
{{ drawer.props.value.title ?? title ?? 'Title' }}
@@ -65,12 +76,12 @@ const { offset, isSwiping, onPointerDown, onPointerMove, onPointerUp, onPointerC
</div>
</slot>
</div>
- <div v-if="$slots.default" class="scrollbar-hide flex max-h-[60vh] w-full flex-col gap-3 overflow-y-scroll p-3">
+ <div v-if="$slots.default" class="scrollbar-hide flex max-h-[60vh] w-full flex-col gap-3 overflow-y-scroll">
<slot> </slot>
</div>
- <div v-if="$slots.footer || !$slots.default" class="flex w-full flex-col gap-3 p-3">
+ <div v-if="$slots.footer || !$slots.default" class="flex w-full flex-col gap-3">
<slot name="footer">
- <ButtonText :class="'h-8 w-full text-sm capitalize ring-1'" :variant="'default'" @click="drawer.close()"> Close Drawer </ButtonText>
+ <ButtonText :class="'h-8 w-full text-sm capitalize ring-1'" :variant="'default'" @click="closeDrawer"> Close Drawer </ButtonText>
</slot>
</div>
</div>
diff --git a/resources/js/components/cedar-ui/drawer/DrawerHandle.vue b/resources/js/components/cedar-ui/drawer/DrawerHandle.vue
index e2a22934..8eed36a9 100644
--- a/resources/js/components/cedar-ui/drawer/DrawerHandle.vue
+++ b/resources/js/components/cedar-ui/drawer/DrawerHandle.vue
@@ -2,7 +2,7 @@
<button
type="button"
title="Close Drawer"
- class="mx-auto w-1/8 sm:w-1/12 h-1.5 rounded-full bg-foreground-2 cursor-pointer group-hover:bg-foreground-1 transition-colors focus:outline-0 focus:bg-foreground-1"
+ class="bg-foreground-2 group-hover:bg-foreground-1 mx-auto h-1.5 w-1/5 cursor-pointer rounded-full transition-colors sm:w-1/12"
aria-controls="drawer"
></button>
</template>
diff --git a/resources/js/components/drawers/VideoSidebarDrawer.vue b/resources/js/components/drawers/VideoSidebarDrawer.vue
new file mode 100644
index 00000000..092e753d
--- /dev/null
+++ b/resources/js/components/drawers/VideoSidebarDrawer.vue
@@ -0,0 +1,14 @@
+<script setup lang="ts">
+import { useAppStore } from '@/stores/AppStore';
+import { BaseDrawer } from '@/components/cedar-ui/drawer';
+
+import VideoSidebar from '@/components/panels/VideoSidebar.vue';
+
+const { cycleSideBar } = useAppStore();
+</script>
+
+<template>
+ <BaseDrawer @close="cycleSideBar()">
+ <VideoSidebar />
+ </BaseDrawer>
+</template>
diff --git a/resources/js/components/panels/NavBar.vue b/resources/js/components/panels/NavBar.vue
index 9fa2c88f..05cbe854 100755
--- a/resources/js/components/panels/NavBar.vue
+++ b/resources/js/components/panels/NavBar.vue
@@ -1,9 +1,12 @@
<script setup lang="ts">
+import { getScreenSize } from '@/service/util';
import { useAuthStore } from '@/stores/AuthStore';
import { useAppStore } from '@/stores/AppStore';
import { storeToRefs } from 'pinia';
+import { drawer } from '@aminnausin/cedar-ui';
import { ref } from 'vue';
+import VideoSidebarDrawer from '@/components/drawers/VideoSidebarDrawer.vue';
import ToggleLightMode from '@/components/inputs/ToggleLightMode.vue';
import DropdownMenu from '@/components/pinesUI/DropdownMenu.vue';
import NavButton from '@/components/inputs/NavButton.vue';
@@ -24,6 +27,16 @@ const { cycleSideBar } = useAppStore();
const toggleDropdown = () => {
showDropdown.value = !showDropdown.value;
};
+
+const toggleVideoSidebar = (sidebar: 'folders' | 'history') => {
+ cycleSideBar(sidebar, 'list-card');
+ if (selectedSideBar.value !== sidebar) return;
+
+ const screenSize = getScreenSize();
+ if (screenSize === 'default' || screenSize === 'sm') {
+ drawer.open(VideoSidebarDrawer, {});
+ }
+};
</script>
<template>
@@ -64,7 +77,7 @@ const toggleDropdown = () => {
</NavButton>
<NavButton
v-if="$route.name === 'home'"
- @click="cycleSideBar('folders', 'list-card')"
+ @click="toggleVideoSidebar('folders')"
:label="'folders'"
:active="selectedSideBar === 'folders'"
:class="`ring-1 ring-gray-900/5`"
@@ -76,7 +89,7 @@ const toggleDropdown = () => {
</NavButton>
<NavButton
v-if="userData && $route.name === 'home'"
- @click="cycleSideBar('history', 'list-card')"
+ @click="toggleVideoSidebar('history')"
:label="'history'"
:active="selectedSideBar === 'history'"
:class="`ring-1 ring-gray-900/5`"
diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vue
index 1d3883f6..9a17aae5 100755
--- a/resources/js/layouts/LayoutBase.vue
+++ b/resources/js/layouts/LayoutBase.vue
@@ -31,7 +31,7 @@ const { selectedSideBar, sideBarTarget } = storeToRefs(useAppStore());
id="list-card"
:class="
cn(`card order-3 col-span-1 sm:scroll-mt-6 lg:col-span-2 2xl:col-span-1`, 'hidden flex-col gap-3 sm:p-3', {
- flex: selectedSideBar && sideBarTarget === 'list-card',
+ 'hidden md:flex': selectedSideBar && sideBarTarget === 'list-card',
})
"
>
@@ -43,10 +43,10 @@ const { selectedSideBar, sideBarTarget } = storeToRefs(useAppStore());
<style lang="css" scoped>
@reference "../../css/app.css";
.card {
- @apply bg-primary-900 dark:bg-primary-dark-900 h-fit ring-gray-900/5 sm:rounded-2xl sm:shadow-xl sm:ring-1;
+ @apply bg-surface-1 h-fit ring-gray-900/5 sm:rounded-2xl sm:shadow-xl sm:ring-1;
}
.page {
- @apply bg-primary-900 dark:bg-primary-dark-900 sm:bg-primary-950 sm:dark:bg-primary-dark-950 xms:px-6 p-3 text-gray-900 antialiased sm:p-6 dark:text-white;
+ @apply bg-surface-1 sm:bg-surface-0 xms:px-6 text-foreground-0 p-3 antialiased sm:p-6;
}
</style>