feat: drag-to-resize sidebar width#170
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds interactive sidebar width resizing with persistent storage. New ChangesResizable Sidebar Feature
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Handle as SidebarResizeHandle
participant Theme as ThemeContext
participant CSS as CSS/DOM
participant Backend as Backend
rect rgba(200, 220, 255, 0.5)
Note over User,Backend: Sidebar Width Initialization
Theme->>Backend: Load settings
Backend-->>Theme: Return sidebarWidthPx (if set)
Theme->>Theme: Validate and clamp to SIDEBAR_MIN/MAX
Theme->>CSS: Set --sidebar-width CSS variable
end
rect rgba(200, 255, 220, 0.5)
Note over User,Backend: User Drags Resize Handle
User->>Handle: Pointer down on separator
Handle->>Handle: Store start X position and initial width
Handle->>CSS: Add sidebar-no-transition class
loop Pointer move
User->>Handle: Move pointer
Handle->>Handle: Compute width delta and clamp
Handle->>Theme: setSidebarWidthLive(px)
Theme->>CSS: Update --sidebar-width immediately
Handle->>Handle: Update and show width tooltip
end
User->>Handle: Release pointer
Handle->>Theme: setSidebarWidthPx(px)
Theme->>Backend: Persist clamped width
Theme->>CSS: Remove sidebar-no-transition
Handle->>Handle: Clear drag state
end
rect rgba(255, 220, 220, 0.5)
Note over User,Backend: Double-Click Reset
User->>Handle: Double-click separator
Handle->>Theme: setSidebarWidthPx(null)
Theme->>Backend: Persist undefined (reset)
Theme->>CSS: Remove --sidebar-width variable
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
16remwidth until you resize it; a custom width is then clamped to 180–800px and persisted in settings assidebarWidthPxChanges
src-tauri/src/lib.rssidebarWidthPxto the persistedSettingsstructsrc/types/note.tssidebarWidthPxtoSettingssrc/lib/sidebar.tssrc/context/ThemeContext.tsx--sidebar-widthvariablesrc/components/layout/SidebarResizeHandle.tsxsrc/components/layout/Sidebar.tsxw-64→w-full)src/App.tsx--sidebar-width(fallback16rem), mount the handlesrc/App.cssTest plan
npm run buildpassescargo clippy -- -D warningspassesSummary by CodeRabbit