feat: function delete chat dev done

This commit is contained in:
butterfly
2024-04-26 19:33:22 +08:00
parent 48e8c0a194
commit 1a636b0f50
36 changed files with 598 additions and 187 deletions

View File

@@ -1,6 +1,6 @@
import { useContext, useEffect, useRef } from "react";
import { ListContext } from "@/app/components/List";
import useResizeObserver from "use-resize-observer";
import { useResizeObserver } from "usehooks-ts";
interface SlideRangeProps {
className?: string;
@@ -31,13 +31,16 @@ export default function SlideRange(props: SlideRangeProps) {
const slideRef = useRef<HTMLDivElement>(null);
const { ref, width = 1 } = useResizeObserver<HTMLDivElement>();
ref(slideRef.current);
useResizeObserver({
ref: slideRef,
onResize: () => {
setProperty(value);
},
});
const transformToWidth = (x: number = start) => {
const abs = x - start;
const maxWidth = width - margin * 2;
const maxWidth = (slideRef.current?.clientWidth || 1) - margin * 2;
const result = (abs / stroke) * maxWidth;
return result;
};
@@ -49,10 +52,10 @@ export default function SlideRange(props: SlideRangeProps) {
`${initWidth + margin}px`,
);
};
useEffect(() => {
setProperty(value);
update?.({ type: "range" });
}, [width]);
}, []);
return (
<div