mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-14 19:42:16 +01:00
24 lines
533 B
TypeScript
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,
|
|
});
|
|
};
|
|
};
|