fix(ui): Git 页的 Changes 与 Graph 接入可拖动分区堆叠
把线索页的 SectionStack 抽成统一组件 WorkbenchStack(ui/WorkbenchStack.tsx + workbench-stack.module.css,从 ui/index.ts 导出),线索页改为从统一层引用, 行为与权重持久化不变。 Git 页把 Changes 与 Graph 两个 WorkbenchSection 放进同一个堆叠:两区之间出现 可拖动的 sash(role=separator、aria-controls、Home/End/ArrowUp/ArrowDown), 权重只存本地 state——Git 页目前没有自己的设置键,不为此新增持久化。 布局:每个打开的分区各自内部滚动(changes 的 body 与 graph 区域),footer 仍是 贴底不滚;gitScroll 保留为 notices 的滚动容器。折叠到一个分区时 sash 消失。 测试:git-scm 新增「两个分区都开时存在 sash、键盘拖动改变两 pane 的 flexGrow、 折叠一个后 sash 消失」;changes-tab 的分隔条查询改为结构判别(sash 有 aria-controls、底部预览手柄没有),并把 .changesSection 的 CSS 契约从 flex:none 更新为 flex:1(现在由堆叠分配高度)。
This commit is contained in:
1 parent
bf4e25db13
commit
86dc34bd84
10 files changed
+118
-57
No files matched your search
@@ -27,7 +27,7 @@ import type { SidebarDiffRef } from '../state.ts'
|
||||
import { buildRepositoryLabels } from './repo-labels.ts'
|
||||
import { RepoSwitcher } from './RepoSwitcher.tsx'
|
||||
import {
|
||||
ActionButton, ConfirmDialog, IconButton, Menu, Notice, StatusBadge, TextArea, WorkbenchSection, invalidateGitStatus, statusOfXY,
|
||||
ActionButton, ConfirmDialog, IconButton, Menu, Notice, StatusBadge, TextArea, WorkbenchSection, WorkbenchStack, invalidateGitStatus, statusOfXY,
|
||||
useGitStatus, type GitFileStatus, type GitTone, type StatusTone,
|
||||
} from '../ui/index.ts'
|
||||
import { buildChangeTree, sumLineCounts, type ChangeDir, type ChangeFile, type ChangeNode } from './change-tree.ts'
|
||||
@@ -432,6 +432,8 @@ export function GitLens(props: GitLensProps) {
|
||||
const [graphRefresh, setGraphRefresh] = useState(0)
|
||||
const [changesOpen, setChangesOpen] = useState(true)
|
||||
const [graphOpen, setGraphOpen] = useState(true)
|
||||
/** Section weights of the changes/graph stack; kept in memory, the Git page has no settings key yet. */
|
||||
const [sectionWeights, setSectionWeights] = useState<Record<string, number>>({})
|
||||
/**
|
||||
* The open More Actions menu: the trigger's viewport corner (null = closed).
|
||||
* Its repo/worktree rows carry nested submenus, which the primitives anchor
|
||||
@@ -1152,8 +1154,18 @@ export function GitLens(props: GitLensProps) {
|
||||
)}
|
||||
|
||||
{isRepo && (
|
||||
<WorkbenchStack
|
||||
initialWeights={sectionWeights}
|
||||
onResize={setSectionWeights}
|
||||
sections={[
|
||||
{
|
||||
id: 'changes',
|
||||
title: t('gitChanges'),
|
||||
open: changesOpen,
|
||||
weight: 2,
|
||||
content: (
|
||||
<section className={css.changesSection} data-scm-section="changes">
|
||||
<WorkbenchSection title={t('gitChanges')} open={changesOpen} onOpenChange={setChangesOpen}
|
||||
<WorkbenchSection title={t('gitChanges')} open={changesOpen} onOpenChange={setChangesOpen} bodyClassName={css.changesBody}
|
||||
actions={<div className={css.scmActions}>
|
||||
<IconButton size="sm" icon={<IconCheckOutlineRegular size={14} />} label={t('commit')}
|
||||
disabled={!canCommit} onClick={commit} />
|
||||
@@ -1221,9 +1233,15 @@ export function GitLens(props: GitLensProps) {
|
||||
</div>}
|
||||
</WorkbenchSection>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{isRepo && <section className={graphOpen ? css.graphSection : undefined} data-scm-section="graph">
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'graph',
|
||||
title: t('gitGraph'),
|
||||
open: graphOpen,
|
||||
weight: 1,
|
||||
content: (
|
||||
<section className={graphOpen ? css.graphSection : undefined} data-scm-section="graph">
|
||||
<WorkbenchSection title={t('gitGraph')} open={graphOpen} onOpenChange={setGraphOpen}
|
||||
className={css.graphWorkbench} bodyClassName={css.graphArea}>
|
||||
{graphOpen && <div data-scm-graph className={css.graphArea}>
|
||||
@@ -1240,7 +1258,12 @@ export function GitLens(props: GitLensProps) {
|
||||
/>
|
||||
</div>}
|
||||
</WorkbenchSection>
|
||||
</section>}
|
||||
</section>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* A sibling of the scroller: usable even with both sections folded. */}
|
||||
|
||||
@@ -79,10 +79,12 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.changesSection { flex: none; }
|
||||
/* Bound the section's minimum, not its maximum: 28px header + 220px viewport.
|
||||
An automatic minimum would let the entire history stretch the outer scroller. */
|
||||
.graphSection { flex: 1; min-height: 248px; display: flex; flex-direction: column; }
|
||||
.changesSection { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
|
||||
/* The stack hands each open pane a flex height; the section's own body scrolls,
|
||||
so both sections keep their header while the list moves under it. */
|
||||
.changesBody { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
|
||||
.changesSection [data-scm-changes] { flex: 1; min-height: 0; overflow-y: auto; }
|
||||
.graphSection { display: flex; flex: 1; flex-direction: column; min-height: 248px; overflow: hidden; }
|
||||
.graphArea { flex: 1; display: flex; flex-direction: column; min-height: 0; }
|
||||
|
||||
.scmHeader { display: flex; align-items: center; min-height: 28px; padding: 0 6px; }
|
||||
|
||||
@@ -31,7 +31,7 @@ import { t } from '../../locales.ts'
|
||||
import { CluePacksSection } from './packs.tsx'
|
||||
import { ClueBrowser } from './browser.tsx'
|
||||
import { ClueHelpOverlay, clueHelpSeen, markClueHelpSeen } from './help.tsx'
|
||||
import { ActionButton, EmptyState, IconButton, SidebarToolbar, WorkbenchSection } from '../../ui/index.ts'
|
||||
import { ActionButton, EmptyState, IconButton, SidebarToolbar, WorkbenchSection, WorkbenchStack } from '../../ui/index.ts'
|
||||
import { openClueDetailWindow, type ClueDetailTarget } from '../windows/detail.tsx'
|
||||
import { openClueCollectionForTarget } from '../windows/collect.tsx'
|
||||
import { openPackManagementWindow } from '../windows/pack.tsx'
|
||||
@@ -41,7 +41,6 @@ import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx'
|
||||
import { SelectMenu } from '../../ui/SelectMenu.tsx'
|
||||
import design from '../../ui/design.module.css'
|
||||
import css from './clues-tab.module.css'
|
||||
import { SectionStack } from './SectionStack.tsx'
|
||||
|
||||
/** The plugin-settings key of the clue tab (one sparse blob). */
|
||||
const CLUE_TAB_SETTINGS_KEY = 'clues'
|
||||
@@ -378,7 +377,7 @@ export function CluesTab({ ctx, store, scope, visible }: CluesTabProps): ReactNo
|
||||
)}
|
||||
|
||||
{ready && browseWorkspaceId !== undefined && (
|
||||
<SectionStack key={browseWorkspaceId} initialWeights={sectionLayoutOf(settings).weights}
|
||||
<WorkbenchStack key={browseWorkspaceId} initialWeights={sectionLayoutOf(settings).weights}
|
||||
onResize={persistWeights} sections={[
|
||||
{ id: 'browse', title: t('clueViewBrowse'), open: sections.browse, weight: 3, content: (
|
||||
<WorkbenchSection
|
||||
|
||||
@@ -42,34 +42,6 @@
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
}
|
||||
.stack {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.stackPane { display: flex; flex: none; min-width: 0; }
|
||||
.stackPane[data-expanded='true'] { flex: 1 0 112px; min-height: 112px; }
|
||||
.sash {
|
||||
position: relative;
|
||||
flex: 0 0 7px;
|
||||
cursor: row-resize;
|
||||
touch-action: none;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
padding-block: 3px;
|
||||
background: var(--dsw-alias-border-l2) content-box;
|
||||
}
|
||||
.sash + .stackPane > div > div:first-child { border-top: 0; }
|
||||
.sash:hover, .sash:focus-visible, .sash:active {
|
||||
background-color: var(--ds-sidebar-accent);
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.stackPane[data-expanded='true'] { flex-basis: 156px; min-height: 156px; }
|
||||
.sash { flex-basis: 14px; padding-block: 6px 7px; }
|
||||
}
|
||||
/* The very first workbench section at the top of the tab needs no double top rule. */
|
||||
.browseSection > div:first-child {
|
||||
border-top: 0;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/** A vertical workbench stack. A sash redistributes only the two nearest open sections. */
|
||||
import { Fragment, useEffect, useId, useRef, useState, type ReactNode } from 'react'
|
||||
import { createFrameBatcher } from '../../frame-batcher.ts'
|
||||
import css from './clues-tab.module.css'
|
||||
import { createFrameBatcher } from '../frame-batcher.ts'
|
||||
import css from './workbench-stack.module.css'
|
||||
|
||||
interface Section {
|
||||
export interface WorkbenchStackSection {
|
||||
/** Stable id; also the persistence key of this section's weight. */
|
||||
id: string
|
||||
title: string
|
||||
open: boolean
|
||||
@@ -82,8 +83,8 @@ function Sash({ top, bottom, ratio, onPreview, onCommit }: {
|
||||
}} />
|
||||
}
|
||||
|
||||
export function SectionStack({ sections, initialWeights, onResize }: {
|
||||
sections: readonly Section[]
|
||||
export function WorkbenchStack({ sections, initialWeights, onResize }: {
|
||||
sections: readonly WorkbenchStackSection[]
|
||||
initialWeights?: Record<string, unknown>
|
||||
onResize(weights: Record<string, number>): void
|
||||
}): ReactNode {
|
||||
@@ -94,7 +95,7 @@ export function SectionStack({ sections, initialWeights, onResize }: {
|
||||
})))
|
||||
const opened = sections.filter(section => section.open)
|
||||
const openWeight = opened.reduce((sum, section) => sum + (weights[section.id] ?? section.weight), 0)
|
||||
let previous: Section | undefined
|
||||
let previous: WorkbenchStackSection | undefined
|
||||
return <div className={css.stack}>
|
||||
{sections.map(section => {
|
||||
const top = section.open ? previous : undefined
|
||||
@@ -9,6 +9,7 @@ export {
|
||||
} from './kit.tsx'
|
||||
export { LoadingIndicator, type LoadingIndicatorProps } from './LoadingIndicator.tsx'
|
||||
export { WorkbenchSection, type WorkbenchSectionProps } from './WorkbenchSection.tsx'
|
||||
export { WorkbenchStack, type WorkbenchStackSection } from './WorkbenchStack.tsx'
|
||||
export { SelectMenu, type SelectMenuProps, type SelectOption } from './SelectMenu.tsx'
|
||||
export { TextInput, TextArea, NumberInput, Checkbox, ToggleSwitch, Tabs, SettingRow, type TabOption } from './controls.tsx'
|
||||
export {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/** A vertical workbench stack: adjacent open sections share the height through a draggable sash. */
|
||||
.stack {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.stackPane { display: flex; flex: none; min-width: 0; }
|
||||
.stackPane[data-expanded='true'] { flex: 1 0 112px; min-height: 112px; }
|
||||
.sash {
|
||||
position: relative;
|
||||
flex: 0 0 7px;
|
||||
cursor: row-resize;
|
||||
touch-action: none;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
padding-block: 3px;
|
||||
background: var(--dsw-alias-border-l2) content-box;
|
||||
}
|
||||
.sash + .stackPane > div > div:first-child { border-top: 0; }
|
||||
.sash:hover, .sash:focus-visible, .sash:active {
|
||||
background-color: var(--ds-sidebar-accent);
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.stackPane[data-expanded='true'] { flex-basis: 156px; min-height: 156px; }
|
||||
.sash { flex-basis: 14px; padding-block: 6px 7px; }
|
||||
}
|
||||
Reference in new issue
Block a user