Files
orca/mobile/src/components/right-drawer-panel-width.ts
T
c9bd61376f feat(mobile): combine PR sidebar and checks parity (#5641)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Orca <help@stably.ai>
Co-authored-by: gsxdsm <gsxdsm@users.noreply.github.com>
2026-06-17 22:52:12 -07:00

23 lines
862 B
TypeScript

// Pure X-axis panel-width resolution for RightDrawer, kept native-import-free so
// it is unit-testable under the node Vitest config (no RN render harness exists).
// Why: cap the panel on wide canvases so it doesn't stretch across a tablet.
export const WIDE_PANEL_MAX_WIDTH = 420
// Why: on a phone the panel leaves a thin gutter so the backdrop stays tappable.
export const NARROW_BACKDROP_GUTTER = 48
export function resolveRightDrawerPanelWidth(
windowWidth: number,
isWideLayout: boolean,
widthPx: number | undefined
): number {
if (widthPx != null) {
// Clamp to [0, windowWidth] so a negative explicit width can't yield a negative panel.
return Math.max(Math.min(widthPx, windowWidth), 0)
}
if (isWideLayout) {
return Math.min(WIDE_PANEL_MAX_WIDTH, windowWidth)
}
return Math.max(windowWidth - NARROW_BACKDROP_GUTTER, 0)
}