MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / getGridPosition

Function getGridPosition

src/utils/common.js:81–97  ·  view source on GitHub ↗
(widget, gridContainer)

Source from the content-addressed store, hash-verified

79 * @returns
80 */
81export const getGridPosition = (widget, gridContainer) => {
82 if (!widget || !gridContainer) return null;
83
84 const widgets = Array.from(gridContainer.children); // Get all grid items
85 // const index = widgets.indexOf(widget);
86 const widgetIndex = widgets.indexOf(widget);
87
88 if (widgetIndex === -1) return null; // Widget not found
89
90 const gridStyles = getComputedStyle(gridContainer);
91 const columnCount = gridStyles.gridTemplateColumns.split(' ').length;
92
93 const row = Math.floor(widgetIndex / columnCount) + 1;
94 const column = (widgetIndex % columnCount) + 1;
95
96 return { row, column };
97}

Callers 1

setParentLayoutFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected