Skip to content

An AI-powered search engine with a generative UI

refactor: compact mobile chat panel and normalize size utilities (#809)

Yoshiki Miura76e20046b7c1
diff --git a/components/chat-messages.tsx b/components/chat-messages.tsx
index cc102879..d6cdf9cc 100644
--- a/components/chat-messages.tsx
+++ b/components/chat-messages.tsx
@@ -67,7 +67,7 @@ export function ChatMessages({
// Calculate the offset height based on device type
// Note: pt-14 (56px) on scroll-container must be included in desktop offset
const offsetHeight = isMobile
- ? 208 // Mobile: larger offset for mobile header/input
+ ? 192 // Mobile: larger offset for mobile header/input (pt-10 = 40px)
: 196 // Desktop: smaller offset (140px) + pt-14 (56px)
// Extract citation maps from all messages in all sections
@@ -162,7 +162,7 @@ export function ChatMessages({
role="list"
aria-roledescription="chat messages"
className={cn(
- 'relative size-full pt-14',
+ 'relative size-full pt-10 md:pt-14',
sections.length > 0 ? 'flex-1 overflow-y-auto' : ''
)}
>
@@ -171,7 +171,7 @@ export function ChatMessages({
<div
key={section.id}
id={`section-${section.id}`}
- className="chat-section pb-14"
+ className="chat-section pb-8 md:pb-14"
style={
sectionIndex === sections.length - 1
? { minHeight: `calc(100dvh - ${offsetHeight}px)` }
@@ -179,7 +179,7 @@ export function ChatMessages({
}
>
{/* User message */}
- <div className="flex flex-col gap-4 mb-4">
+ <div className="flex flex-col gap-2 md:gap-4 mb-2 md:mb-4">
<RenderMessage
message={section.userMessage}
messageId={section.userMessage.id}
@@ -205,7 +205,10 @@ export function ChatMessages({
messageIndex === section.assistantMessages.length - 1
return (
- <div key={assistantMessage.id} className="flex flex-col gap-4">
+ <div
+ key={assistantMessage.id}
+ className="flex flex-col gap-2 md:gap-4"
+ >
<RenderMessage
message={assistantMessage}
messageId={assistantMessage.id}
@@ -228,7 +231,7 @@ export function ChatMessages({
{/* Show assistant logo after assistant messages */}
{showAssistantLogo && sectionIndex === sections.length - 1 && (
<div className="flex justify-start py-4">
- <AnimatedLogo className="h-10 w-10" animate={isLoading} />
+ <AnimatedLogo className="size-10" animate={isLoading} />
</div>
)}
{sectionIndex === sections.length - 1 && (
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index 209a2898..2abca395 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -154,13 +154,13 @@ export function ChatPanel({
<div
className={cn(
'w-full bg-background group/form-container shrink-0',
- messages.length > 0 ? 'sticky bottom-0 px-2 pb-4' : 'px-6'
+ messages.length > 0 ? 'sticky bottom-0 px-2 pb-2 md:pb-4' : 'px-6'
)}
>
{messages.length === 0 && (
- <div className="mb-10 flex flex-col items-center gap-4">
+ <div className="mb-6 md:mb-10 flex flex-col items-center gap-2 md:gap-4">
<IconBlinkingLogo className="size-12" />
- <h1 className="text-2xl font-medium text-foreground">
+ <h1 className="text-xl md:text-2xl font-medium text-foreground">
What would you like to know?
</h1>
</div>
@@ -217,7 +217,7 @@ export function ChatPanel({
spellCheck={false}
value={input}
disabled={isLoading || isToolInvocationInProgress()}
- className="resize-none w-full min-h-12 bg-transparent border-0 p-4 text-sm placeholder:text-muted-foreground focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
+ className="resize-none w-full min-h-12 bg-transparent border-0 p-3 md:p-4 text-sm placeholder:text-muted-foreground focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
onChange={handleInputChange}
onKeyDown={e => {
if (
@@ -241,7 +241,7 @@ export function ChatPanel({
/>
{/* Bottom menu area */}
- <div className="flex items-center justify-between p-3">
+ <div className="flex items-center justify-between p-2 md:p-3">
<div className="flex items-center gap-2">
{!isGuest && (
<FileUploadButton
@@ -304,7 +304,7 @@ export function ChatPanel({
variant="outline"
size="icon"
onClick={handleNewChat}
- className="shrink-0 rounded-full group"
+ className="shrink-0 size-8 md:size-10 rounded-full group"
type="button"
disabled={isLoading}
>
@@ -314,7 +314,10 @@ export function ChatPanel({
<Button
type={isLoading ? 'button' : 'submit'}
size={'icon'}
- className={cn(isLoading && 'animate-pulse', 'rounded-full')}
+ className={cn(
+ isLoading && 'animate-pulse',
+ 'size-8 md:size-10 rounded-full'
+ )}
disabled={
(input.length === 0 && !isLoading) || !hasAvailableModels
}
@@ -325,7 +328,11 @@ export function ChatPanel({
: 'No enabled model is available'
}
>
- {isLoading ? <Square size={20} /> : <ArrowUp size={20} />}
+ {isLoading ? (
+ <Square className="size-4 md:size-5" />
+ ) : (
+ <ArrowUp className="size-4 md:size-5" />
+ )}
</Button>
</div>
</div>
diff --git a/components/drag-overlay.tsx b/components/drag-overlay.tsx
index 54fc43fb..1cabad1d 100644
--- a/components/drag-overlay.tsx
+++ b/components/drag-overlay.tsx
@@ -12,7 +12,7 @@ export function DragOverlay({ visible }: { visible: boolean }) {
)}
>
<div className="text-center text-muted-foreground">
- <UploadCloud className="mx-auto mb-4 w-10 h-10" />
+ <UploadCloud className="mx-auto mb-4 size-10" />
<p className="text-lg font-semibold">Drop files here</p>
</div>
</div>
diff --git a/components/feedback-modal.tsx b/components/feedback-modal.tsx
index d4306874..d4fbad7e 100644
--- a/components/feedback-modal.tsx
+++ b/components/feedback-modal.tsx
@@ -79,11 +79,11 @@ export function FeedbackModal({ open, onOpenChange }: FeedbackModalProps) {
size="icon"
onClick={() => setSentiment('positive')}
className={cn(
- 'h-12 w-12',
+ 'size-12',
sentiment === 'positive' && 'bg-green-500 hover:bg-green-600'
)}
>
- <Smile className="h-6 w-6" />
+ <Smile className="size-6" />
</Button>
<Button
type="button"
@@ -91,11 +91,11 @@ export function FeedbackModal({ open, onOpenChange }: FeedbackModalProps) {
size="icon"
onClick={() => setSentiment('neutral')}
className={cn(
- 'h-12 w-12',
+ 'size-12',
sentiment === 'neutral' && 'bg-yellow-500 hover:bg-yellow-600'
)}
>
- <Meh className="h-6 w-6" />
+ <Meh className="size-6" />
</Button>
<Button
type="button"
@@ -103,11 +103,11 @@ export function FeedbackModal({ open, onOpenChange }: FeedbackModalProps) {
size="icon"
onClick={() => setSentiment('negative')}
className={cn(
- 'h-12 w-12',
+ 'size-12',
sentiment === 'negative' && 'bg-red-500 hover:bg-red-600'
)}
>
- <Frown className="h-6 w-6" />
+ <Frown className="size-6" />
</Button>
</div>
diff --git a/components/guest-menu.tsx b/components/guest-menu.tsx
index 3b0fe380..46bc7f5e 100644
--- a/components/guest-menu.tsx
+++ b/components/guest-menu.tsx
@@ -28,8 +28,8 @@ export default function GuestMenu() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon" className="h-6 w-6">
- <Settings2 className="h-4 w-4" /> {/* Choose an icon */}
+ <Button variant="ghost" size="icon" className="size-6">
+ <Settings2 className="size-4" /> {/* Choose an icon */}
<span className="sr-only">Open menu</span>
</Button>
</DropdownMenuTrigger>
diff --git a/components/header.tsx b/components/header.tsx
index 44b62aa7..4bc50d60 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -30,7 +30,7 @@ export const Header: React.FC<HeaderProps> = ({ user }) => {
<>
<header
className={cn(
- 'absolute top-0 right-0 p-3 flex justify-between items-center z-10 backdrop-blur-sm lg:backdrop-blur-none bg-background/80 lg:bg-transparent transition-[width] duration-200 ease-linear',
+ 'absolute top-0 right-0 p-2 md:p-3 flex justify-between items-center z-10 backdrop-blur-sm lg:backdrop-blur-none bg-background/80 lg:bg-transparent transition-[width] duration-200 ease-linear',
open ? 'md:w-[calc(100%-var(--sidebar-width))]' : 'md:w-full',
'w-full'
)}
diff --git a/components/reasoning-section.tsx b/components/reasoning-section.tsx
index df7ef538..3d84c451 100644
--- a/components/reasoning-section.tsx
+++ b/components/reasoning-section.tsx
@@ -85,7 +85,7 @@ export function ReasoningSection({
label={
!isSingle ? (
<div className="flex items-center gap-2 min-w-0">
- <div className="w-4 h-4 shrink-0 flex items-center justify-center relative">
+ <div className="size-4 shrink-0 flex items-center justify-center relative">
<div className="w-1.5 h-1.5 rounded-full bg-muted-foreground" />
</div>
<span className="truncate block min-w-0 max-w-full">
diff --git a/components/retry-button.tsx b/components/retry-button.tsx
index 48f44306..7b5b3467 100644
--- a/components/retry-button.tsx
+++ b/components/retry-button.tsx
@@ -15,14 +15,14 @@ export const RetryButton: React.FC<RetryButtonProps> = ({
}) => {
return (
<Button
- className="rounded-full h-8 w-8"
+ className="rounded-full size-8"
type="button"
variant="ghost"
size="icon"
onClick={() => reload()}
aria-label={`Retry from message ${messageId}`}
>
- <RotateCcw className="w-4 h-4" />
+ <RotateCcw className="size-4" />
<span className="sr-only">Retry</span>
</Button>
)
diff --git a/components/search-mode-selector.tsx b/components/search-mode-selector.tsx
index bf12a6be..6d85e48e 100644
--- a/components/search-mode-selector.tsx
+++ b/components/search-mode-selector.tsx
@@ -73,12 +73,13 @@ export function SearchModeSelector() {
<DropdownMenuTrigger asChild>
<Button
variant="outline"
- className="text-sm rounded-full shadow-none gap-1 transition-all"
+ size="sm"
+ className="text-xs rounded-full shadow-none gap-1 transition-all"
>
{SelectedIcon && (
<SelectedIcon
className={cn(
- 'h-4 w-4 transition-colors',
+ 'size-3.5 transition-colors',
selectedMode?.color
)}
/>
@@ -86,7 +87,7 @@ export function SearchModeSelector() {
<span className="text-xs font-medium">{selectedMode?.label}</span>
<ChevronDown
className={cn(
- 'h-3 w-3 ml-1 opacity-50 transition-transform duration-200',
+ 'size-3 ml-0.5 opacity-50 transition-transform duration-200',
dropdownOpen && 'rotate-180'
)}
/>
@@ -103,11 +104,11 @@ export function SearchModeSelector() {
className="relative flex flex-col items-start gap-1 py-2 pl-8 pr-2 cursor-pointer focus:outline-none"
>
{isSelected && (
- <Check className="absolute left-2 top-2.5 h-4 w-4" />
+ <Check className="absolute left-2 top-2.5 size-4" />
)}
<div className="flex items-center gap-2">
<ModeIcon
- className={cn('h-4 w-4 transition-colors', config.color)}
+ className={cn('size-4 transition-colors', config.color)}
/>
<span className="text-sm font-medium">{config.label}</span>
</div>
@@ -182,7 +183,7 @@ export function SearchModeSelector() {
>
<div className="space-y-2">
<div className="flex items-center gap-2">
- <Icon className={cn('h-5 w-5', config.color)} />
+ <Icon className={cn('size-5', config.color)} />
<h4 className="text-sm font-semibold">
{config.label}
</h4>
diff --git a/components/ui/animated-logo.tsx b/components/ui/animated-logo.tsx
index 1ef190fa..47c2c882 100644
--- a/components/ui/animated-logo.tsx
+++ b/components/ui/animated-logo.tsx
@@ -50,7 +50,7 @@ export function AnimatedLogo({
viewBox="0 0 256 256"
role="img"
xmlns="http://www.w3.org/2000/svg"
- className={cn('h-8 w-8', className)}
+ className={cn('size-8', className)}
{...props}
>
<circle cx="128" cy="128" r="128" fill="black"></circle>
diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx
index 48d774c5..cd238b7d 100644
--- a/components/ui/avatar.tsx
+++ b/components/ui/avatar.tsx
@@ -13,7 +13,7 @@ const Avatar = React.forwardRef<
<AvatarPrimitive.Root
ref={ref}
className={cn(
- 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
+ 'relative flex size-10 shrink-0 overflow-hidden rounded-full',
className
)}
{...props}
diff --git a/components/ui/button.tsx b/components/ui/button.tsx
index 99d09be4..274b1ec1 100644
--- a/components/ui/button.tsx
+++ b/components/ui/button.tsx
@@ -24,7 +24,7 @@ const buttonVariants = cva(
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
- icon: 'h-10 w-10'
+ icon: 'size-10'
}
},
defaultVariants: {
diff --git a/components/ui/carousel.tsx b/components/ui/carousel.tsx
index 4cbc73a3..f5165734 100644
--- a/components/ui/carousel.tsx
+++ b/components/ui/carousel.tsx
@@ -208,7 +208,7 @@ const CarouselPrevious = React.forwardRef<
variant={variant}
size={size}
className={cn(
- 'absolute h-8 w-8 rounded-full',
+ 'absolute size-8 rounded-full',
orientation === 'horizontal'
? '-left-12 top-1/2 -translate-y-1/2'
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
@@ -218,7 +218,7 @@ const CarouselPrevious = React.forwardRef<
onClick={scrollPrev}
{...props}
>
- <ArrowLeft className="h-4 w-4" />
+ <ArrowLeft className="size-4" />
<span className="sr-only">Previous slide</span>
</Button>
)
@@ -237,7 +237,7 @@ const CarouselNext = React.forwardRef<
variant={variant}
size={size}
className={cn(
- 'absolute h-8 w-8 rounded-full',
+ 'absolute size-8 rounded-full',
orientation === 'horizontal'
? '-right-12 top-1/2 -translate-y-1/2'
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
@@ -247,7 +247,7 @@ const CarouselNext = React.forwardRef<
onClick={scrollNext}
{...props}
>
- <ArrowRight className="h-4 w-4" />
+ <ArrowRight className="size-4" />
<span className="sr-only">Next slide</span>
</Button>
)
diff --git a/components/ui/icons.tsx b/components/ui/icons.tsx
index d7ed7d06..6df13e43 100644
--- a/components/ui/icons.tsx
+++ b/components/ui/icons.tsx
@@ -11,7 +11,7 @@ function IconLogo({ className, ...props }: React.ComponentProps<'svg'>) {
viewBox="0 0 256 256"
role="img"
xmlns="http://www.w3.org/2000/svg"
- className={cn('h-4 w-4', className)}
+ className={cn('size-4', className)}
{...props}
>
<circle cx="128" cy="128" r="128" fill="black"></circle>
@@ -28,7 +28,7 @@ function IconLogoOutline({ className, ...props }: React.ComponentProps<'svg'>) {
viewBox="0 0 256 256"
role="img"
xmlns="http://www.w3.org/2000/svg"
- className={cn('h-4 w-4', className)}
+ className={cn('size-4', className)}
{...props}
>
<circle
@@ -144,7 +144,7 @@ function IconBlinkingLogo({
viewBox="0 0 256 256"
role="img"
xmlns="http://www.w3.org/2000/svg"
- className={cn('h-4 w-4', className)}
+ className={cn('size-4', className)}
{...props}
>
<circle cx="128" cy="128" r="128" fill="#222"></circle>
diff --git a/components/ui/spinner.tsx b/components/ui/spinner.tsx
index 07bf01a2..9373b745 100644
--- a/components/ui/spinner.tsx
+++ b/components/ui/spinner.tsx
@@ -15,7 +15,7 @@ export const Spinner = ({ className, ...props }: SpinnerProps) => (
strokeLinecap="round"
strokeLinejoin="round"
xmlns="http://www.w3.org/2000/svg"
- className={cn('h-5 w-5 animate-spin stroke-zinc-400', className)}
+ className={cn('size-5 animate-spin stroke-zinc-400', className)}
{...props}
>
<path d="M12 3v3m6.366-.366-2.12 2.12M21 12h-3m.366 6.366-2.12-2.12M12 21v-3m-6.366.366 2.12-2.12M3 12h3m-.366-6.366 2.12 2.12"></path>
@@ -24,6 +24,6 @@ export const Spinner = ({ className, ...props }: SpinnerProps) => (
export const LogoSpinner = () => (
<div className="p-4 border border-background">
- <IconLogo className="w-4 h-4 animate-spin" />
+ <IconLogo className="size-4 animate-spin" />
</div>
)
diff --git a/components/user-menu.tsx b/components/user-menu.tsx
index 9cb6cd06..b56e43b2 100644
--- a/components/user-menu.tsx
+++ b/components/user-menu.tsx
@@ -59,8 +59,8 @@ export default function UserMenu({ user }: UserMenuProps) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="ghost" className="relative h-6 w-6 rounded-full">
- <Avatar className="h-6 w-6">
+ <Button variant="ghost" className="relative size-6 rounded-full">
+ <Avatar className="size-6">
<AvatarImage src={avatarUrl} alt={userName} />
<AvatarFallback>{getInitials(userName, user.email)}</AvatarFallback>
</Avatar>
diff --git a/components/user-text-section.tsx b/components/user-text-section.tsx
index a1cdbf26..c1458c2d 100644
--- a/components/user-text-section.tsx
+++ b/components/user-text-section.tsx
@@ -131,7 +131,7 @@ export const UserTextSection: React.FC<UserTextSectionProps> = ({
<Button
variant="ghost"
size="icon"
- className="rounded-full h-7 w-7"
+ className="rounded-full size-7"
onClick={handleEditClick}
>
<Pencil className="size-3.5" />