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
style/right pane peek button: match the translucency of the rightmost split
Adorian Doran13b46b3593cb
diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.tsindex 2dd9ea4143..0eb4c0502d 100644--- a/apps/client/src/widgets/containers/split_note_container.ts+++ b/apps/client/src/widgets/containers/split_note_container.ts@@ -95,6 +95,8 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {// move the note context rendered widget after the originating widgetthis.$widget.find(`[data-ntx-id="${noteContext.ntxId}"]`).insertAfter(this.$widget.find(`[data-ntx-id="${ntxId}"]`));++ this.refresh();}@@ -166,6 +168,10 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {// reorder the note context widgetsthis.$widget.find(`[data-ntx-id="${ntxIds[leftIndex]}"]`).insertAfter(this.$widget.find(`[data-ntx-id="${ntxIds[leftIndex + 1]}"]`));+ // the reorder changes which split is last; the activation below may be a no-op (the moved+ // context can already be active), so it can't be relied on to refresh.+ this.refresh();+// activate context that now contains the original noteawait appContext.tabManager.activateNoteContext(isMovingLeft ? ntxIds[leftIndex + 1] : ntxIds[leftIndex]);@@ -192,6 +198,9 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {}splitService.delNoteSplitResizer(ntxIds);++ // closing a non-active split fires no activation, so nothing else would refresh here+ this.refresh();}contextsReopenedEvent({ ntxId, mainNtxId, afterNtxId }: EventData<"contextsReopened">) {@@ -204,6 +213,8 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {this.$widget.find(`[data-ntx-id="${mainNtxId}"]`).insertBefore(this.$widget.find(`[data-ntx-id="${beforeNtxId}"]`));}++ this.refresh();}async refresh() {@@ -213,6 +224,13 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {for (const child of this.children as NoteContextAwareWidget[]) {child.$widget.toggleClass("active", !!child.noteContext?.isActive());}++ // Mark the rightmost visible split. CSS can't reach a split from outside #center-pane, so+ // siblings of it (the right pane peek button) need this hook to match its background.+ // Read the DOM, not `this.children`: splits are reordered in place, the array is not.+ const $visibleSplits = this.$widget.children(".note-split:not(.hidden-ext)");+ $visibleSplits.removeClass("last-visible");+ $visibleSplits.last().addClass("last-visible");}toggleInt(show: boolean) {} // not neededdiff --git a/apps/client/src/widgets/note_wrapper.spec.ts b/apps/client/src/widgets/note_wrapper.spec.tsindex 59cb8d5fd7..17d1c1f86c 100644--- a/apps/client/src/widgets/note_wrapper.spec.ts+++ b/apps/client/src/widgets/note_wrapper.spec.ts@@ -1,7 +1,25 @@import { describe, expect, it } from "vitest";import { buildNote } from "../test/easy-froca";-import { isAlwaysFullWidthByType, isFullWidthNote } from "./note_wrapper";+import NoteWrapperWidget, { isAlwaysFullWidthByType, isFullWidthNote } from "./note_wrapper";++describe("NoteWrapperWidget", () => {+ it("preserves the classes owned by SplitNoteContainer through the class reset in refresh()", () => {+ const widget = new NoteWrapperWidget();+ widget.render();+ widget.$widget.addClass("active last-visible");+ widget.toggleExt(false);++ widget.refresh();++ expect(widget.$widget.hasClass("active")).toBe(true);+ expect(widget.$widget.hasClass("last-visible")).toBe(true);+ expect(widget.$widget.hasClass("hidden-ext")).toBe(true);+ // Without a note context, the split renders as empty — the note-derived classes still apply.+ expect(widget.$widget.hasClass("note-split")).toBe(true);+ expect(widget.$widget.hasClass("empty-note")).toBe(true);+ });+});describe("isAlwaysFullWidthByType", () => {it("is false for a regular text note regardless of the fullContentWidth label", () => {diff --git a/apps/client/src/widgets/note_wrapper.ts b/apps/client/src/widgets/note_wrapper.tsindex 37712349fc..9d3c5df48e 100644--- a/apps/client/src/widgets/note_wrapper.ts+++ b/apps/client/src/widgets/note_wrapper.ts@@ -38,16 +38,14 @@ export default class NoteWrapperWidget extends FlexContainer<BasicWidget> {}refresh() {- const isHiddenExt = this.isHiddenExt(); // preserve through class reset- const isActive = this.$widget.hasClass("active");+ // These are owned by SplitNoteContainer, not by the note — preserve them through the reset below.+ const isHiddenExt = this.isHiddenExt();+ const containerClasses = CONTAINER_OWNED_CLASSES.filter((cls) => this.$widget.hasClass(cls));this.$widget.removeClass();this.toggleExt(!isHiddenExt);-- if (isActive) {- this.$widget.addClass("active");- }+ this.$widget.addClass(containerClasses.join(" "));this.$widget.addClass("component note-split");@@ -112,6 +110,9 @@ export default class NoteWrapperWidget extends FlexContainer<BasicWidget> {}}+/** Classes set on the split by `SplitNoteContainer`, based on the split's position among its siblings. */+const CONTAINER_OWNED_CLASSES = [ "active", "last-visible" ];+/*** Whether a note is full width purely because of its type (e.g. canvas, collections, media),* irrespective of the `fullContentWidth` label. For these notes the label has no effect, so thediff --git a/apps/client/src/widgets/sidebar/RightPanePeekButton.css b/apps/client/src/widgets/sidebar/RightPanePeekButton.cssindex fa4a75b396..c43d897104 100644--- a/apps/client/src/widgets/sidebar/RightPanePeekButton.css+++ b/apps/client/src/widgets/sidebar/RightPanePeekButton.css@@ -9,6 +9,11 @@--peek-button-expand-collapse-background-color: var(--hover-item-background-color);}+/* The button follows the translucency of the rightmost split. */+body.desktop.background-effects #center-pane:has(.note-split.last-visible.bgfx) ~ .right-pane-peek-button {+ --peek-button-expand-background-color: var(--center-pane-background-color-bgfx, var(--main-background-color));+}+/* The peek button is absolutely positioned in a reserved gutter on the right edge of#vertical-main-container, so it stays fixed at the viewport's right side and fullyowns its background — independent of whether the right pane is open or collapsed. */