mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-08-11 21:50:24 +02:00
refactor: cleanup
This commit is contained in:
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { GoPlus } from "react-icons/go";
|
||||
import { LuChevronLeft, LuChevronRight, LuSearch, LuX } from "react-icons/lu";
|
||||
import { useWindowDecorations } from "@/hooks/use-window-decorations";
|
||||
import { getCurrentOS } from "@/lib/browser-utils";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { GroupWithCount } from "@/types";
|
||||
@@ -59,8 +60,14 @@ const HomeHeader = ({
|
||||
}, []);
|
||||
|
||||
const isMacOS = platform === "macos";
|
||||
const isLinux = platform === "linux";
|
||||
const showProfileToolbar = !pageTitle;
|
||||
|
||||
// Same hook the controls use, so the reserved space can never disagree with
|
||||
// what is actually drawn.
|
||||
const decorations = useWindowDecorations();
|
||||
const linuxLayout = decorations.clientSide ? decorations.layout : null;
|
||||
|
||||
// Press-and-hold drag: any pixel of the sys-bar becomes a drag handle after
|
||||
// HOLD_MS, but quick clicks still reach buttons/inputs underneath.
|
||||
const holdTimeoutRef = useRef<number | null>(null);
|
||||
@@ -179,14 +186,29 @@ const HomeHeader = ({
|
||||
onPointerCancel={handlePointerEnd}
|
||||
onDoubleClick={handleDoubleClick}
|
||||
className={cn(
|
||||
"flex h-11 items-center gap-2 border-b border-border bg-card pl-3 select-none",
|
||||
"flex h-11 items-center gap-2 border-b border-border bg-card select-none",
|
||||
// Windows: WindowDragArea renders three 44px native-style controls
|
||||
// (minimize + maximize/restore + close) fixed at top-right with
|
||||
// z-50, total 132px wide. Reserve 144px on the right edge so the
|
||||
// "+ New" button and search input clear them with a few pixels of
|
||||
// breathing room and never sit underneath the controls.
|
||||
isWindows ? "pr-[144px]" : "pr-3",
|
||||
isWindows ? "pl-3 pr-[144px]" : null,
|
||||
// Linux reserves its space through the inline style below, because the
|
||||
// desktop chooses which side the controls sit on and how many there
|
||||
// are. Everything else keeps the plain symmetric padding.
|
||||
!isWindows && !isLinux ? "pl-3 pr-3" : null,
|
||||
)}
|
||||
style={
|
||||
isLinux
|
||||
? {
|
||||
// Each control is 44px wide; add the usual 12px gutter. Before
|
||||
// the layout resolves, fall back to the gutter alone rather than
|
||||
// to no padding, which would visibly shift the content.
|
||||
paddingLeft: (linuxLayout?.left.length ?? 0) * 44 + 12,
|
||||
paddingRight: (linuxLayout?.right.length ?? 0) * 44 + 12,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{isMacOS && (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user