authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:09:42-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:09:42-07:00
logeda0cec92398a4097958b55accaa59fdd178a977
tree99dade2e9b50a07ffd1c3c2898b61db10e2a9810
parent1782a2af44a7630f184a05dbcf788e6121da2554
signature Signed by PGP key B5690EEEBB952194

refactor(mobile): remove unused layout calculations (#9974)


2 files changed, 0 insertions(+), 57 deletions(-)

apps/mobile/src/lib/layout.test.ts-19
......@@ -2,11 +2,9 @@ import { describe, expect, it } from "vite-plus/test";
22
33import {
44 constrainAuxiliaryPaneWidth,
5 constrainPrimarySidebarWidth,
65 deriveCenteredContentHorizontalPadding,
76 deriveFileInspectorPaneLayout,
87 deriveLayout,
9 deriveStableFormSheetDetent,
108 deriveThreadFeedInitialContentInset,
119 deriveThreadWorkLogSizing,
1210 deriveWorkspacePaneLayout,
......@@ -75,12 +73,6 @@ describe("deriveThreadFeedInitialContentInset", () => {
7573});
7674
7775describe("resizable pane constraints", () => {
78 it("keeps a preferred sidebar width across large windows and clamps it in a narrow split view", () => {
79 expect(constrainPrimarySidebarWidth(430, 1_366)).toBe(430);
80 expect(constrainPrimarySidebarWidth(430, 744)).toBe(384);
81 expect(constrainPrimarySidebarWidth(100, 1_366)).toBe(280);
82 });
83
8476 it("preserves a useful main pane while constraining a trailing pane", () => {
8577 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 1_100 })).toBe(440);
8678 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 900 })).toBe(340);
......@@ -392,14 +384,3 @@ describe("deriveWorkspacePaneLayout", () => {
392384 });
393385 });
394386});
395
396describe("deriveStableFormSheetDetent", () => {
397 it.each([
398 { height: 1_194, expected: 0.62 },
399 { height: 834, expected: 0.863 },
400 { height: 600, expected: 0.893 },
401 { height: 0, expected: 0.92 },
402 ])("derives a stable sheet detent for height $height", ({ height, expected }) => {
403 expect(deriveStableFormSheetDetent(height)).toBe(expected);
404 });
405});
apps/mobile/src/lib/layout.ts-38
......@@ -16,7 +16,6 @@ export const SPLIT_LAYOUT_MIN_WIDTH = 720;
1616export const SPLIT_LAYOUT_MIN_HEIGHT = 600;
1717
1818export const SPLIT_SIDEBAR_MIN_WIDTH = 280;
19export const SPLIT_SIDEBAR_MAX_WIDTH = 460;
2019const SPLIT_SIDEBAR_DEFAULT_MAX_WIDTH = 380;
2120
2221export const AUXILIARY_PANE_MIN_CONTENT_WIDTH = 960;
......@@ -50,10 +49,6 @@ export const AUXILIARY_PANE_MAX_WIDTH = 480;
5049const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
5150const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
5251const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;
53const STABLE_FORM_SHEET_MAX_HEIGHT = 720;
54const STABLE_FORM_SHEET_VERTICAL_MARGIN = 64;
55const STABLE_FORM_SHEET_MIN_DETENT = 0.62;
56const STABLE_FORM_SHEET_MAX_DETENT = 0.92;
5752
5853export type LayoutVariant = "compact" | "split";
5954
......@@ -218,22 +213,6 @@ export function deriveFileInspectorPaneLayout(input: {
218213 };
219214}
220215
221/** Keep a user-selected sidebar width useful as a window is resized. */
222export function constrainPrimarySidebarWidth(
223 preferredWidth: number,
224 viewportWidth = Number.POSITIVE_INFINITY,
225): number {
226 const safeWidth = Number.isFinite(preferredWidth) ? preferredWidth : SPLIT_SIDEBAR_MIN_WIDTH;
227 const viewportMax = Number.isFinite(viewportWidth)
228 ? Math.max(SPLIT_SIDEBAR_MIN_WIDTH, viewportWidth - 360)
229 : SPLIT_SIDEBAR_MAX_WIDTH;
230 return clamp(
231 Math.round(safeWidth),
232 SPLIT_SIDEBAR_MIN_WIDTH,
233 Math.min(SPLIT_SIDEBAR_MAX_WIDTH, viewportMax),
234 );
235}
236
237216/**
238217 * Keep an auxiliary pane within native-feeling bounds without squeezing its
239218 * neighboring content below a usable reading/editor width.
......@@ -275,20 +254,3 @@ export function deriveCenteredContentHorizontalPadding(input: {
275254
276255 return minimumPadding + Math.max(0, (viewportWidth - input.maxContentWidth) / 2);
277256}
278
279export function deriveStableFormSheetDetent(containerHeight: number): number {
280 if (!Number.isFinite(containerHeight) || containerHeight <= 0) {
281 return STABLE_FORM_SHEET_MAX_DETENT;
282 }
283
284 const targetHeight = Math.min(
285 STABLE_FORM_SHEET_MAX_HEIGHT,
286 Math.max(0, containerHeight - STABLE_FORM_SHEET_VERTICAL_MARGIN),
287 );
288 const detent = clamp(
289 targetHeight / containerHeight,
290 STABLE_FORM_SHEET_MIN_DETENT,
291 STABLE_FORM_SHEET_MAX_DETENT,
292 );
293 return Math.round(detent * 1_000) / 1_000;
294}