Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/right pane toggle handle: refactor
Adorian Doran37fa5dcc87e3
diff --git a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.cssindex 7c833cb8f5..d032d4667b 100644--- a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css+++ b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css@@ -1,29 +1,19 @@-/* Minimal functional styling only — refine visuals later. */--/* Always reserve the 12px handle strip on the left of the pane, even when it is- collapsed to no content, and give the handle a positioned ancestor to anchor to. */-body.experimental-feature-new-layout #right-pane {- position: relative;- min-width: 12px;- padding-inline-start: 12px;-}--/* Doubled class to win specificity over the shared `.icon-action` button rules. */-body.experimental-feature-new-layout #right-pane .right-pane-toggle-handle.right-pane-toggle-handle {- position: absolute;- inset-inline-start: 0; /* Inside the pane's left edge so `overflow: auto` does not clip it. */- top: 0;- width: 12px;- height: 100%;- z-index: 10;+/* Minimal functional styling only — refine visuals later.+ The handle is a flex sibling of #right-pane inside #vertical-main-container,+ so it reserves its own 12px column and fully owns its background. */+.right-pane-toggle-handle {+ /* Inherited from #right-pane-wrapper (RightPanelContainer.css); fallback for safety. */+ flex: 0 0 var(--right-pane-handle-width, 12px);display: flex;align-items: center;justify-content: center;padding: 0;- border-radius: 0;+ border: 0;+ background: transparent;+ font-size: 16px;cursor: pointer;}-body.experimental-feature-new-layout #right-pane .right-pane-toggle-handle.right-pane-toggle-handle:hover {+.right-pane-toggle-handle:hover {background-color: var(--hover-item-background-color);}diff --git a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsxindex 0447e81318..a0518a1cfb 100644--- a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx+++ b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx@@ -50,7 +50,7 @@ export default function RightPaneToggleHandle() {<buttonref={buttonRef}class={clsx(- "right-pane-toggle-handle icon-action bx",+ "right-pane-toggle-handle bx",rightPaneVisible ? "bx-chevron-right" : "bx-chevron-left",rightPaneVisible ? "right-pane-toggle-handle-action-collapse" : "right-pane-toggle-handle-action-expand")}diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.cssindex 8351868cb3..fa5b506c4c 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css@@ -1,4 +1,19 @@+/* Split target: lays out the toggle handle (fixed) next to the panel (filling).+ When the pane is collapsed, Split sets no width, so the wrapper must not shrink past+ the handle. `flex-shrink: 0` + a `min-width` of the handle width keep the handle strip+ visible against #center-pane's growth. The handle (RightPaneToggleHandle.css) inherits+ `--right-pane-handle-width`; keep `minSize` in RightPanelContainer.tsx in sync too. */+body.experimental-feature-new-layout #right-pane-wrapper {+ --right-pane-handle-width: 12px;+ display: flex;+ flex-direction: row;+ flex-shrink: 0;+ min-width: var(--right-pane-handle-width);+}+body.experimental-feature-new-layout #right-pane {+ flex: 1;+ min-width: 0;display: flex;flex-direction: column;diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex c512e60a4e..65c4b87664 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -26,6 +26,9 @@ import RightPanelWidget from "./RightPanelWidget";import TableOfContents from "./TableOfContents";const MIN_WIDTH_PERCENT = 5;+const RIGHT_PANE_MIN_CONTENT_PX = 180;+// Keep in sync with `--right-pane-handle-width` in RightPanelContainer.css.+const HANDLE_WIDTH_PX = 12;interface RightPanelWidgetDefinition {el: VNode;@@ -46,23 +49,29 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare}, []));return (- <div id="right-pane">+ <div id="right-pane-wrapper">+ {/* The wrapper is the split target, so the resize gutter stays on the outer+ boundary (between #center-pane and the wrapper). The handle is a sibling of+ #right-pane — it owns its background and isn't clipped by the pane's overflow —+ and sits just inside the gutter, against the panel. */}<RightPaneToggleHandle />- {rightPaneVisible && (- items.length > 0 ? (- items- ) : (- <NoItems- icon="bx bx-sidebar"- text={t("right_pane.empty_message")}- >- <Button- text={t("right_pane.empty_button")}- triggerCommand="toggleRightPane"- />- </NoItems>- )- )}+ <div id="right-pane">+ {rightPaneVisible && (+ items.length > 0 ? (+ items+ ) : (+ <NoItems+ icon="bx bx-sidebar"+ text={t("right_pane.empty_message")}+ >+ <Button+ text={t("right_pane.empty_button")}+ triggerCommand="toggleRightPane"+ />+ </NoItems>+ )+ )}+ </div></div>);}@@ -146,10 +155,10 @@ function useSplit(visible: boolean) {// We are intentionally omitting useTriliumOption to avoid re-render due to size change.const rightPaneWidth = Math.max(MIN_WIDTH_PERCENT, options.getInt("rightPaneWidth") ?? MIN_WIDTH_PERCENT);- const splitInstance = Split(["#center-pane", "#right-pane"], {+ const splitInstance = Split(["#center-pane", "#right-pane-wrapper"], {sizes: [100 - rightPaneWidth, rightPaneWidth],gutterSize: DEFAULT_GUTTER_SIZE,- minSize: [300, 180],+ minSize: [300, RIGHT_PANE_MIN_CONTENT_PX + HANDLE_WIDTH_PX], // panel content + handle strip.rtl: glob.isRtl,onDragEnd: (sizes) => options.save("rightPaneWidth", Math.round(sizes[1]))});