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";...@@ -2,11 +2,9 @@ import { describe, expect, it } from "vite-plus/test";
22
3import {3import {
4 constrainAuxiliaryPaneWidth,4 constrainAuxiliaryPaneWidth,
5 constrainPrimarySidebarWidth,
6 deriveCenteredContentHorizontalPadding,5 deriveCenteredContentHorizontalPadding,
7 deriveFileInspectorPaneLayout,6 deriveFileInspectorPaneLayout,
8 deriveLayout,7 deriveLayout,
9 deriveStableFormSheetDetent,
10 deriveThreadFeedInitialContentInset,8 deriveThreadFeedInitialContentInset,
11 deriveThreadWorkLogSizing,9 deriveThreadWorkLogSizing,
12 deriveWorkspacePaneLayout,10 deriveWorkspacePaneLayout,
...@@ -75,12 +73,6 @@ describe("deriveThreadFeedInitialContentInset", () => {...@@ -75,12 +73,6 @@ describe("deriveThreadFeedInitialContentInset", () => {
75});73});
7674
77describe("resizable pane constraints", () => {75describe("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
84 it("preserves a useful main pane while constraining a trailing pane", () => {76 it("preserves a useful main pane while constraining a trailing pane", () => {
85 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 1_100 })).toBe(440);77 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 1_100 })).toBe(440);
86 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 900 })).toBe(340);78 expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 900 })).toBe(340);
...@@ -392,14 +384,3 @@ describe("deriveWorkspacePaneLayout", () => {...@@ -392,14 +384,3 @@ describe("deriveWorkspacePaneLayout", () => {
392 });384 });
393 });385 });
394});386});
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;...@@ -16,7 +16,6 @@ export const SPLIT_LAYOUT_MIN_WIDTH = 720;
16export const SPLIT_LAYOUT_MIN_HEIGHT = 600;16export const SPLIT_LAYOUT_MIN_HEIGHT = 600;
1717
18export const SPLIT_SIDEBAR_MIN_WIDTH = 280;18export const SPLIT_SIDEBAR_MIN_WIDTH = 280;
19export const SPLIT_SIDEBAR_MAX_WIDTH = 460;
20const SPLIT_SIDEBAR_DEFAULT_MAX_WIDTH = 380;19const SPLIT_SIDEBAR_DEFAULT_MAX_WIDTH = 380;
2120
22export const AUXILIARY_PANE_MIN_CONTENT_WIDTH = 960;21export const AUXILIARY_PANE_MIN_CONTENT_WIDTH = 960;
...@@ -50,10 +49,6 @@ export const AUXILIARY_PANE_MAX_WIDTH = 480;...@@ -50,10 +49,6 @@ export const AUXILIARY_PANE_MAX_WIDTH = 480;
50const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;49const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
51const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;50const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
52const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;51const 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
58export type LayoutVariant = "compact" | "split";53export type LayoutVariant = "compact" | "split";
5954
...@@ -218,22 +213,6 @@ export function deriveFileInspectorPaneLayout(input: {...@@ -218,22 +213,6 @@ export function deriveFileInspectorPaneLayout(input: {
218 };213 };
219}214}
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
237/**216/**
238 * Keep an auxiliary pane within native-feeling bounds without squeezing its217 * Keep an auxiliary pane within native-feeling bounds without squeezing its
239 * neighboring content below a usable reading/editor width.218 * neighboring content below a usable reading/editor width.
...@@ -275,20 +254,3 @@ export function deriveCenteredContentHorizontalPadding(input: {...@@ -275,20 +254,3 @@ export function deriveCenteredContentHorizontalPadding(input: {
275254
276 return minimumPadding + Math.max(0, (viewportWidth - input.maxContentWidth) / 2);255 return minimumPadding + Math.max(0, (viewportWidth - input.maxContentWidth) / 2);
277}256}
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}