mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-01-27 18:24:25 +01:00
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:
@@ -3,3 +3,4 @@ export * from "./useResizeListener";
|
||||
export * from "./usePressHolder";
|
||||
export * from "./useInfiniteQuery";
|
||||
export * from "./useReachedBottom";
|
||||
export * from "./useAutoResizableTextArea";
|
||||
|
||||
20
src/utils/hooks/useAutoResizableTextArea.ts
Normal file
20
src/utils/hooks/useAutoResizableTextArea.ts
Normal 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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user