refactor: open search from titlebar command

This commit is contained in:
2026-08-05 00:03:33 +02:00
parent e910a53def
commit 3442b5fa4e
7 changed files with 47 additions and 82 deletions
+3 -14
View File
@@ -33,16 +33,9 @@ export function calculateSearchOverlayLayout(
const mobile = viewportWidth < MOBILE_BREAKPOINT;
const margin = mobile ? MOBILE_MARGIN : DESKTOP_MARGIN;
const width = Math.max(1, Math.min(DESKTOP_PANEL_WIDTH, viewportWidth - margin * 2));
const centeredLeft = anchor.left + anchor.width / 2 - width / 2;
const left = mobile
? margin
: clamp(centeredLeft, margin, Math.max(margin, viewportWidth - width - margin));
const inputWidth = mobile
? width
: Math.min(Math.max(1, anchor.width), width);
const inputOffset = mobile
? 0
: clamp(anchor.left - left, 0, Math.max(0, width - inputWidth));
const left = Math.max(margin, (viewportWidth - width) / 2);
const inputWidth = width;
const inputOffset = 0;
const top = Math.max(0, anchor.top);
const inputHeight = Math.max(1, anchor.height);
const availableResultsHeight = viewportHeight - top - inputHeight - RESULTS_GAP - margin;
@@ -89,7 +82,3 @@ function normalizePath(value: string): string {
const normalized = `/${String(value || "").trim().replace(/^\/+|\/+$/g, "")}`;
return normalized === "/" ? normalized : normalized.replace(/\/+$/g, "");
}
function clamp(value: number, minimum: number, maximum: number): number {
return Math.min(Math.max(value, minimum), maximum);
}