fix: use a compact 40 to 200 pixel tile range

This commit is contained in:
ajnart committed 2026-09-09 15:33:14 +02:00
1 parent 9256a432f9
commit dbc24e9091
7 files changed
+13 -14

No files matched your search

@@ -10,7 +10,7 @@ import { clientApi } from "@homarr/api/client";
import { useUpdateBoard } from "@homarr/boards/updater";
import { revalidatePathActionAsync } from "@homarr/common/client";
import { env } from "@homarr/common/env";
import { BOARD_FIXED_ITEM_SIZE_DEFAULT } from "@homarr/definitions";
import { normalizeFixedItemSize } from "~/components/board/layout/scaling";
import { useZodForm } from "@homarr/form";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useSettings } from "@homarr/settings";
@@ -83,7 +83,7 @@ const buildInitialValues = (board: Board): FormValues => ({
customCss: board.customCss ?? "",
disableStatus: board.disableStatus,
fixedScaling: board.fixedScaling ?? false,
fixedItemSize: board.fixedItemSize ?? BOARD_FIXED_ITEM_SIZE_DEFAULT,
fixedItemSize: normalizeFixedItemSize(board.fixedItemSize ?? ""),
layouts: normalizeMobileLayoutGutters(board.layouts),
});
@@ -41,7 +41,6 @@ import type { z } from "zod/v4";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
import {
BOARD_FIXED_ITEM_SIZE_DEFAULT,
BOARD_FIXED_ITEM_SIZE_MAX,
BOARD_FIXED_ITEM_SIZE_MIN,
backgroundImageAttachments,
@@ -96,7 +95,7 @@ const normalizeFormValues = (
itemRadius: values.itemRadius,
disableStatus: values.disableStatus,
fixedScaling: values.fixedScaling ?? false,
fixedItemSize: values.fixedItemSize ?? BOARD_FIXED_ITEM_SIZE_DEFAULT,
fixedItemSize: normalizeFixedItemSize(values.fixedItemSize ?? ""),
};
};
@@ -14,7 +14,7 @@ import {
} from "../scaling";
describe("board canvas scale policy", () => {
test.each([100, 150, 200, 400])("renders an exact %s CSS-pixel fixed tile", (itemSize) => {
test.each([40, 80, 100, 200])("renders an exact %s CSS-pixel fixed tile", (itemSize) => {
const scale = calculateFixedBoardCanvasScale(itemSize);
expect(LOGICAL_GRID_PITCH * scale - 2 * BOARD_GRID_ITEM_INSET).toBeCloseTo(itemSize);
});
@@ -27,9 +27,9 @@ describe("board canvas scale policy", () => {
);
test("clamps and rounds the configured fixed size", () => {
expect(normalizeFixedItemSize(20)).toBe(100);
expect(normalizeFixedItemSize(700)).toBe(400);
expect(normalizeFixedItemSize(200.7)).toBe(201);
expect(normalizeFixedItemSize(20)).toBe(40);
expect(normalizeFixedItemSize(400)).toBe(200);
expect(normalizeFixedItemSize(100.7)).toBe(101);
});
test.each([0.75, 1, 1.25, 1.5, 2])("preserves fixed CSS dimensions at browser zoom %s", (zoom) => {