Skip to content

Commit 9748972

Browse files
author
Ritik Ranjan
committed
feature/auto-hide-tab-bar review comment resolved
window:autohidetabsbar --> window:autohidetabbar added invisible tab bar above and made it visible on hover using mouseenter and invisible mouseleave docs updated css updated
1 parent 3fd9d97 commit 9748972

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

docs/docs/config.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ wsh editconfig
6868
| window:magnifiedblockblursecondarypx | int | change the blur in CSS pixels that is applied to the visible portions of non-magnified blocks when a block is magnified (see [backdrop-filter](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter) for more info on how this gets applied) |
6969
| window:maxtabcachesize | int | number of tabs to cache. when tabs are cached, switching between them is very fast. (defaults to 10) |
7070
| window:showmenubar | bool | set to use the OS-native menu bar (Windows and Linux only, requires app restart) |
71-
| window:autohidetabsbar | bool | auto hide tab bar based on true or false (requires restart)
71+
| window:autohidetabbar | bool | show and hide the tab bar automatically when the mouse moves near the top of the window
7272
| window:nativetitlebar | bool | set to use the OS-native title bar, rather than the overlay (Windows and Linux only, requires app restart) |
7373
| window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) |
7474
| telemetry:enabled | bool | set to enable/disable telemetry |

frontend/app/tab/tabbar.scss

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
margin-bottom: 20px;
2525
}
2626

