Files
Homarr/src/components/Board/gridstack/useResizeGridItem.ts
2023-10-09 06:30:43 +02:00

24 lines
533 B
TypeScript

import { useGridItemRef } from '../item/context';
import { useGridstackRef } from './context';
type ResizeGridItemProps = {
height: number;
width: number;
x: number;
y: number;
};
export const useResizeGridItem = () => {
const itemRef = useGridItemRef();
const gridstackRef = useGridstackRef();
return ({ height, width, ...options }: ResizeGridItemProps) => {
if (!itemRef?.current) return;
gridstackRef?.current?.update(itemRef.current!, {
...options,
h: height,
w: width,
});
};
};