Skip to content

Commit 99e1fc2

Browse files
refactor: improve layout and structure of assistant components (#99)
Co-authored-by: iza <[email protected]>
1 parent 07fba18 commit 99e1fc2

File tree

4 files changed

+60
-65
lines changed

4 files changed

+60
-65
lines changed

apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function AIAssistantMain() {
2121
.slice()
2222
.reverse()
2323
.find(
24-
(m: Message) =>
24+
(m) =>
2525
m.data &&
2626
m.chartType &&
2727
m.type === 'assistant' &&
@@ -55,8 +55,8 @@ export default function AIAssistantMain() {
5555
);
5656

5757
return (
58-
<div className="flex h-full flex-col">
59-
<div className="flex flex-1 flex-col gap-3 overflow-hidden lg:flex-row">
58+
<div className="h-full bg-gradient-to-br from-background to-muted/20">
59+
<div className="flex h-full flex-1 flex-col gap-3 overflow-hidden lg:flex-row">
6060
<div
6161
className={cn(
6262
'flex flex-col overflow-hidden',

apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { useAtom } from 'jotai';
1515
import { useEffect, useRef, useState } from 'react';
1616
import { Button } from '@/components/ui/button';
1717
import { Input } from '@/components/ui/input';
18-
import { ScrollArea } from '@/components/ui/scroll-area';
1918
import { Skeleton } from '@/components/ui/skeleton';
2019
import { cn } from '@/lib/utils';
2120
import {
@@ -202,20 +201,20 @@ export default function ChatSection() {
202201
</div>
203202

204203
{/* Messages Area */}
205-
<div className="relative min-h-0 flex-1 overflow-y-auto">
206-
<ScrollArea className="h-full" ref={scrollAreaRef}>
207-
<div className="px-4 py-3">
208-
{/* Welcome State */}
209-
{!(hasMessages || isLoading) && (
210-
<div className="fade-in-0 slide-in-from-bottom-4 animate-in space-y-6 duration-500">
211-
<div className="py-8 text-center">
204+
<div className="min-h-0 flex-1 overflow-y-auto" ref={scrollAreaRef}>
205+
{/* Welcome State */}
206+
<div className="h-full px-4 py-3">
207+
{!(hasMessages || isLoading) && (
208+
<div className="fade-in-0 slide-in-from-bottom-4 h-full animate-in space-y-6 duration-500">
209+
<div className="flex h-full flex-col justify-between">
210+
<div className="space-y-2 py-4 text-center">
212211
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gradient-to-br from-primary/10 to-accent/10">
213212
<SparkleIcon
214213
className="h-8 w-8 text-primary"
215214
weight="duotone"
216215
/>
217216
</div>
218-
<h3 className="mb-2 font-semibold text-lg">
217+
<h3 className="font-semibold text-lg">
219218
Welcome to Databunny
220219
</h3>
221220
<p className="mx-auto max-w-md text-muted-foreground text-sm">
@@ -226,56 +225,56 @@ export default function ChatSection() {
226225
</div>
227226

228227
<div className="space-y-3">
229-
<div className="mb-3 flex items-center gap-2 text-muted-foreground text-sm">
228+
<div className="flex items-center gap-2 text-muted-foreground text-sm">
230229
<LightningIcon className="h-4 w-4" weight="duotone" />
231230
<span>Try these examples:</span>
232231
</div>
233-
{quickQuestions.map((question, index) => (
234-
<Button
235-
className={cn(
236-
'h-auto w-full justify-start px-4 py-3 text-left font-normal text-sm',
237-
'hover:bg-gradient-to-r hover:from-primary/5 hover:to-accent/5',
238-
'border-dashed transition-all duration-300 hover:border-solid',
239-
'fade-in-0 slide-in-from-left-2 animate-in'
240-
)}
241-
disabled={isLoading || isRateLimited}
242-
key={question.text}
243-
onClick={() => {
244-
if (!(isLoading || isRateLimited)) {
245-
sendMessage(question.text);
246-
scrollToBottom();
247-
}
248-
}}
249-
size="sm"
250-
style={{ animationDelay: `${index * 100}ms` }}
251-
variant="outline"
252-
>
253-
<question.icon className="mr-3 h-4 w-4 flex-shrink-0 text-primary/70" />
254-
<div className="flex-1">
255-
<div className="font-medium">{question.text}</div>
256-
<div className="text-muted-foreground text-xs capitalize">
257-
{question.type} response
232+
<div className="grid grid-cols-1 gap-2 md:grid-cols-2">
233+
{quickQuestions.map((question, index) => (
234+
<Button
235+
className={cn(
236+
'h-auto px-4 py-3 text-left font-normal text-sm',
237+
'hover:bg-gradient-to-r hover:from-primary/5 hover:to-accent/5',
238+
'border-dashed transition-all duration-300 hover:border-solid',
239+
'fade-in-0 slide-in-from-left-2 animate-in'
240+
)}
241+
disabled={isLoading || isRateLimited}
242+
key={question.text}
243+
onClick={() => {
244+
if (!(isLoading || isRateLimited)) {
245+
sendMessage(question.text);
246+
scrollToBottom();
247+
}
248+
}}
249+
size="sm"
250+
style={{ animationDelay: `${index * 100}ms` }}
251+
variant="outline"
252+
>
253+
<question.icon className="mr-3 h-4 w-4 flex-shrink-0 text-primary/70" />
254+
<div className="flex-1">
255+
<div className="font-medium">{question.text}</div>
256+
<div className="text-muted-foreground text-xs capitalize">
257+
{question.type} response
258+
</div>
258259
</div>
259-
</div>
260-
</Button>
261-
))}
260+
</Button>
261+
))}
262+
</div>
262263
</div>
263264
</div>
264-
)}
265+
</div>
266+
)}
265267

266-
{/* Messages */}
267-
{hasMessages && (
268-
<div className="space-y-6">
269-
{messages.map((message) => (
270-
<div className="mb-2" key={message.id}>
271-
<MessageBubble message={message} />
272-
</div>
273-
))}
274-
<div ref={bottomRef} />
275-
</div>
276-
)}
277-
</div>
278-
</ScrollArea>
268+
{/* Messages */}
269+
{hasMessages && (
270+
<div className="space-y-3">
271+
{messages.map((message) => (
272+
<MessageBubble key={message.id} message={message} />
273+
))}
274+
<div ref={bottomRef} />
275+
</div>
276+
)}
277+
</div>
279278
</div>
280279

281280
{/* Enhanced Input Area */}

apps/dashboard/app/(main)/websites/[id]/assistant/page.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ export default function AssistantPage() {
7777
});
7878
}, [id, setWebsiteId, websiteData, setWebsiteData, setDateRange]);
7979

80-
return (
81-
<div className="flex h-full flex-col bg-gradient-to-br from-background to-muted/20">
82-
{isLoading || !websiteData ? (
83-
<AIAssistantLoadingSkeleton />
84-
) : (
85-
<AIAssistantMain />
86-
)}
87-
</div>
88-
);
80+
if (isLoading || !websiteData) {
81+
return <AIAssistantLoadingSkeleton />;
82+
}
83+
84+
return <AIAssistantMain />;
8985
}

apps/dashboard/app/(main)/websites/[id]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
5050
};
5151

5252
return (
53-
<div className="mx-auto max-w-[1600px] p-3 sm:p-4 lg:p-6">
53+
<div className="mx-auto h-full max-w-[1600px] p-3 sm:p-4 lg:p-6">
5454
{isTrackingSetup && !isAssistantPage && (
5555
<div className="space-y-4">
5656
<AnalyticsToolbar

0 commit comments

Comments
 (0)