From 3f17a7632f9b1c938406b3bd9b2660cc0e22f638 Mon Sep 17 00:00:00 2001 From: oxdc <29519076+oxdc@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:57:50 +0800 Subject: [PATCH] view cue for horizontal tabs --- src/components/NavigationContainer.tsx | 2 ++ src/components/Tab.tsx | 8 ++++++++ src/styles/TabIndexViewCue.scss | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/components/NavigationContainer.tsx b/src/components/NavigationContainer.tsx index f739923..808b67f 100644 --- a/src/components/NavigationContainer.tsx +++ b/src/components/NavigationContainer.tsx @@ -184,6 +184,7 @@ export const NavigationContainer = () => { setTimeout(() => { if (useViewState.getState().hasCtrlKeyPressed) { ref.current?.toggleClass("tab-index-view-cue", true); + document.body.toggleClass("vt-tab-index-view-cue", true); scorllToViewCueFirstTab(app); } }, VIEW_CUE_DELAY); @@ -197,6 +198,7 @@ export const NavigationContainer = () => { plugin.registerDomEvent(window, "keyup", () => { setCtrlKeyState(false); ref.current?.toggleClass("tab-index-view-cue", false); + document.body.toggleClass("vt-tab-index-view-cue", false); }); plugin.registerDomEvent(document, "dblclick", (event) => { makeDblclickedFileNonEphemeral(app, event); diff --git a/src/components/Tab.tsx b/src/components/Tab.tsx index 6dec1f4..283ff0a 100644 --- a/src/components/Tab.tsx +++ b/src/components/Tab.tsx @@ -512,6 +512,14 @@ export const Tab = ({ viewCueIndex === VIEW_CUE_PREV || (viewCueIndex === index && index === 1); registerViewCueTab(leaf, ref.current, isFirstTab); + if (leaf.tabHeaderInnerTitleEl) { + if (viewCueIndex) { + leaf.tabHeaderInnerTitleEl.dataset.index = + viewCueIndex.toString(); + } else { + delete leaf.tabHeaderInnerTitleEl.dataset.index; + } + } }, [viewCueIndex, ref]); const previewTab = ( diff --git a/src/styles/TabIndexViewCue.scss b/src/styles/TabIndexViewCue.scss index 2e563ee..61b9032 100644 --- a/src/styles/TabIndexViewCue.scss +++ b/src/styles/TabIndexViewCue.scss @@ -26,3 +26,27 @@ } } } + +body.vt-tab-index-view-cue { + .workspace-tab-header-inner-title { + &[data-index]::before { + content: attr(data-index); + display: inline-block; + width: var(--size-4-4); + height: var(--size-4-4); + line-height: var(--size-4-4); + background: var(--background-primary); + border-radius: var(--radius-s); + border: var(--border-width) solid; + text-align: center; + left: var(--size-2-1); + z-index: var(--layer-tooltip); + margin-right: var(--size-4-1); + } + + &[data-index="→"]::before, + &[data-index="←"]::before { + background: var(--background-secondary); + } + } +}