feat: resizable columns, nav rail overhaul, multi-select & drag-drop, UI polish
Resizable Columns - Add ResizeHandle component with mouse drag, keyboard (Arrow keys), and double-click to reset to default width - Add sidebarWidth/emailListWidth to ui-store with clamping + persistence - Wire resize handles between sidebar/email-list panels on desktop Navigation Rail Overhaul - Move StorageQuotaCircle, push-status, sign-out from Sidebar to NavigationRail - Interactive SVG ring with popover breakdown (used/free/total) - Sidebar collapse state lifted to ui-store - Show total email count per mailbox alongside unread badge Email Multi-Selection & Drag-and-Drop - Ctrl+Click (toggle) and Shift+Click (range) on all list items - Add selectRangeEmails and lastSelectedEmailId to email-store - Enable drag-and-drop on thread items and thread headers - useEmailDrag accepts optional threadEmails for full-thread drag Email Viewer Layout - Remove card wrapper for cleaner full-width reading - Always render HTML body when available - Adjust skeleton loader to match flat layout Modal & UI Polish - Standardise backdrops, close buttons, padding, border-radius, transitions - Migrate template-string classNames to cn() in settings - Unify focus-ring token to ring-ring on form controls i18n - Add storage_used/free/total keys to all 8 locales Dev Mock JMAP Server (new, gated by DEV_MOCK_JMAP=true) - Session, Mailbox/Email/Thread/Identity CRUD, back-references, upload - GET /download with Content-Disposition, GET /eventsource SSE Tests (46 new) - ui-store (13), email-selection (10), resize-handle (9), mock-server (14)
This commit is contained in:
@@ -4,6 +4,14 @@ import { create } from "zustand";
|
||||
|
||||
export type ActiveView = "sidebar" | "list" | "viewer";
|
||||
|
||||
// Column width constraints (in pixels)
|
||||
const SIDEBAR_MIN = 180;
|
||||
const SIDEBAR_MAX = 400;
|
||||
const SIDEBAR_DEFAULT = 256;
|
||||
const EMAIL_LIST_MIN = 240;
|
||||
const EMAIL_LIST_MAX = 600;
|
||||
const EMAIL_LIST_DEFAULT = 384;
|
||||
|
||||
interface UIState {
|
||||
// Mobile view state
|
||||
activeView: ActiveView;
|
||||
@@ -17,12 +25,26 @@ interface UIState {
|
||||
isTablet: boolean;
|
||||
isDesktop: boolean;
|
||||
|
||||
// Resizable column widths (desktop only)
|
||||
sidebarWidth: number;
|
||||
emailListWidth: number;
|
||||
|
||||
// Sidebar collapsed state (desktop)
|
||||
sidebarCollapsed: boolean;
|
||||
|
||||
// Actions
|
||||
setActiveView: (view: ActiveView) => void;
|
||||
setSidebarOpen: (open: boolean) => void;
|
||||
toggleSidebar: () => void;
|
||||
setTabletListVisible: (visible: boolean) => void;
|
||||
setDeviceType: (isMobile: boolean, isTablet: boolean, isDesktop: boolean) => void;
|
||||
setSidebarWidth: (width: number) => void;
|
||||
setEmailListWidth: (width: number) => void;
|
||||
resetSidebarWidth: () => void;
|
||||
resetEmailListWidth: () => void;
|
||||
persistColumnWidths: () => void;
|
||||
setSidebarCollapsed: (collapsed: boolean) => void;
|
||||
toggleSidebarCollapsed: () => void;
|
||||
|
||||
// Navigation helpers
|
||||
showEmailList: () => void;
|
||||
@@ -30,6 +52,8 @@ interface UIState {
|
||||
goBack: () => void;
|
||||
}
|
||||
|
||||
// Column widths are hydrated from localStorage by the page component on mount
|
||||
|
||||
export const useUIStore = create<UIState>((set, get) => ({
|
||||
// Initial state (SSR-safe defaults)
|
||||
activeView: "list",
|
||||
@@ -38,6 +62,9 @@ export const useUIStore = create<UIState>((set, get) => ({
|
||||
isMobile: false,
|
||||
isTablet: false,
|
||||
isDesktop: true,
|
||||
sidebarWidth: SIDEBAR_DEFAULT,
|
||||
emailListWidth: EMAIL_LIST_DEFAULT,
|
||||
sidebarCollapsed: false,
|
||||
|
||||
// Actions
|
||||
setActiveView: (view) => set({ activeView: view }),
|
||||
@@ -51,6 +78,38 @@ export const useUIStore = create<UIState>((set, get) => ({
|
||||
setDeviceType: (isMobile, isTablet, isDesktop) =>
|
||||
set({ isMobile, isTablet, isDesktop }),
|
||||
|
||||
setSidebarWidth: (width) =>
|
||||
set({ sidebarWidth: Math.min(SIDEBAR_MAX, Math.max(SIDEBAR_MIN, width)) }),
|
||||
|
||||
setEmailListWidth: (width) =>
|
||||
set({ emailListWidth: Math.min(EMAIL_LIST_MAX, Math.max(EMAIL_LIST_MIN, width)) }),
|
||||
|
||||
resetSidebarWidth: () => {
|
||||
set({ sidebarWidth: SIDEBAR_DEFAULT });
|
||||
const { emailListWidth } = get();
|
||||
try {
|
||||
localStorage.setItem("column-widths", JSON.stringify({ sidebarWidth: SIDEBAR_DEFAULT, emailListWidth }));
|
||||
} catch { /* localStorage may be unavailable */ }
|
||||
},
|
||||
|
||||
resetEmailListWidth: () => {
|
||||
set({ emailListWidth: EMAIL_LIST_DEFAULT });
|
||||
const { sidebarWidth } = get();
|
||||
try {
|
||||
localStorage.setItem("column-widths", JSON.stringify({ sidebarWidth, emailListWidth: EMAIL_LIST_DEFAULT }));
|
||||
} catch { /* localStorage may be unavailable */ }
|
||||
},
|
||||
|
||||
persistColumnWidths: () => {
|
||||
const { sidebarWidth, emailListWidth } = get();
|
||||
try {
|
||||
localStorage.setItem("column-widths", JSON.stringify({ sidebarWidth, emailListWidth }));
|
||||
} catch { /* localStorage may be unavailable */ }
|
||||
},
|
||||
|
||||
setSidebarCollapsed: (collapsed) => set({ sidebarCollapsed: collapsed }),
|
||||
toggleSidebarCollapsed: () => set((state) => ({ sidebarCollapsed: !state.sidebarCollapsed })),
|
||||
|
||||
// Navigation helpers for mobile
|
||||
showEmailList: () => {
|
||||
const { isMobile } = get();
|
||||
|
||||
Reference in New Issue
Block a user