Skip to content

feat(panel): resizable file panel width (180-420px, persisted) - #70

Open
moyu12-ae wants to merge 1 commit into
marswaveai:mainfrom
moyu12-ae:feat/resizable-file-panel
Open

feat(panel): resizable file panel width (180-420px, persisted)#70
moyu12-ae wants to merge 1 commit into
marswaveai:mainfrom
moyu12-ae:feat/resizable-file-panel

Conversation

@moyu12-ae

Copy link
Copy Markdown
Contributor

解决的问题

实现 design.md 刚刚接受的「可调文件面板」规格,并彻底解决 issue #64 中「宽度不能拖动,长标题显示不全」的宽度部分(tooltip 缓解部分在 #68)。

Resizable file panel 已从 feature-requests.md 的 Declined 移入 design.md(180–420px 拖拽并持久化),本 PR 按该规格实现。

改动内容

  • 拖拽热区:面板右缘 6px 固定定位热区,cursor: col-resize;按 design.md 要求不显示常驻把手图标,仅 hover / 拖拽中显示主题色细条反馈(color-mix(var(--link-color)) 派生,随主题适配)。
  • 范围钳制:拖拽宽度实时钳制在 180px–420px,默认仍为 220px
  • 持久化:释放鼠标时写入 localStorage('file-panel-width'),模块加载时先应用再渲染,首帧即为保存的宽度、无闪跳。
  • 联动细节
    • 编辑区 / 源码区 margin-left 与面板宽度共用同一 CSS 变量 --file-panel-width,拖拽时正文实时让位,不会出现面板遮挡正文;
    • 面板隐藏(⌘⇧B)时热区随之隐藏;
    • 使用 Pointer Capture,拖拽越过 iframe(Mermaid)和选中文本时不会中断。

实现说明

宽度全部走 CSS 变量:#file-panelwidthbody.show-file-panel #editor/#source-editormargin-left 引用同一 --file-panel-width,两处永远同步(初版曾漏改 margin 一处导致遮挡,已在实测中修复并回归)。

验证

  • tsc --noEmitelectron-vite buildcheck:theme-colors(12 主题)通过。
  • 实测(CDP + 真实拖拽):拖拽时面板与正文同步移动;拖到两端分别钳制在 180/420 并正确持久化;重载后宽度保留;面板显隐联动热区显隐。

Implement the resizable panel accepted in design.md: the panel's right
edge offers a lightweight drag hot zone (no permanent handle icon, hover
stripe only) to resize between 180px and 420px. The choice persists in
localStorage and is applied at module load so the first paint already
uses it. The hot zone hides with the panel, and pointer capture keeps
the drag alive over iframes and selected text.

Closes the width half of marswaveai#64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant