Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions frontend/src/pages/idea/_components/GeneratingIdea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const GeneratingIdea = () => {
const [keyword, setKeyword] = useState('')
const [additionalInfo, setAdditionalInfo] = useState('')
const [selectedOption, setSelectedOption] = useState('')
const [isKeywordLimit, setIsKeywordLimit] = useState(false)
const [isExtraLimit, setIsExtraLimit] = useState(false)

const hasTrackedKeywordFocus = useRef(false)
const hasTrackedAdditionalFocus = useRef(false)
Expand Down Expand Up @@ -153,6 +155,7 @@ export const GeneratingIdea = () => {
id="keyword-input"
value={keyword}
onChange={(value) => setKeyword(value)}
onLimitChange={setIsKeywordLimit}
onFocus={handleKeywordFocus}
title="키워드"
placeholder="생각나는 키워드를 입력해주세요. (예: 바이브코딩, 도쿄 여행, 가을 메이크업)"
Expand All @@ -161,8 +164,9 @@ export const GeneratingIdea = () => {
/>

<div
className={`flex flex-col p-4 items-start gap-2 rounded-lg bg-surface-elevate-l2 relative border self-stretch ${isDropdownOpen ? ' border-gray-400' : 'border-transparent'
}`}
className={`flex flex-col p-4 items-start gap-2 rounded-lg bg-surface-elevate-l2 relative border self-stretch ${
isDropdownOpen ? ' border-gray-400' : 'border-transparent'
}`}
>
<div className="font-caption-14m text-gray-600">영상형식</div>
<div
Expand Down Expand Up @@ -192,6 +196,7 @@ export const GeneratingIdea = () => {
id="additional-info-input"
value={additionalInfo}
onChange={(value) => setAdditionalInfo(value)}
onLimitChange={setIsExtraLimit}
onFocus={handleAdditionalFocus}
title="추가 입력 사항"
placeholder="어떤 점을 강조하고 싶으신가요? (예: 쉬운 설명, 유머, 영상미)"
Expand All @@ -201,10 +206,10 @@ export const GeneratingIdea = () => {
/>

<button
className="flex h-[48px] px-2 py-4 justify-center items-center gap-2 rounded-2xl
bg-primary-500 hover:bg-primary-opacity50 font-body-16b text-gray-900 text-center cursor-pointer"
className="flex h-12 px-2 py-4 justify-center items-center gap-2 rounded-2xl
bg-primary-500 hover:bg-primary-opacity50 font-body-16b text-gray-900 text-center cursor-pointer disabled:bg-gray-300"
onClick={handleSubmitClick}
disabled={isPending}
disabled={isPending || isKeywordLimit || isExtraLimit}
>
콘텐츠 아이디어 생성하기
</button>
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/pages/idea/_components/TextareaWithLimit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface TextareaWithLimitProps {
id: string
value: string // textarea의 값
onChange: (value: string) => void // 사용자가 입력한 텍스트가 변경될 때 호출되는 함수
onLimitChange: (value: boolean) => void
title: string
placeholder?: string
initialRows?: number // row 개수로 textarea 박스의 초기 높이를 지정할 수 있습니다. 디폴트는 1
Expand All @@ -17,6 +18,7 @@ const TextareaWithLimit = ({
id,
value,
onChange,
onLimitChange,
title,
placeholder,
initialRows = 1,
Expand Down Expand Up @@ -44,7 +46,8 @@ const TextareaWithLimit = ({
return (
<div
className={`flex flex-col p-4 gap-2 items-start
border bg-surface-elevate-l2 rounded-lg ${inputCount > limitLength ? 'border-error' : isFocused ? 'border-gray-400' : 'border-transparent'
border bg-surface-elevate-l2 rounded-lg ${
inputCount > limitLength ? 'border-error' : isFocused ? 'border-gray-400' : 'border-transparent'
}
`}
>
Expand All @@ -60,8 +63,10 @@ const TextareaWithLimit = ({
value={value}
disabled={disabled}
onChange={(e) => {
onChange(e.target.value)
onInputHandler(e.target.value)
const newValue = e.target.value
onChange(newValue)
onInputHandler(newValue)
onLimitChange(newValue.length > limitLength)
}}
onFocus={handleFocus}
onBlur={() => setIsFocused(false)}
Expand Down