feat: chat panel redesigned ui

This commit is contained in:
butterfly
2024-04-16 14:07:51 +08:00
parent 3fc9b91bf1
commit 51a1d9f92a
41 changed files with 1350 additions and 526 deletions

View File

@@ -0,0 +1,36 @@
import { useLayoutEffect, useMemo, useRef } from "react";
type Size = {
width: number;
height: number;
};
export function useWindowSize(callback: (size: Size) => void) {
const callbackRef = useRef<typeof callback>();
const hascalled = useRef(false);
if (typeof window !== "undefined" && !hascalled.current) {
callback({
width: window.innerWidth,
height: window.innerHeight,
});
hascalled.current = true;
}
callbackRef.current = callback;
useLayoutEffect(() => {
const onResize = () => {
callbackRef.current?.({
width: window.innerWidth,
height: window.innerHeight,
});
};
window.addEventListener("resize", onResize);
return () => {
window.removeEventListener("resize", onResize);
};
}, []);
}