Files
Netcatty/components/vault/VaultPageHeader.tsx
T
27a55f8b40 fix(window): fit main window to half-screen tiling cells (#4254)
* fix(window): fit main window to half-screen tiling cells

macOS and Windows window tiling keep the app's minimum size when the
requested cell is smaller, so the 1100x640 minimum pushed half-tiled
windows past the screen edge. Cap the effective minimum at half the
display work area minus the macOS tiling margin, and pull restored
bounds back inside the work area while preserving windows that span
adjacent displays.

Let Vault page headers wrap their action buttons on narrow half-screen
windows instead of clipping them.

Tests: window manager suite (127) and Vault header/layout tests pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(vault): allow nested VaultPageHeader action groups to wrap

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-11-23 17:04:14 +08:00

84 lines
2.3 KiB
TypeScript

import { Search } from "lucide-react";
import React from "react";
import { cn } from "../../lib/utils";
import { Input } from "../ui/input";
interface VaultPageHeaderProps {
children: React.ReactNode;
className?: string;
contentClassName?: string;
dataSection?: string;
}
export function VaultPageHeader({
children,
className,
contentClassName,
dataSection,
}: VaultPageHeaderProps) {
return (
<header
className={cn(
"relative shrink-0 bg-background/95 app-drag after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:origin-bottom after:[transform:scaleY(.5)] after:bg-border/40 after:content-['']",
className,
)}
data-section={dataSection}
>
<div
className={cn(
// Wrap instead of clipping when the window is tiled to a narrow
// half-screen cell: the search row keeps its controls and the
// fixed-width action buttons move to a second row.
"min-h-14 px-4 py-2 flex flex-wrap items-center gap-x-3 gap-y-2 app-no-drag",
contentClassName,
)}
>
{children}
</div>
</header>
);
}
interface VaultHeaderSearchProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "className"> {
className?: string;
inputClassName?: string;
rightAdornment?: React.ReactNode;
}
export function VaultHeaderSearch({
className,
inputClassName,
rightAdornment,
...props
}: VaultHeaderSearchProps) {
return (
<div className={cn("relative min-w-[100px]", className)}>
<Search
size={14}
className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
/>
<Input
{...props}
className={cn(
"pl-9 h-10 bg-secondary border-border/60 text-sm",
rightAdornment && "pr-9",
inputClassName,
)}
/>
{rightAdornment && (
<div className="absolute right-3 top-1/2 -translate-y-1/2">
{rightAdornment}
</div>
)}
</div>
);
}
export const vaultHeaderSecondaryButtonClass =
"h-10 px-3 gap-2 bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40";
export const vaultHeaderIconButtonClass = "h-10 w-10";
export const vaultSectionTitleClass = "text-base font-semibold text-muted-foreground";