refine ui further

This commit is contained in:
Developers Digest
2025-09-05 15:56:14 -04:00
parent 836b085f75
commit 9d71ae77e7
8 changed files with 285 additions and 232 deletions
+11 -1
View File
@@ -1,6 +1,6 @@
"use client";
import { useState, KeyboardEvent } from "react";
import { useState, KeyboardEvent, useEffect, useRef } from "react";
interface HeroInputProps {
value: string;
@@ -18,6 +18,15 @@ export default function HeroInput({
className = ""
}: HeroInputProps) {
const [isFocused, setIsFocused] = useState(false);
const textareaRef = useRef<HTMLTextAreaElement>(null);
// Reset textarea height when value changes (especially when cleared)
useEffect(() => {
if (textareaRef.current) {
textareaRef.current.style.height = 'auto';
textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px';
}
}, [value]);
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey) {
@@ -52,6 +61,7 @@ export default function HeroInput({
</div>
<textarea
ref={textareaRef}
className="w-full bg-transparent text-body-input text-accent-black placeholder:text-black-alpha-48 resize-none outline-none min-h-[24px] leading-6"
placeholder={placeholder}
value={value}