fix(beszel): restore balanced grid layout for system grid widget
Reverts getColCount to the minimize-empty-cells heuristic from v1.68.0
after the aspect-ratio rewrite in 576856d63 broke 2×2 layout for 4
systems at common widget widths (240–359px).
Lowered MIN_CELL_WIDTH from 180 to 140 — a compromise between the
original 120 (v1.68.0) and the current 180, leaving room for the
DiskUsage component while keeping the 2×2 threshold at 280px.
Fixes #6385
This commit is contained in:
1 parent
6ac4c6a7b9
commit
dafe1fdb75
1 file changed
+12
-4
@@ -114,14 +114,22 @@ const getMaxVisibleMetrics = (cellHeight: number, size: SizeConfig): number => {
|
||||
return Math.max(1, Math.floor(available / size.rowHeight));
|
||||
};
|
||||
|
||||
const MIN_CELL_WIDTH = 180;
|
||||
const MIN_CELL_WIDTH = 140;
|
||||
const MIN_CELL_HEIGHT = 80;
|
||||
|
||||
const getColCount = (width: number, height: number, itemCount: number): number => {
|
||||
const getColCount = (width: number, _height: number, itemCount: number): number => {
|
||||
if (itemCount <= 1) return 1;
|
||||
const maxCols = Math.min(itemCount, Math.max(1, Math.floor(width / MIN_CELL_WIDTH)));
|
||||
const aspectRatio = width / Math.max(height, MIN_CELL_HEIGHT);
|
||||
return Math.min(maxCols, Math.max(1, Math.ceil(Math.sqrt(itemCount * aspectRatio))));
|
||||
|
||||
let best = 1;
|
||||
for (let c = 1; c <= maxCols; c++) {
|
||||
const emptyCells = (c - (itemCount % c)) % c;
|
||||
const bestEmpty = (best - (itemCount % best)) % best;
|
||||
if (emptyCells < bestEmpty || (emptyCells === bestEmpty && c > best)) {
|
||||
best = c;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
};
|
||||
|
||||
interface MetricRowProps {
|
||||
|
||||
Reference in new issue
Block a user