27-
.tab-bar-wrapper {
27+
.tab-bar-wrapper-always-visible {
2828
padding-top: 6px;
2929
position: relative;
30+
opacity: 1;
3031
}
3132

3233
.tab-bar-wrapper-auto-hide {
33-
top: -20px;
3434
left: 0;
3535
right: 0;
3636

@@ -39,15 +39,20 @@
3939

4040
position: fixed;
4141
z-index: 1000;
42+
43+
opacity: 0;
4244
background: transparent;
4345
backdrop-filter: blur(10px);
44-
border-radius: 12px;
46+
border-radius: 6px;
4547

46-
transition: top 0.3s ease;
48+
transition: opacity 0.3s ease, top 0.3s ease;
4749
}
4850

49-
.tab-bar-wrapper,
50-
.tab-bar-wrapper-auto-hide {
51+
.tab-bar-wrapper-auto-hide-visible {
52+
opacity: 1;
53+
}
54+
55+
.tab-bar-wrapper {
5156
user-select: none;
5257
display: flex;
5358
flex-direction: row;

frontend/app/tab/tabbar.tsx

+31-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { deleteLayoutModelForTab } from "@/layout/index";
88
import { atoms, createTab, getApi, globalStore, isDev, PLATFORM, setActiveTab } from "@/store/global";
99
import { fireAndForget } from "@/util/util";
1010
import { useAtomValue } from "jotai";
11+
import clsx from "clsx";
1112
import { OverlayScrollbars } from "overlayscrollbars";
1213
import { createRef, memo, useCallback, useEffect, useRef, useState } from "react";
1314
import { debounce } from "throttle-debounce";
@@ -174,26 +175,45 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
174175
const isFullScreen = useAtomValue(atoms.isFullScreen);
175176

176177
const settings = useAtomValue(atoms.settingsAtom);
177-
const autoHideTabsBar = settings?.["window:autohidetabsbar"] ?? false;
178+
const autoHideTabBar = settings?.["window:autohidetabbar"] ?? false;
178179

179180
let prevDelta: number;
180181
let prevDragDirection: string;
181182

182-
const handleAutoHideTabsBar = (event: MouseEvent) => {
183-
const currentY = event.clientY;
183+
const handleAutoHideTabBar = (event: MouseEvent) => {
184184
const tabBar = tabbarWrapperRef.current;
185-
const tabBarHeight = tabBar.clientHeight + 1;
185+
const tabBarHeight = tabBar?.clientHeight + 1;
186186

187-
if (currentY < 10) tabBar.style.top = '0px';
188-
if (autoHideTabsBar && currentY > tabBarHeight) tabBar.style.top = `-${tabBarHeight}px`;
187+
if (event.type === 'mouseenter') {
188+
tabBar.style.top = '0px';
189+
tabBar.addEventListener("mouseleave", handleAutoHideTabBar);
190+
tabBar.classList.add('tab-bar-wrapper-auto-hide-visible')
191+
}
192+
193+
if (event.type === 'mouseleave') {
194+
tabBar.style.top = `-${tabBarHeight - 10}px`;
195+
tabBar.removeEventListener("mouseleave", handleAutoHideTabBar);
196+
tabBar.classList.remove('tab-bar-wrapper-auto-hide-visible')
197+
}
189198
};
190199

191200
useEffect(() => {
192-
if (!autoHideTabsBar) return;
201+
const tabBar = tabbarWrapperRef.current;
202+
if (!autoHideTabBar) {
203+
tabBar.style.top = '0px';
204+
return;
205+
}
206+
207+
const tabBarHeight = tabBar?.clientHeight + 1;
208+
if (autoHideTabBar) {
209+
tabbarWrapperRef.current.style.top = `-${tabBarHeight - 10}px`
210+
}
193211

194-
document.addEventListener("mousemove", handleAutoHideTabsBar);
195-
return () => document.removeEventListener("mousemove", handleAutoHideTabsBar);
196-
}, [autoHideTabsBar])
212+
tabbarWrapperRef.current.addEventListener("mouseenter", handleAutoHideTabBar);
213+
return () => {
214+
tabbarWrapperRef.current.removeEventListener("mouseenter", handleAutoHideTabBar);
215+
}
216+
}, [autoHideTabBar])
197217

198218
// Update refs when tabIds change
199219
useEffect(() => {
@@ -671,7 +691,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
671691
title: "Add Tab",
672692
};
673693
return (
674-
<div ref={tabbarWrapperRef} className={`tab-bar-wrapper${autoHideTabsBar ? '-auto-hide' : ''}`}>
694+
<div ref={tabbarWrapperRef} className={clsx('tab-bar-wrapper', {'tab-bar-wrapper-auto-hide': autoHideTabBar, 'tab-bar-wrapper-always-visible': !autoHideTabBar})}>
675695
<WindowDrag ref={draggerLeftRef} className="left" />
676696
{appMenuButton}
677697
{devLabel}

frontend/types/gotypes.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ declare global {
649649
"window:reducedmotion"?: boolean;
650650
"window:tilegapsize"?: number;
651651
"window:showmenubar"?: boolean;
652-
"window:autohidetabsbar"?: boolean;
652+
"window:autohidetabbar"?: boolean;
653653
"window:nativetitlebar"?: boolean;
654654
"window:disablehardwareacceleration"?: boolean;
655655
"window:maxtabcachesize"?: number;

pkg/wconfig/metaconsts.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const (
6161
ConfigKey_WindowReducedMotion = "window:reducedmotion"
6262
ConfigKey_WindowTileGapSize = "window:tilegapsize"
6363
ConfigKey_WindowShowMenuBar = "window:showmenubar"
64-
ConfigKey_WindowAutoHideTabsBar = "window:autohidetabsbar"
64+
ConfigKey_WindowAutoHideTabBar = "window:autohidetabbar"
6565
ConfigKey_WindowNativeTitleBar = "window:nativetitlebar"
6666
ConfigKey_WindowDisableHardwareAcceleration = "window:disablehardwareacceleration"
6767
ConfigKey_WindowMaxTabCacheSize = "window:maxtabcachesize"

pkg/wconfig/settingsconfig.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type SettingsType struct {
8888
WindowReducedMotion bool `json:"window:reducedmotion,omitempty"`
8989
WindowTileGapSize *int64 `json:"window:tilegapsize,omitempty"`
9090
WindowShowMenuBar bool `json:"window:showmenubar,omitempty"`
91-
WindowAutoHideTabsBar bool `json:"window:autohidetabsbar,omitempty"`
91+
WindowAutoHideTabBar bool `json:"window:autohidetabbar,omitempty"`
9292
WindowNativeTitleBar bool `json:"window:nativetitlebar,omitempty"`
9393
WindowDisableHardwareAcceleration bool `json:"window:disablehardwareacceleration,omitempty"`
9494
WindowMaxTabCacheSize int `json:"window:maxtabcachesize,omitempty"`

0 commit comments

Comments
 (0)