From 845b23cf21f61719ebed3de90ed81208cc7c06c1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 26 Oct 2026 15:27:04 +0100 Subject: [PATCH] feat: sidebar for mobiles --- src-tauri/tauri.conf.json | 9 +- src/components/Sidebar/Sidebar.css | 104 +++++++++++++++++- src/components/Sidebar/Sidebar.tsx | 12 +- .../components/DSP408Panel/DSP408Panel.css | 20 +++- .../components/DSP408Panel/DSP408Panel.tsx | 10 +- src/hooks/useLongPress.ts | 22 ++++ src/variables.css | 16 +++ 7 files changed, 184 insertions(+), 9 deletions(-) create mode 100644 src/hooks/useLongPress.ts diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index be8f86e..3d40a69 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -13,10 +13,11 @@ "windows": [ { "title": "Thomann DSP Controller", - "width": 360, - "height": 800, - "minWidth": 320, - "minHeight": 500 + "width": 1600, + "height": 950, + "minWidth": 1200, + "minHeight": 600 + } ], "security": { diff --git a/src/components/Sidebar/Sidebar.css b/src/components/Sidebar/Sidebar.css index 7b49869..622ad8b 100644 --- a/src/components/Sidebar/Sidebar.css +++ b/src/components/Sidebar/Sidebar.css @@ -2,7 +2,7 @@ .sidebar-rail { position: fixed; - top: var(--header-height); + top: var(--topbar-h); left: 0; bottom: 0; @@ -416,3 +416,105 @@ max-width: 200px; border: none; } + +/* ---------- Phone / touch ---------- */ + +.sidebar-backdrop { + display: none; +} + +@media (hover: none) { + .sidebar-item:hover { + background: transparent; + color: var(--text-muted); + border-color: transparent; + } + .sidebar-item--active:hover { + color: var(--text-primary); + border-color: var(--accent-brand); + } + .sidebar-toggle:hover { + background: var(--bg-void); + color: var(--text-muted); + border-color: transparent; + } + .sidebar-app-trigger:hover { + border-color: var(--border-hairline); + } +} + +@media (pointer: coarse) { + /* Cancel the global 44px min-height, sizes are set explicitly below */ + .sidebar-rail button { + min-height: 0; + } + + /* No iOS/Android callout menu on long-press (we use it for rename) */ + .sidebar-item, + .sidebar-app-trigger { + -webkit-touch-callout: none; + } +} + +@media (max-width: 768px) { + .sidebar-rail { + top: var(--topbar-h); + bottom: 0; + padding-bottom: var(--safe-bottom); + padding-left: var(--safe-left); + width: calc(var(--sidebar-width-collapsed) + var(--safe-left)); + } + + /* Expanded = drawer on top of the content, not pushing it */ + .sidebar-rail--expanded { + width: calc(var(--sidebar-width-expanded) + var(--safe-left)); + z-index: 50; + box-shadow: 8px 0 24px rgba(0, 0, 0, 0.45); + } + + .app-root--sidebar-expanded .sidebar-backdrop { + display: block; + position: fixed; + top: var(--topbar-h); + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + z-index: 45; + } + + .sidebar-scroll { + overscroll-behavior: contain; + -webkit-overflow-scrolling: touch; + } + + /* Touch-sized items */ + .sidebar-item, + .sidebar-item--editing { + height: 44px; + } + .sidebar-rail--expanded .sidebar-item { + width: 100%; + } + .sidebar-toggle { + height: 40px; + } + + /* Preset dropdown */ + .sidebar-app-trigger, + .sidebar-app-input { + height: 40px; + } + .sidebar-app-input, + .sidebar-item-input { + font-size: 16px; /* prevents iOS focus-zoom */ + } + .sidebar-app-listbox { + max-height: min(240px, 50dvh); + -webkit-overflow-scrolling: touch; + } + .sidebar-app-option { + padding: var(--space-3) var(--space-2); + font-size: var(--font-sm); + } +} \ No newline at end of file diff --git a/src/components/Sidebar/Sidebar.tsx b/src/components/Sidebar/Sidebar.tsx index 295fed8..d10867f 100644 --- a/src/components/Sidebar/Sidebar.tsx +++ b/src/components/Sidebar/Sidebar.tsx @@ -1,6 +1,7 @@ import { useEffect, useRef, useState } from 'react'; import './Sidebar.css'; import { ChevronLeftIcon } from '../../assets/icons/ChevronLeftIcon'; +import { useLongPress } from '../../hooks/useLongPress'; export type SidebarItem = { id: T; @@ -33,7 +34,7 @@ function SidebarButton({ if (!editing) setInputValue(item.label); }, [item.label, editing]); - function startEditing(e: React.MouseEvent) { + function startEditing(e: { stopPropagation(): void }) { e.stopPropagation(); if (!onRename) return; @@ -68,6 +69,11 @@ function SidebarButton({ } } + const longPress = useLongPress((e, el) => { + // only when the drawer is open (labels are invisible when collapsed) + if (onRename && el.closest('.sidebar-rail--expanded')) startEditing(e); + }); + if (editing) { return (
@@ -90,6 +96,7 @@ function SidebarButton({ return (