Skip to content

Commit

Permalink
view cue for horizontal tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdc committed Feb 17, 2025
1 parent 0321cf8 commit 3f17a76
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/NavigationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/components/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
24 changes: 24 additions & 0 deletions src/styles/TabIndexViewCue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 3f17a76

Please sign in to comment.