feat: comment with replies component, convertCommentsToTree helper method, comments section component, add comment input component, useAutoResizableText area, update mocks with comments data

This commit is contained in:
MTG2000
2022-04-26 10:41:03 +03:00
parent 2b0d2c174c
commit d7b2499c13
14 changed files with 201 additions and 16 deletions

View File

@@ -3,3 +3,4 @@ export * from "./useResizeListener";
export * from "./usePressHolder";
export * from "./useInfiniteQuery";
export * from "./useReachedBottom";
export * from "./useAutoResizableTextArea";

View File

@@ -0,0 +1,20 @@
import { useEffect, useRef } from "react";
export const useAutoResizableTextArea = () => {
const ref = useRef<HTMLTextAreaElement>(null);
useEffect(() => {
function OnInput() {
if (ref.current) {
ref.current.style.height = "auto";
ref.current.style.height = (ref.current.scrollHeight) + "px";
}
}
ref.current?.setAttribute("style", "height:" + (ref.current?.scrollHeight) + "px;overflow-y:hidden;");
ref.current?.addEventListener("input", OnInput, false);
}, [])
return ref
}