feat: rebuild board grid experience

This commit is contained in:
ajnart committed 2026-08-13 19:52:09 +02:00
1 parent 5dc4dbeaef
commit 0110a2ef63
122 files changed
+9582 -4063

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
export const boardViewportWidthCookieName = "homarr-viewport-width";
interface ResponsiveLayout {
id: string;
breakpoint: number;
}
export const getLayoutIdForViewportWidth = (
layouts: readonly ResponsiveLayout[],
viewportWidth: number,
): string => {
if (layouts.length === 0) {
throw new Error("Expected the board to contain a layout");
}
const normalizedWidth = Number.isFinite(viewportWidth) ? Math.max(0, viewportWidth) : 0;
const sortedLayouts = layouts.toSorted((layoutA, layoutB) => layoutB.breakpoint - layoutA.breakpoint);
const selected = sortedLayouts.find((layout) => layout.breakpoint <= normalizedWidth) ?? sortedLayouts.at(-1);
if (!selected) {
throw new Error("Expected the board to contain a layout");
}
return selected.id;
};