refactor(mobile): remove unused layout calculations (#9974)
This commit is contained in:
1 parent
1782a2af44
commit
eda0cec923
2 files changed
-57
No files matched your search
@@ -2,11 +2,9 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
constrainAuxiliaryPaneWidth,
|
||||
constrainPrimarySidebarWidth,
|
||||
deriveCenteredContentHorizontalPadding,
|
||||
deriveFileInspectorPaneLayout,
|
||||
deriveLayout,
|
||||
deriveStableFormSheetDetent,
|
||||
deriveThreadFeedInitialContentInset,
|
||||
deriveThreadWorkLogSizing,
|
||||
deriveWorkspacePaneLayout,
|
||||
@@ -75,12 +73,6 @@ describe("deriveThreadFeedInitialContentInset", () => {
|
||||
});
|
||||
|
||||
describe("resizable pane constraints", () => {
|
||||
it("keeps a preferred sidebar width across large windows and clamps it in a narrow split view", () => {
|
||||
expect(constrainPrimarySidebarWidth(430, 1_366)).toBe(430);
|
||||
expect(constrainPrimarySidebarWidth(430, 744)).toBe(384);
|
||||
expect(constrainPrimarySidebarWidth(100, 1_366)).toBe(280);
|
||||
});
|
||||
|
||||
it("preserves a useful main pane while constraining a trailing pane", () => {
|
||||
expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 1_100 })).toBe(440);
|
||||
expect(constrainAuxiliaryPaneWidth({ preferredWidth: 440, availableWidth: 900 })).toBe(340);
|
||||
@@ -392,14 +384,3 @@ describe("deriveWorkspacePaneLayout", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveStableFormSheetDetent", () => {
|
||||
it.each([
|
||||
{ height: 1_194, expected: 0.62 },
|
||||
{ height: 834, expected: 0.863 },
|
||||
{ height: 600, expected: 0.893 },
|
||||
{ height: 0, expected: 0.92 },
|
||||
])("derives a stable sheet detent for height $height", ({ height, expected }) => {
|
||||
expect(deriveStableFormSheetDetent(height)).toBe(expected);
|
||||
});
|
||||
});
|
||||
@@ -16,7 +16,6 @@ export const SPLIT_LAYOUT_MIN_WIDTH = 720;
|
||||
export const SPLIT_LAYOUT_MIN_HEIGHT = 600;
|
||||
|
||||
export const SPLIT_SIDEBAR_MIN_WIDTH = 280;
|
||||
export const SPLIT_SIDEBAR_MAX_WIDTH = 460;
|
||||
const SPLIT_SIDEBAR_DEFAULT_MAX_WIDTH = 380;
|
||||
|
||||
export const AUXILIARY_PANE_MIN_CONTENT_WIDTH = 960;
|
||||
@@ -50,10 +49,6 @@ export const AUXILIARY_PANE_MAX_WIDTH = 480;
|
||||
const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
|
||||
const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
|
||||
const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;
|
||||
const STABLE_FORM_SHEET_MAX_HEIGHT = 720;
|
||||
const STABLE_FORM_SHEET_VERTICAL_MARGIN = 64;
|
||||
const STABLE_FORM_SHEET_MIN_DETENT = 0.62;
|
||||
const STABLE_FORM_SHEET_MAX_DETENT = 0.92;
|
||||
|
||||
export type LayoutVariant = "compact" | "split";
|
||||
|
||||
@@ -218,22 +213,6 @@ export function deriveFileInspectorPaneLayout(input: {
|
||||
};
|
||||
}
|
||||
|
||||
/** Keep a user-selected sidebar width useful as a window is resized. */
|
||||
export function constrainPrimarySidebarWidth(
|
||||
preferredWidth: number,
|
||||
viewportWidth = Number.POSITIVE_INFINITY,
|
||||
): number {
|
||||
const safeWidth = Number.isFinite(preferredWidth) ? preferredWidth : SPLIT_SIDEBAR_MIN_WIDTH;
|
||||
const viewportMax = Number.isFinite(viewportWidth)
|
||||
? Math.max(SPLIT_SIDEBAR_MIN_WIDTH, viewportWidth - 360)
|
||||
: SPLIT_SIDEBAR_MAX_WIDTH;
|
||||
return clamp(
|
||||
Math.round(safeWidth),
|
||||
SPLIT_SIDEBAR_MIN_WIDTH,
|
||||
Math.min(SPLIT_SIDEBAR_MAX_WIDTH, viewportMax),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep an auxiliary pane within native-feeling bounds without squeezing its
|
||||
* neighboring content below a usable reading/editor width.
|
||||
@@ -275,20 +254,3 @@ export function deriveCenteredContentHorizontalPadding(input: {
|
||||
|
||||
return minimumPadding + Math.max(0, (viewportWidth - input.maxContentWidth) / 2);
|
||||
}
|
||||
|
||||
export function deriveStableFormSheetDetent(containerHeight: number): number {
|
||||
if (!Number.isFinite(containerHeight) || containerHeight <= 0) {
|
||||
return STABLE_FORM_SHEET_MAX_DETENT;
|
||||
}
|
||||
|
||||
const targetHeight = Math.min(
|
||||
STABLE_FORM_SHEET_MAX_HEIGHT,
|
||||
Math.max(0, containerHeight - STABLE_FORM_SHEET_VERTICAL_MARGIN),
|
||||
);
|
||||
const detent = clamp(
|
||||
targetHeight / containerHeight,
|
||||
STABLE_FORM_SHEET_MIN_DETENT,
|
||||
STABLE_FORM_SHEET_MAX_DETENT,
|
||||
);
|
||||
return Math.round(detent * 1_000) / 1_000;
|
||||
}
|
||||
Reference in new issue
Block a user