Skip to content

Commit

Permalink
feature/auto-hide-tab-bar refactored code and updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rritik772 authored and Ritik Ranjan committed Dec 16, 2024
1 parent 0da0a75 commit b3720b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/docs/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ wsh editconfig
| 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) |
| window:maxtabcachesize | int | number of tabs to cache. when tabs are cached, switching between them is very fast. (defaults to 10) |
| window:showmenubar | bool | set to use the OS-native menu bar (Windows and Linux only, requires app restart) |
| window:autohidetabsbar | bool | auto hide tab bar based on true or false
| window:autohidetabsbar | bool | auto hide tab bar based on true or false (requires restart)
| window:nativetitlebar | bool | set to use the OS-native title bar, rather than the overlay (Windows and Linux only, requires app restart) |
| window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) |
| telemetry:enabled | bool | set to enable/disable telemetry |
Expand Down
10 changes: 6 additions & 4 deletions frontend/app/tab/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
const isFullScreen = useAtomValue(atoms.isFullScreen);

const settings = useAtomValue(atoms.settingsAtom);
const autoHideTabsBar = useRef<boolean>(settings["window:autohidetabsbar"]);
const autoHideTabsBar = settings?.["window:autohidetabsbar"] ?? false;

let prevDelta: number;
let prevDragDirection: string;
Expand All @@ -185,13 +185,15 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
const tabBarHeight = tabBar.clientHeight + 1;

if (currentY < 10) tabBar.style.top = '0px';
if (autoHideTabsBar.current && currentY > tabBarHeight) tabBar.style.top = `-${tabBarHeight}px`;
if (autoHideTabsBar && currentY > tabBarHeight) tabBar.style.top = `-${tabBarHeight}px`;
};

useEffect(() => {
if (!autoHideTabsBar) return;

document.addEventListener("mousemove", handleAutoHideTabsBar);
return () => document.removeEventListener("mousemove", handleAutoHideTabsBar);
}, [])
}, [autoHideTabsBar])

// Update refs when tabIds change
useEffect(() => {
Expand Down Expand Up @@ -669,7 +671,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
title: "Add Tab",
};
return (
<div ref={tabbarWrapperRef} className={`tab-bar-wrapper${autoHideTabsBar.current ? '-auto-hide' : ''}`}>
<div ref={tabbarWrapperRef} className={`tab-bar-wrapper${autoHideTabsBar ? '-auto-hide' : ''}`}>
<WindowDrag ref={draggerLeftRef} className="left" />
{appMenuButton}
{devLabel}
Expand Down

0 comments on commit b3720b3

Please sign in to comment.