Skip to content

A self-hosted media server and file management system

add scrolling to modals (pain)

aminnausinbeddf64b5f72
diff --git a/package-lock.json b/package-lock.json
index 3a7c42c8..ef8efa64 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.5.0",
"pinia": "^2.1.7",
+ "tailwind-scrollbar-hide": "^1.1.7",
"vue": "^3.4.29",
"vue-loader": "^17.4.2",
"vue-router": "^4.4.0"
@@ -4093,6 +4094,12 @@
"integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==",
"license": "MIT"
},
+ "node_modules/tailwind-scrollbar-hide": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz",
+ "integrity": "sha512-X324n9OtpTmOMqEgDUEA/RgLrNfBF/jwJdctaPZDzB3mppxJk7TLIDmOreEDm1Bq4R9LSPu4Epf8VSdovNU+iA==",
+ "license": "MIT"
+ },
"node_modules/tailwindcss": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz",
diff --git a/package.json b/package.json
index 18e4a2dd..7a7c779d 100755
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.5.0",
"pinia": "^2.1.7",
+ "tailwind-scrollbar-hide": "^1.1.7",
"vue": "^3.4.29",
"vue-loader": "^17.4.2",
"vue-router": "^4.4.0"
diff --git a/resources/js/components/pinesUI/ModalBase.vue b/resources/js/components/pinesUI/ModalBase.vue
index 6b44ffaf..ab742024 100755
--- a/resources/js/components/pinesUI/ModalBase.vue
+++ b/resources/js/components/pinesUI/ModalBase.vue
@@ -1,9 +1,10 @@
<script setup>
-import { nextTick, ref, watch } from 'vue';
import ButtonCorner from '../inputs/ButtonCorner.vue';
+
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
import { OnClickOutside } from '@vueuse/components';
-const modalRoot = ref(null);
+import { useAppStore } from '../../stores/AppStore';
+import { watch } from 'vue';
const props = defineProps({
modalData: {
@@ -21,18 +22,19 @@ const props = defineProps({
}
})
+const AppStore = useAppStore();
+const { setScrollLock } = AppStore;
+
const submitModal = async (action, modalData) => {
await action();
modalData.toggleModal(false);
}
-watch(() => props.modalData.modalOpen, async (value) => {
-
- if(value && modalRoot.value !== null) {
- await nextTick();
- // modalRoot.value.focus();
+watch(() => props.modalData.isAnimating, (value) => {
+ if((props.modalData.modalOpen && value) || !value){
+ setScrollLock(props.modalData.modalOpen);
}
-} )
+})
</script>
<template>
<Teleport to="body">
@@ -40,15 +42,17 @@ watch(() => props.modalData.modalOpen, async (value) => {
class="fixed top-0 left-0 z-[25] flex items-center justify-center w-full h-screen text-neutral-900 dark:text-neutral-200"
v-cloak>
<Transition enter-active-class="ease-out duration-300" enter-from-class="opacity-0" enter-to-class="opacity-100" leave-active-class="ease-in duration-300" leave-from-class="opacity-100" leave-to-class="opacity-0">
- <div v-if="modalData.modalOpen" class="absolute inset-0 w-full h-full backdrop-blur-sm bg-opacity-70"></div>
+ <div v-if="modalData.modalOpen" class="absolute inset-0 w-full h-full backdrop-blur-sm bg-opacity-70"></div>
</Transition>
- <Transition enter-active-class="ease-out duration-300" enter-from-class="opacity-0 -translate-y-2 sm:scale-95" enter-to-class="opacity-100 translate-y-0 sm:scale-100" leave-active-class="ease-in duration-200" leave-from-class="opacity-100 translate-y-0 sm:scale-100" leave-to-class="opacity-0 -translate-y-2 sm:scale-95">
- <UseFocusTrap v-if="modalData.modalOpen" >
- <OnClickOutside @trigger="modalData.toggleModal(false)">
- <div class="relative w-full m-6 p-6 bg-white dark:bg-neutral-800/90 backdrop-blur-lg border shadow-lg border-neutral-200 dark:border-neutral-700 sm:max-w-lg rounded-md sm:rounded-lg"
- @keydown.esc="modalData.toggleModal(false)">
+ <div class="relative w-full p-6 max-h-screen overflow-y-scroll scrollbar-hide">
+ <Transition enter-active-class="ease-out duration-300" enter-from-class="opacity-0 -translate-y-2 sm:scale-95" enter-to-class="opacity-100 translate-y-0 sm:scale-100" leave-active-class="ease-in duration-200" leave-from-class="opacity-100 translate-y-0 sm:scale-100" leave-to-class="opacity-0 -translate-y-2 sm:scale-95">
+ <UseFocusTrap v-if="modalData.modalOpen" class="h-full">
+ <OnClickOutside @trigger="modalData.toggleModal(false)"
+ @keydown.esc="modalData.toggleModal(false)"
+ class="m-auto w-full p-6 bg-white dark:bg-neutral-800/90 backdrop-blur-lg border shadow-lg border-neutral-200 dark:border-neutral-700 sm:max-w-lg rounded-md sm:rounded-lg"
+ tabindex="-1">
<div class="flex items-center justify-between pb-3">
- <h3 class="text-lg font-semibold">{{ modalData?.title ?? 'Modal Title' }}</h3>
+ <h3 class="text-xl font-semibold">{{ modalData?.title ?? 'Modal Title' }}</h3>
<ButtonCorner @click="modalData.toggleModal(false)" tabindex="99"/>
</div>
<slot name="content">
@@ -66,10 +70,10 @@ watch(() => props.modalData.modalOpen, async (value) => {
:class="'focus:ring-1 focus:ring-violet-900 focus:ring-offset-1 bg-neutral-950 hover:bg-neutral-800 dark:hover:bg-neutral-900 '">{{ modalData.submitText }}</button>
</div>
</slot>
- </div>
- </OnClickOutside>
- </UseFocusTrap>
- </Transition>
+ </OnClickOutside>
+ </UseFocusTrap>
+ </Transition>
+ </div>
</div>
</Teleport>
</template>
\ No newline at end of file
diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vue
index 5182cec8..3defe762 100755
--- a/resources/js/layouts/LayoutBase.vue
+++ b/resources/js/layouts/LayoutBase.vue
@@ -1,24 +1,36 @@
<script setup>
import NavBar from '../components/panels/NavBar.vue';
+
+// import { useScrollLock } from '@vueuse/core'
import { useAppStore } from '../stores/AppStore';
import { storeToRefs } from 'pinia';
+// import { ref, watch } from 'vue';
+import { ref } from 'vue';
const appStore = useAppStore();
-const { selectedSideBar } = storeToRefs(appStore);
+const { selectedSideBar, scrollLock } = storeToRefs(appStore);
+
+const scrollBody = ref(null);
+// const scrollLocked = useScrollLock(scrollBody);
+
+// watch(() => scrollLock.value, () => scrollLocked.value = scrollLock.value);
</script>
<template>
- <main class="p-6 flex gap-6 flex-wrap lg:flex-nowrap snap-y">
- <section id="left-card" class="w-full p-3 pb-6 rounded-2xl lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 space-y-2 scroll-mt-6 hidden lg:block">
- </section>
- <section id="content-card"
- class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-6 pt-3 rounded-2xl w-full flex flex-col gap-3 z-20">
- <NavBar class="z-20" />
- <slot name="content" class="relative z-0"></slot>
- </section>
- <section id="list-card" :class="{ invisible: !selectedSideBar }"
- class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-3 pb-6 rounded-2xl w-full lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 space-y-2 scroll-mt-6 z-20">
- <slot name="sidebar"></slot>
- </section>
- </main>
+ <div class="h-screen" :class="{'' : scrollLock}" ref="scrollBody">
+ <!-- overflow-y-hidden -->
+ <main class="flex p-6 gap-6 flex-wrap lg:flex-nowrap snap-y bg-primary-950 dark:bg-primary-dark-950 dark:text-[#e2e0e2] font-sans text-gray-900 antialiased">
+ <section id="left-card" class="w-full h-fit p-3 pb-6 rounded-2xl lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 space-y-2 scroll-mt-6 hidden lg:block">
+ </section>
+ <section id="content-card"
+ class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-6 pt-3 rounded-2xl w-full h-fit flex flex-col gap-3 z-20">
+ <NavBar class="z-20" />
+ <slot name="content" class="relative z-0"></slot>
+ </section>
+ <section id="list-card" :class="{ invisible: !selectedSideBar }"
+ class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-3 pb-6 rounded-2xl w-full h-fit lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 space-y-2 scroll-mt-6 z-20">
+ <slot name="sidebar"></slot>
+ </section>
+ </main>
+ </div>
</template>
\ No newline at end of file
diff --git a/resources/js/stores/AppStore.js b/resources/js/stores/AppStore.js
index 4bfa9ff8..9012065b 100755
--- a/resources/js/stores/AppStore.js
+++ b/resources/js/stores/AppStore.js
@@ -6,6 +6,7 @@ export const useAppStore = defineStore("App", () => {
const lightMode = ref(null);
const ambientMode = ref(null);
const selectedSideBar = ref("");
+ const scrollLock = ref(false);
function toggleDarkMode() {
let rootHTML = document.querySelector("html");
@@ -49,10 +50,15 @@ export const useAppStore = defineStore("App", () => {
selectedSideBar.value = target;
}
+ function setScrollLock(state = false){
+ scrollLock.value = state;
+ }
+
return {
initDarkMode, toggleDarkMode, lightMode,
initAmbientMode, setAmbientMode, ambientMode,
cycleSideBar, selectedSideBar,
pageTitle,
+ scrollLock, setScrollLock
};
});
diff --git a/tailwind.config.js b/tailwind.config.js
index 7fa5ba21..1c688650 100755
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -87,6 +87,8 @@ export default {
require('@tailwindcss/forms'),
// eslint-disable-next-line no-undef
require('@tailwindcss/aspect-ratio'),
+ // eslint-disable-next-line no-undef
+ require('tailwind-scrollbar-hide'),
]
}