Skip to content

Commit 4324a68

Browse files
fix(multimodal-input): refactor greeting and suggested actions display for better clarity and organization
1 parent 272102a commit 4324a68

File tree

1 file changed

+53
-52
lines changed

1 file changed

+53
-52
lines changed

components/custom/multimodal-input.tsx

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -178,61 +178,31 @@ export function MultimodalInput({
178178
<div className="relative w-full flex flex-col gap-4">
179179
{/* Show greeting and suggested actions only for new chat */}
180180
{messages.length === 0 && (
181-
<>
182-
<div
183-
className="w-full flex justify-center items-center my-2"
181+
<div
182+
className="w-full flex justify-center items-center my-2"
183+
style={{
184+
minHeight: "2.5rem",
185+
height: "2.5rem",
186+
perspective: "800px"
187+
}}
188+
>
189+
<motion.div
190+
key={greetingIndex}
191+
initial={{ rotateX: -90, opacity: 0 }}
192+
animate={{ rotateX: 0, opacity: 1 }}
193+
exit={{ rotateX: 90, opacity: 0 }}
194+
transition={{ duration: 0.5 }}
195+
className="text-2xl font-semibold"
184196
style={{
185-
minHeight: "2.5rem",
186-
height: "2.5rem",
187-
perspective: "800px"
197+
textAlign: "center",
198+
display: "inline-block",
199+
width: "100%",
200+
backfaceVisibility: "hidden"
188201
}}
189202
>
190-
<motion.div
191-
key={greetingIndex}
192-
initial={{ rotateX: -90, opacity: 0 }}
193-
animate={{ rotateX: 0, opacity: 1 }}
194-
exit={{ rotateX: 90, opacity: 0 }}
195-
transition={{ duration: 0.5 }}
196-
className="text-2xl font-semibold"
197-
style={{
198-
textAlign: "center",
199-
display: "inline-block",
200-
width: "100%",
201-
backfaceVisibility: "hidden"
202-
}}
203-
>
204-
{greetings[greetingIndex]}
205-
</motion.div>
206-
</div>
207-
{/* Suggested actions below input, always visible for new chat */}
208-
<div className="grid sm:grid-cols-2 gap-4 w-full md:px-0 mx-auto md:max-w-[500px] mt-4">
209-
{suggestedActions.map((suggestedAction, index) => (
210-
<motion.div
211-
initial={{ opacity: 0, y: 20 }}
212-
animate={{ opacity: 1, y: 0 }}
213-
exit={{ opacity: 0, y: 20 }}
214-
transition={{ delay: 0.05 * index }}
215-
key={index}
216-
className={index > 1 ? "hidden sm:block" : "block"}
217-
>
218-
<button
219-
onClick={async () => {
220-
append({
221-
role: "user",
222-
content: suggestedAction.action,
223-
});
224-
}}
225-
className="border-none bg-muted/50 w-full text-left border border-zinc-200 dark:border-zinc-800 text-zinc-800 dark:text-zinc-300 rounded-lg p-3 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors flex flex-col"
226-
>
227-
<span className="font-medium">{suggestedAction.title}</span>
228-
<span className="text-zinc-500 dark:text-zinc-400">
229-
{suggestedAction.label}
230-
</span>
231-
</button>
232-
</motion.div>
233-
))}
234-
</div>
235-
</>
203+
{greetings[greetingIndex]}
204+
</motion.div>
205+
</div>
236206
)}
237207

238208
<input
@@ -324,6 +294,37 @@ export function MultimodalInput({
324294
</div>
325295
</div>
326296

297+
{/* Suggested actions below input, always visible for new chat */}
298+
{messages.length === 0 && (
299+
<div className="grid sm:grid-cols-2 gap-4 w-full md:px-0 mx-auto md:max-w-[500px] mt-4">
300+
{suggestedActions.map((suggestedAction, index) => (
301+
<motion.div
302+
initial={{ opacity: 0, y: 20 }}
303+
animate={{ opacity: 1, y: 0 }}
304+
exit={{ opacity: 0, y: 20 }}
305+
transition={{ delay: 0.05 * index }}
306+
key={index}
307+
className={index > 1 ? "hidden sm:block" : "block"}
308+
>
309+
<button
310+
onClick={async () => {
311+
append({
312+
role: "user",
313+
content: suggestedAction.action,
314+
});
315+
}}
316+
className="border-none bg-muted/50 w-full text-left border border-zinc-200 dark:border-zinc-800 text-zinc-800 dark:text-zinc-300 rounded-lg p-3 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors flex flex-col"
317+
>
318+
<span className="font-medium">{suggestedAction.title}</span>
319+
<span className="text-zinc-500 dark:text-zinc-400">
320+
{suggestedAction.label}
321+
</span>
322+
</button>
323+
</motion.div>
324+
))}
325+
</div>
326+
)}
327+
327328
</div>
328329
);
329330
}

0 commit comments

Comments
 (0)