Skip to content

Commit

Permalink
refactor: chat-form textInput component to textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
swgvenghy committed Oct 30, 2024
1 parent 8669db7 commit a9d6633
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/ui/components/molecule/chat-form/chat-form.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
// src/ui/molecule/chat-form.tsx
import React from 'react';
import TextInput from '../../atom/text-input/text-input';
import IconButton from '../../atom/icon/icon-button';
import { ReactComponent as SendIcon } from '../../../../assets/Send.svg';
import AutoCompleteList from '../../atom/auto-complete/auto-complete';
import { cn } from '../../../../utils/style';
import useChatForm from '../../../../hooks/use-chat-form.hooks';
import { useTextAreaSubmit } from '../../../../hooks/use-textarea-submit.hooks';

const ChatForm = () => {
const { content, autoOpen, disabled, results, handleChange, handleSelect, handleSubmit } = useChatForm();

const { handlePressEnter } = useTextAreaSubmit({ handleSubmit });
return (
<>
{autoOpen && <AutoCompleteList results={results} onSelect={handleSelect} />}
<form
className={cn('flex flex-nowrap rounded-2xl border py-2 pr-1', 'bg-background-default')}
onSubmit={handleSubmit}
>
<TextInput
value={content}
onValueChange={handleChange}
placeholder="메시지를 입력해주세요."
<textarea
rows={2}
className={cn(
`w-full resize-none rounded-2xl bg-transparent px-4 py-2 text-base`,
`placeholder:text-[#72777A] focus:outline-none`,
`disabled:cursor-wait`,
)}
disabled={disabled}
value={content}
onChange={(e) => handleChange(e.target.value)}
onKeyDown={handlePressEnter}
placeholder="질문을 입력해주세요"
/>
<IconButton type="submit" disabled={disabled}>
<div className="pr-2">
Expand Down

0 comments on commit a9d6633

Please sign in to comment.