π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
<template>
<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 class="modal-container">
<button class="close-btn" @click="modalManager.close(modal)">
<Icon name="close" display="lg" />
</button>
<component
:is="modal.component"
:style="{ padding: modal.options.noPadding ? '0' : '10px 18px' }"
v-bind="modal.options.props"
class="modal"
:class="modal.options.size"
@close="() => modalManager.close(modal)"
/>
</div>
</div>
</TransitionGroup>
</template>
<script setup lang="ts">
const modalManager = useModal();
const modals = modalManager.modals;
const handleKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && modals.value.length > 0) {
modalManager.closeLast();
}
};
onMounted(() => document.addEventListener('keydown', handleKeydown));
onUnmounted(() => document.removeEventListener('keydown', handleKeydown));
</script>
<style scoped lang="scss">
/* Transition group classes */
.modal-enter-active,
.modal-leave-active {
transition:
opacity $transition-medium ease,
transform $transition-medium ease;
}
.modal-enter-from,
.modal-leave-to {
opacity: 0;
transform: scale(1.1);
}
/* Styles modals */
.modal-container {
position: relative;
width: 90%;
max-width: 750px;
margin: auto;
border-radius: var(--radius-lg);
font-size: initial;
background-color: var(--surface-base);
box-shadow: var(--shadow-sm);
backdrop-filter: var(--backdrop-blur) var(--backdrop-saturate);
}
.modal-container:has(> .full) {
width: 100%;
max-width: calc(100vw - 32px);
height: 100%;
max-height: calc(100vh - 20px);
.modal {
max-height: none;
}
}
.modal-container:has(> .large) {
width: 100%;
max-width: 95vw;
height: 100%;
max-height: 90vh;
.modal {
max-height: none;
}
}
.modal-container:has(> .medium) {
max-width: 1115px;
}
.modal-container:has(> .small) {
max-width: 700px;
}
.modal-overlay {
position: absolute;
z-index: 1;
border-radius: var(--radius-lg);
background-color: var(--overlay-light);
inset: 0;
pointer-events: none;
}
.close-btn {
position: absolute;
top: 1rem;
right: 0;
z-index: 1000;
background: none;
}
.modal {
border-radius: var(--radius-md);
background-color: var(--surface-base);
}
.modal-mask {
position: fixed;
display: flex;
background-color: var(--overlay-backdrop);
backdrop-filter: var(--backdrop-blur) var(--backdrop-saturate);
inset: 0;
}
.modal-pos {
position: fixed;
top: 0;
left: 0;
display: flex;
width: 100vw;
height: 100vh;
}
@media screen and (width <= 600px) {
.modal-container {
display: flex;
flex-direction: column;
justify-content: center;
width: 95%;
padding: 12px 0;
}
.close-btn {
top: 0.5rem;
right: 0.5rem;
}
}
</style>