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

+1 -1
View File
@@ -63,7 +63,7 @@ layouts can use any other breakpoint, and Homarr selects the highest breakpoint
roles and use the canonical layouts returned by save operations, including generated IDs. roles and use the canonical layouts returned by save operations, including generated IDs.
Board settings expose `fixedScaling` and `fixedItemSize`. The default fitted mode uses `fixedScaling: false`; setting it Board settings expose `fixedScaling` and `fixedItemSize`. The default fitted mode uses `fixedScaling: false`; setting it
to `true` keeps each `1 × 1` tile at `fixedItemSize` pixels, which must be an integer from `100` through `400`. The to `true` keeps each `1 × 1` tile at `fixedItemSize` pixels, which must be an integer from `40` through `200`. The
configured size is retained while fixed scaling is disabled. Layout `columnCount` remains the maximum total column count, configured size is retained while fixed scaling is disabled. Layout `columnCount` remains the maximum total column count,
including fixed sidebars. including fixed sidebars.
+1 -1
View File
@@ -75,7 +75,7 @@ draft; **Discard** restores the saved settings.
### Try a layout before saving ### Try a layout before saving
Choose **Fixed scaling** or **Fit to screen** under **Tile sizing**. Fixed sizing accepts **100–400 px**; its square Choose **Fixed scaling** or **Fit to screen** under **Tile sizing**. Fixed sizing accepts **40–200 px**; its square
sample is shown at half size with the configured dimensions underneath. The size is retained when you switch modes. sample is shown at half size with the configured dimensions underneath. The size is retained when you switch modes.
Select a layout to edit its columns, breakpoint, and side rails beside the compact **Board preview**. It uses the Select a layout to edit its columns, breakpoint, and side rails beside the compact **Board preview**. It uses the
+2 -2
View File
@@ -2156,8 +2156,8 @@
}, },
"fixedItemSize": { "fixedItemSize": {
"type": "integer", "type": "integer",
"minimum": 100, "minimum": 40,
"maximum": 400 "maximum": 200
}, },
"disableStatus": { "disableStatus": {
"type": "boolean" "type": "boolean"
@@ -10,7 +10,7 @@ import { clientApi } from "@homarr/api/client";
import { useUpdateBoard } from "@homarr/boards/updater"; import { useUpdateBoard } from "@homarr/boards/updater";
import { revalidatePathActionAsync } from "@homarr/common/client"; import { revalidatePathActionAsync } from "@homarr/common/client";
import { env } from "@homarr/common/env"; 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 { useZodForm } from "@homarr/form";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useSettings } from "@homarr/settings"; import { useSettings } from "@homarr/settings";
@@ -83,7 +83,7 @@ const buildInitialValues = (board: Board): FormValues => ({
customCss: board.customCss ?? "", customCss: board.customCss ?? "",
disableStatus: board.disableStatus, disableStatus: board.disableStatus,
fixedScaling: board.fixedScaling ?? false, fixedScaling: board.fixedScaling ?? false,
fixedItemSize: board.fixedItemSize ?? BOARD_FIXED_ITEM_SIZE_DEFAULT, fixedItemSize: normalizeFixedItemSize(board.fixedItemSize ?? ""),
layouts: normalizeMobileLayoutGutters(board.layouts), layouts: normalizeMobileLayoutGutters(board.layouts),
}); });
@@ -41,7 +41,6 @@ import type { z } from "zod/v4";
import type { RouterOutputs } from "@homarr/api"; import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
import { import {
BOARD_FIXED_ITEM_SIZE_DEFAULT,
BOARD_FIXED_ITEM_SIZE_MAX, BOARD_FIXED_ITEM_SIZE_MAX,
BOARD_FIXED_ITEM_SIZE_MIN, BOARD_FIXED_ITEM_SIZE_MIN,
backgroundImageAttachments, backgroundImageAttachments,
@@ -96,7 +95,7 @@ const normalizeFormValues = (
itemRadius: values.itemRadius, itemRadius: values.itemRadius,
disableStatus: values.disableStatus, disableStatus: values.disableStatus,
fixedScaling: values.fixedScaling ?? false, fixedScaling: values.fixedScaling ?? false,
fixedItemSize: values.fixedItemSize ?? BOARD_FIXED_ITEM_SIZE_DEFAULT, fixedItemSize: normalizeFixedItemSize(values.fixedItemSize ?? ""),
}; };
}; };
@@ -14,7 +14,7 @@ import {
} from "../scaling"; } from "../scaling";
describe("board canvas scale policy", () => { 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); const scale = calculateFixedBoardCanvasScale(itemSize);
expect(LOGICAL_GRID_PITCH * scale - 2 * BOARD_GRID_ITEM_INSET).toBeCloseTo(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", () => { test("clamps and rounds the configured fixed size", () => {
expect(normalizeFixedItemSize(20)).toBe(100); expect(normalizeFixedItemSize(20)).toBe(40);
expect(normalizeFixedItemSize(700)).toBe(400); expect(normalizeFixedItemSize(400)).toBe(200);
expect(normalizeFixedItemSize(200.7)).toBe(201); 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) => { test.each([0.75, 1, 1.25, 1.5, 2])("preserves fixed CSS dimensions at browser zoom %s", (zoom) => {
+2 -2
View File
@@ -11,8 +11,8 @@ export const backgroundImageSizes = createDefinition(["cover", "contain"], {
export const layoutRoles = createDefinition(["mobile", "base", "custom"], { defaultValue: "custom" }); export const layoutRoles = createDefinition(["mobile", "base", "custom"], { defaultValue: "custom" });
export const BOARD_FIXED_ITEM_SIZE_DEFAULT = 200; export const BOARD_FIXED_ITEM_SIZE_DEFAULT = 200;
export const BOARD_FIXED_ITEM_SIZE_MIN = 100; export const BOARD_FIXED_ITEM_SIZE_MIN = 40;
export const BOARD_FIXED_ITEM_SIZE_MAX = 400; export const BOARD_FIXED_ITEM_SIZE_MAX = 200;
export type BackgroundImageAttachment = inferDefinitionType<typeof backgroundImageAttachments>; export type BackgroundImageAttachment = inferDefinitionType<typeof backgroundImageAttachments>;
export type BackgroundImageRepeat = inferDefinitionType<typeof backgroundImageRepeats>; export type BackgroundImageRepeat = inferDefinitionType<typeof backgroundImageRepeats>;