Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Improve modal system

Smaug6739c492edc69955
diff --git a/frontend/app/components/Modal.vue b/frontend/app/components/Modal.vue
deleted file mode 100644
index 8241a844..00000000
--- a/frontend/app/components/Modal.vue
+++ /dev/null
@@ -1,25 +0,0 @@
-<template>
- <div v-if="show">
- <div class="modal-container">
- <slot></slot>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-defineProps<{ show: boolean }>();
-const emit = defineEmits(['close', 'confirm']);
-</script>
-
-<style lang="scss" scoped>
-.modal-container {
- width: 500px;
- margin: auto;
- padding: 20px;
- background-color: var(--bg-color);
- border-radius: 10px;
- box-shadow: 0 2px 8px var(--shadow);
- transition: all 0.3s ease;
- font-size: initial;
-}
-</style>
diff --git a/frontend/app/components/ModalManager.vue b/frontend/app/components/ModalManager.vue
index fbc98355..e399d396 100644
--- a/frontend/app/components/ModalManager.vue
+++ b/frontend/app/components/ModalManager.vue
@@ -1,32 +1,51 @@
<template>
- <Transition name="modal">
- <div v-if="modals.length">
- <div v-for="(modal, index) in modals" :key="index" class="modal-mask modal-pos" :style="{ zIndex: 120 + index }">
- <div v-if="index !== modals.length - 1" class="modal-overlay"></div>
- <div class="modal-container">
- <button @click="modalManager.close(modal)" class="close-btn"><Icon name="close" :big="true" /></button>
- <component :is="modal.component" v-bind="modal.props" class="modal" @close="modalManager.close(modal)" />
- </div>
+ <TransitionGroup name="modal" tag="div">
+ <div v-for="(modal, index) in modals" :key="index" class="modal-mask modal-pos" :style="{ zIndex: 120 + index }" @click.self="modalManager.close(modal)">
+ <div v-if="index !== modals.length - 1" class="modal-overlay"></div>
+ <div class="modal-container">
+ <button @click="modalManager.close(modal)" class="close-btn">
+ <Icon name="close" :big="true" />
+ </button>
+ <component :is="modal.component" v-bind="modal.props" class="modal" :class="modal.big ? 'big' : ''" @close="modalManager.close(modal)" />
</div>
</div>
- </Transition>
+ </TransitionGroup>
</template>
+
<script setup lang="ts">
const modalManager = useModal();
const modals = modalManager.modals;
</script>
<style scoped lang="scss">
+/* Transition group classes */
+.modal-enter-active,
+.modal-leave-active {
+ transition: all 0.3s ease;
+}
+.modal-enter-from,
+.modal-leave-to {
+ transform: scale(1.1);
+ opacity: 0;
+}
+
+/* Styles modals */
.modal-container {
+ width: 80%;
+ max-width: 750px;
margin: auto;
padding: 16px 22px;
background-color: var(--bg-color);
border-radius: 10px;
box-shadow: 0 2px 10px var(--shadow);
- transition: all 0.3s ease;
font-size: initial;
position: relative;
}
+
+.modal-container:has(> .big) {
+ max-width: 1115px;
+}
+
.modal-overlay {
position: absolute;
inset: 0;
@@ -35,18 +54,6 @@ const modals = modalManager.modals;
z-index: 1;
pointer-events: none;
}
-
-.modal-enter-from,
-.modal-leave-to {
- opacity: 0;
-}
-
-.modal-enter-from .modal-container,
-.modal-leave-to .modal-container {
- -webkit-transform: scale(1.1);
- transform: scale(1.1);
-}
-
.close-btn {
position: absolute;
right: 0px;
@@ -58,14 +65,9 @@ const modals = modalManager.modals;
background-color: var(--bg-color);
border-radius: 8px;
}
-
.modal-mask {
position: fixed;
- z-index: 120;
- top: 0;
- left: 0;
- width: 100vw;
- height: 100vh;
+ inset: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
}
diff --git a/frontend/app/composables/ModalBus.ts b/frontend/app/composables/ModalBus.ts
index 14542073..171441d1 100644
--- a/frontend/app/composables/ModalBus.ts
+++ b/frontend/app/composables/ModalBus.ts
@@ -22,5 +22,5 @@ export function useModal() {
}
export class Modal {
- constructor(public component: any, public props: any = {}, public onClose: () => void = () => {}) {}
+ constructor(public component: any, public props: any = {}, public onClose: () => void = () => {}, public big: boolean = false) {}
}
diff --git a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
index d0822e65..a7849a71 100644
--- a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
+++ b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue
@@ -29,9 +29,6 @@ const allChildren = useSidebarTree().getSubTreeById(props.categoryId);
</script>
<style scoped lang="scss">
-.modal {
- min-width: 500px;
-}
.warn {
color: $red-dark;
opacity: 0.7;
diff --git a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue
index 7e9cb05c..7a0d1139 100644
--- a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue
+++ b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue
@@ -25,8 +25,4 @@ const deleteRessource = async () => {
};
</script>
-<style scoped lang="scss">
-.modal {
- min-width: 500px;
-}
-</style>
+<style scoped lang="scss"></style>
diff --git a/frontend/app/pages/dashboard/docs/_modals/DeleteDocumentModal.vue b/frontend/app/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
index 05a0ea87..1105e2b0 100644
--- a/frontend/app/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
+++ b/frontend/app/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
@@ -28,9 +28,6 @@ const allChildren = useSidebarTree().getSubTreeById(props.documentId);
</script>
<style scoped lang="scss">
-.modal {
- min-width: 500px;
-}
.warn {
color: $red-dark;
opacity: 0.7;
diff --git a/frontend/app/pages/dashboard/settings/_modals/DeleteAccountModal.vue b/frontend/app/pages/dashboard/settings/_modals/DeleteAccountModal.vue
index 8adfa5d2..2f20ca1f 100644
--- a/frontend/app/pages/dashboard/settings/_modals/DeleteAccountModal.vue
+++ b/frontend/app/pages/dashboard/settings/_modals/DeleteAccountModal.vue
@@ -45,9 +45,6 @@ function deleteAccount() {
</script>
<style scoped lang="scss">
-.modal {
- min-width: 500px;
-}
.warn {
color: $red-dark;
opacity: 0.7;