π 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
New mobile version of context menu component
Smaug6739c9d8404894b7
diff --git a/frontend/app/components/ContextMenuManager.vue b/frontend/app/components/ContextMenuManager.vueindex ee37adff..62c57e87 100644--- a/frontend/app/components/ContextMenuManager.vue+++ b/frontend/app/components/ContextMenuManager.vue@@ -1,12 +1,29 @@<template><div v-if="menu">- <!-- Backdrop transparent -->- <div class="context-backdrop" @click="contextMenu.close" />+ <!-- Desktop: Classic context menu -->+ <template v-if="!isMobile">+ <!-- Backdrop transparent -->+ <div class="context-backdrop" @click="contextMenu.close" />- <!-- Menu -->- <div ref="menuRef" class="context-menu" :style="{ top: `${pos.y}px`, left: `${pos.x}px` }">- <component :is="menu.component" v-bind="menu.options.props" class="context-menu-content" @close="contextMenu.close" />- </div>+ <!-- Menu -->+ <div ref="menuRef" class="context-menu" :style="{ top: `${pos.y}px`, left: `${pos.x}px` }">+ <component :is="menu.component" v-bind="menu.options.props" class="context-menu-content" @close="contextMenu.close" />+ </div>+ </template>++ <!-- Mobile: Bottom Sheet -->+ <Transition name="mobile-sheet">+ <div v-if="isMobile" class="mobile-overlay" @click.self="contextMenu.close">+ <div class="mobile-sheet" :style="sheetStyle">+ <div class="mobile-sheet-header" @touchstart="onDragStart" @touchmove="onDragMove" @touchend="onDragEnd" @mousedown="onDragStart">+ <div class="mobile-sheet-handle" />+ </div>+ <div class="mobile-sheet-body">+ <component :is="menu.component" v-bind="menu.options.props" class="mobile-menu-content" @close="contextMenu.close" />+ </div>+ </div>+ </div>+ </Transition></div></template>@@ -14,6 +31,103 @@const contextMenu = useContextMenu();const menu = contextMenu.menu;+// Mobile detection+const mobileBreakpoint = 768;+const windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1024);+const isMobile = computed(() => windowWidth.value < mobileBreakpoint);++function updateWindowWidth() {+ windowWidth.value = window.innerWidth;+}++// Drag/Swipe handling for mobile sheet+const isDragging = ref(false);+const dragStartY = ref(0);+const dragCurrentY = ref(0);+const sheetTranslateY = ref(0);++const sheetStyle = computed(() => {+ if (sheetTranslateY.value > 0) {+ return {+ transform: `translateY(${sheetTranslateY.value}px)`,+ transition: isDragging.value ? 'none' : 'transform 0.3s ease-out',+ };+ }+ return {};+});++function getClientY(e: TouchEvent | MouseEvent): number {+ if ('touches' in e) {+ return e.touches[0]?.clientY ?? 0;+ }+ return e.clientY;+}++function onDragStart(e: TouchEvent | MouseEvent) {+ isDragging.value = true;+ dragStartY.value = getClientY(e);+ dragCurrentY.value = dragStartY.value;++ if (!('touches' in e)) {+ // Mouse events need global listeners+ window.addEventListener('mousemove', onDragMove);+ window.addEventListener('mouseup', onDragEnd);+ }+}++function onDragMove(e: TouchEvent | MouseEvent) {+ if (!isDragging.value) return;++ dragCurrentY.value = getClientY(e);+ const deltaY = dragCurrentY.value - dragStartY.value;++ // Only allow dragging down (positive delta)+ sheetTranslateY.value = Math.max(0, deltaY);+}++function onDragEnd() {+ if (!isDragging.value) return;++ isDragging.value = false;++ // Remove mouse listeners if added+ window.removeEventListener('mousemove', onDragMove);+ window.removeEventListener('mouseup', onDragEnd);++ const threshold = 100; // pixels to trigger close++ if (sheetTranslateY.value > threshold) {+ // Close the menu+ contextMenu.close();+ }++ // Reset translate+ sheetTranslateY.value = 0;+}++// Reset drag state when menu closes+watch(+ () => menu.value,+ newMenu => {+ if (!newMenu) {+ sheetTranslateY.value = 0;+ isDragging.value = false;+ }+ if (isMobile.value) {+ document.body.style.overflow = newMenu ? 'hidden' : '';+ }+ },+);++onMounted(() => {+ window.addEventListener('resize', updateWindowWidth);+});++onBeforeUnmount(() => {+ window.removeEventListener('resize', updateWindowWidth);+ document.body.style.overflow = '';+});+const pos = computed(() => {if (!menu.value) return { x: 0, y: 0 };@@ -71,4 +185,93 @@ const pos = computed(() => {:root.dark .context-menu {box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 1px rgba(255, 255, 255, 0.1);}++/* ========================+ Mobile Bottom Sheet Styles+ ======================== */+.mobile-overlay {+ position: fixed;+ inset: 0;+ z-index: 6000;+ display: flex;+ align-items: flex-end;+ justify-content: center;+ background: rgb(0 0 0 / 50%);+}++.mobile-sheet {+ display: flex;+ flex-direction: column;+ width: 100%;+ min-height: 60vh;+ max-height: 85vh;+ border-radius: 16px 16px 0 0;+ background: var(--bg-color);+ animation: slide-up 0.3s ease-out;+}++@keyframes slide-up {+ from {+ transform: translateY(100%);+ }++ to {+ transform: translateY(0);+ }+}++.mobile-sheet-header {+ display: flex;+ flex-shrink: 0;+ align-items: center;+ justify-content: center;+ padding: 12px 16px 8px;+ cursor: grab;+ touch-action: none;+ user-select: none;++ &:active {+ cursor: grabbing;+ }+}++.mobile-sheet-handle {+ width: 36px;+ height: 4px;+ border-radius: 2px;+ background: var(--border-color);+ transition: background 0.2s, width 0.2s;++ .mobile-sheet-header:active & {+ width: 48px;+ background: var(--font-color-light, #888);+ }+}++.mobile-sheet-body {+ flex: 1;+ overflow-y: auto;+ -webkit-overflow-scrolling: touch;+}++/* Transitions */+.mobile-sheet-enter-active,+.mobile-sheet-leave-active {+ transition: opacity 0.3s ease;+}++.mobile-sheet-enter-active .mobile-sheet,+.mobile-sheet-leave-active .mobile-sheet {+ transition: transform 0.3s ease;+}++.mobile-sheet-enter-from,+.mobile-sheet-leave-to {+ opacity: 0;+}++.mobile-sheet-enter-from .mobile-sheet,+.mobile-sheet-leave-to .mobile-sheet {+ transform: translateY(100%);+}</style>