style(ui): format panel rail modules and retain source invariants

This commit is contained in:
Sameh Khamis committed 2026-09-12 19:55:02 -07:00
1 parent bf77ae61b8
commit e13a680b53
11 files changed
+460 -178

No files matched your search

+33 -10
View File
@@ -13,26 +13,47 @@ export function resolveHudRailLayout({
gap = 12,
align = 'center',
}) {
if (![viewportHeight, panelHeight, laneLeft, laneRight, baseTop, baseBottom]
.every(Number.isFinite) || viewportHeight <= 0 || laneRight <= laneLeft) return null;
if (
![
viewportHeight,
panelHeight,
laneLeft,
laneRight,
baseTop,
baseBottom,
].every(Number.isFinite) ||
viewportHeight <= 0 ||
laneRight <= laneLeft
)
return null;
const midpoint = viewportHeight * 0.5;
let safeTop = Math.max(0, baseTop);
let safeBottom = Math.min(viewportHeight, baseBottom);
for (const rect of obstacles) {
if (![rect?.left, rect?.right, rect?.top, rect?.bottom].every(Number.isFinite)) continue;
if (rect.right <= laneLeft || rect.left >= laneRight || rect.bottom <= rect.top) continue;
if (
![rect?.left, rect?.right, rect?.top, rect?.bottom].every(Number.isFinite)
)
continue;
if (
rect.right <= laneLeft ||
rect.left >= laneRight ||
rect.bottom <= rect.top
)
continue;
if (rect.bottom <= midpoint) safeTop = Math.max(safeTop, rect.bottom + gap);
else if (rect.top >= midpoint) safeBottom = Math.min(safeBottom, rect.top - gap);
else if (rect.top >= midpoint)
safeBottom = Math.min(safeBottom, rect.top - gap);
}
safeBottom = Math.max(safeTop, safeBottom);
const availableHeight = Math.max(0, safeBottom - safeTop);
const renderedHeight = Math.min(Math.max(0, panelHeight), availableHeight);
return {
top: align === 'start'
? safeTop
: safeTop + Math.max(0, (availableHeight - renderedHeight) * 0.5),
top:
align === 'start'
? safeTop
: safeTop + Math.max(0, (availableHeight - renderedHeight) * 0.5),
maxHeight: availableHeight,
safeTop,
safeBottom,
@@ -49,7 +70,9 @@ export function resolveHudRailLayout({
* @param {boolean} input.hasExpandedPanel Whether any rail panel is expanded.
* @returns {boolean} Whether collapsed sibling launchers should be hidden.
*/
export function shouldHideCollapsedRightPanels({ hudVariant, hasExpandedPanel }) {
export function shouldHideCollapsedRightPanels({
hudVariant,
hasExpandedPanel,
}) {
return hudVariant === 'tactical' && Boolean(hasExpandedPanel);
}