11'use client'
22
33import { useCallback , useEffect , useRef , useState } from 'react'
4- import { ArrowUp , Mic } from 'lucide-react'
4+ import { ArrowUp , Mic , Paperclip } from 'lucide-react'
55import { Button } from '@/components/emcn'
66import { cn } from '@/lib/core/utils/cn'
77import { useAnimatedPlaceholder } from '../../hooks'
88
9- const TEXTAREA_CLASSES =
10- 'm-0 box-border h-auto max-h-[30vh] min-h-[24px] w-full resize-none overflow-y-auto overflow-x-hidden break-words border-0 bg-transparent px-[4px] py-[4px] font-medium font-sans text-[14px] text-[var(--text-primary)] leading-[20px] outline-none placeholder:text-[var(--text-muted)] focus-visible:ring-0 focus-visible:ring-offset-0 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'
9+ const TEXTAREA_CLASSES = cn (
10+ 'm-0 box-border h-auto max-h-[30vh] min-h-[24px] w-full resize-none' ,
11+ 'overflow-y-auto overflow-x-hidden break-words border-0 bg-transparent' ,
12+ 'px-[4px] py-[4px] font-body text-[15px] leading-[24px] tracking-[-0.015em]' ,
13+ 'text-[var(--text-primary)] outline-none' ,
14+ 'placeholder:font-[350] placeholder:text-[var(--text-subtle)]' ,
15+ 'focus-visible:ring-0 focus-visible:ring-offset-0' ,
16+ '[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'
17+ )
1118
1219const SEND_BUTTON_BASE = 'h-[28px] w-[28px] rounded-full border-0 p-0 transition-colors'
1320const SEND_BUTTON_ACTIVE =
@@ -26,7 +33,7 @@ interface UserInputProps {
2633 onSubmit : ( ) => void
2734 isSending : boolean
2835 onStopGeneration : ( ) => void
29- animate ?: boolean
36+ isInitialView ?: boolean
3037}
3138
3239export function UserInput ( {
@@ -35,10 +42,10 @@ export function UserInput({
3542 onSubmit,
3643 isSending,
3744 onStopGeneration,
38- animate = true ,
45+ isInitialView = true ,
3946} : UserInputProps ) {
4047 const animatedPlaceholder = useAnimatedPlaceholder ( )
41- const placeholder = animate ? animatedPlaceholder : 'Send message to Sim'
48+ const placeholder = isInitialView ? animatedPlaceholder : 'Send message to Sim'
4249 const canSubmit = value . trim ( ) . length > 0 && ! isSending
4350
4451 const [ isListening , setIsListening ] = useState ( false )
@@ -124,7 +131,10 @@ export function UserInput({
124131 return (
125132 < div
126133 onClick = { handleContainerClick }
127- className = 'mx-auto w-full max-w-[640px] cursor-text rounded-[12px] border border-[var(--border-1)] bg-white px-[10px] py-[8px] shadow-sm dark:bg-[var(--surface-4)]'
134+ className = { cn (
135+ 'mx-auto w-full max-w-[640px] cursor-text rounded-[20px] border border-[var(--border-1)] bg-[var(--white)] px-[10px] py-[8px] dark:bg-[var(--surface-4)]' ,
136+ isInitialView && 'shadow-sm'
137+ ) }
128138 >
129139 < textarea
130140 ref = { textareaRef }
@@ -136,46 +146,54 @@ export function UserInput({
136146 rows = { 1 }
137147 className = { TEXTAREA_CLASSES }
138148 />
139- < div className = 'flex items-center justify-end gap-[6px]' >
140- < button
141- type = 'button'
142- onClick = { toggleListening }
143- className = { cn (
144- 'flex h-[28px] w-[28px] items-center justify-center rounded-full transition-colors' ,
145- isListening
146- ? 'bg-red-500 text-white hover:bg-red-600'
147- : 'text-[var(--text-muted)] hover:text-[var(--text-primary)]'
148- ) }
149- title = { isListening ? 'Stop listening' : 'Voice input' }
150- >
151- < Mic className = 'h-[16px] w-[16px]' strokeWidth = { 2 } />
152- </ button >
153- { isSending ? (
154- < Button
155- onClick = { onStopGeneration }
156- className = { cn ( SEND_BUTTON_BASE , SEND_BUTTON_ACTIVE ) }
157- title = 'Stop generation'
149+ < div className = 'flex items-center justify-between' >
150+ < div className = 'flex h-[28px] w-[28px] cursor-pointer items-center justify-center rounded-full border border-[#F0F0F0] transition-colors hover:bg-[#F7F7F7] dark:border-[#3d3d3d] dark:hover:bg-[#303030]' >
151+ < Paperclip className = 'h-[14px] w-[14px] text-[var(--text-muted)]' strokeWidth = { 2 } />
152+ </ div >
153+ < div className = 'flex items-center gap-[6px]' >
154+ < button
155+ type = 'button'
156+ onClick = { toggleListening }
157+ className = { cn (
158+ 'flex h-[28px] w-[28px] items-center justify-center rounded-full transition-colors' ,
159+ isListening
160+ ? 'bg-red-500 text-white hover:bg-red-600'
161+ : 'text-[var(--text-muted)] hover:text-[var(--text-primary)]'
162+ ) }
163+ title = { isListening ? 'Stop listening' : 'Voice input' }
158164 >
159- < svg
160- className = 'block h-[14px] w-[14px] fill-white dark:fill-black'
161- viewBox = '0 0 24 24'
162- xmlns = 'http://www.w3.org/2000/svg'
165+ < Mic className = 'h-[16px] w-[16px]' strokeWidth = { 2 } />
166+ </ button >
167+ { isSending ? (
168+ < Button
169+ onClick = { onStopGeneration }
170+ className = { cn ( SEND_BUTTON_BASE , SEND_BUTTON_ACTIVE ) }
171+ title = 'Stop generation'
163172 >
164- < rect x = '4' y = '4' width = '16' height = '16' rx = '3' ry = '3' />
165- </ svg >
166- </ Button >
167- ) : (
168- < Button
169- onClick = { onSubmit }
170- disabled = { ! canSubmit }
171- className = { cn ( SEND_BUTTON_BASE , canSubmit ? SEND_BUTTON_ACTIVE : SEND_BUTTON_DISABLED ) }
172- >
173- < ArrowUp
174- className = 'block h-[16px] w-[16px] text-white dark:text-black'
175- strokeWidth = { 2.25 }
176- />
177- </ Button >
178- ) }
173+ < svg
174+ className = 'block h-[14px] w-[14px] fill-white dark:fill-black'
175+ viewBox = '0 0 24 24'
176+ xmlns = 'http://www.w3.org/2000/svg'
177+ >
178+ < rect x = '4' y = '4' width = '16' height = '16' rx = '3' ry = '3' />
179+ </ svg >
180+ </ Button >
181+ ) : (
182+ < Button
183+ onClick = { onSubmit }
184+ disabled = { ! canSubmit }
185+ className = { cn (
186+ SEND_BUTTON_BASE ,
187+ canSubmit ? SEND_BUTTON_ACTIVE : SEND_BUTTON_DISABLED
188+ ) }
189+ >
190+ < ArrowUp
191+ className = 'block h-[16px] w-[16px] text-white dark:text-black'
192+ strokeWidth = { 2.25 }
193+ />
194+ </ Button >
195+ ) }
196+ </ div >
179197 </ div >
180198 </ div >
181199 )
0 commit comments