Skip to content

An AI-powered search engine with a generative UI

Update UI layout for mobile

Yoshiki Miurae656c5cdbd61
diff --git a/app/action.tsx b/app/action.tsx
index 784eaa53..7e54db5e 100644
--- a/app/action.tsx
+++ b/app/action.tsx
@@ -50,7 +50,7 @@ async function submit(formData?: FormData, skip?: boolean) {
isGenerating.done()
aiState.done([
...aiState.get(),
- { role: 'assistant', content: `inquiry: ${inquiry?.inquiry}` }
+ { role: 'assistant', content: `inquiry: ${inquiry?.question}` }
])
return
}
diff --git a/app/layout.tsx b/app/layout.tsx
index 1e4fbe5a..836739a3 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -24,12 +24,7 @@ export default function RootLayout({
}>) {
return (
<html lang="en" suppressHydrationWarning>
- <body
- className={cn(
- 'min-h-screen bg-background font-sans antialiased',
- fontSans.variable
- )}
- >
+ <body className={cn('font-sans antialiased', fontSans.variable)}>
<ThemeProvider
attribute="class"
defaultTheme="system"
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index bd0e1f50..ade8e1f4 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -70,7 +70,7 @@ export function ChatPanel() {
// If there are messages and the new button has not been pressed, display the new Button
if (messages.length > 0 && !isButtonPressed) {
return (
- <div className="fixed bottom-8 left-0 right-0 flex justify-center items-center mx-auto">
+ <div className="fixed bottom-2 md:bottom-8 left-0 right-0 flex justify-center items-center mx-auto">
<Button
type="button"
variant={'secondary'}
diff --git a/components/chat.tsx b/components/chat.tsx
index e969c18b..bb1b0d31 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -5,7 +5,7 @@ import { ChatMessages } from './chat-messages'
export function Chat() {
return (
- <div className="px-12 pt-8 pb-24 max-w-3xl mx-auto flex flex-col space-y-4">
+ <div className="px-8 md:px-12 pt-6 md:pt-8 pb-14 md:pb-24 max-w-3xl mx-auto flex flex-col space-y-3 md:space-y-4">
<ChatMessages />
<ChatPanel />
</div>
diff --git a/components/copilot.tsx b/components/copilot.tsx
index c12292e5..c3c40dfa 100644
--- a/components/copilot.tsx
+++ b/components/copilot.tsx
@@ -104,14 +104,14 @@ export const Copilot: React.FC<CopilotProps> = ({
if (completed) {
return (
- <Card className="p-4 w-full flex justify-between items-center">
- <div className="flex items-center space-x-2">
- <IconLogo className="w-4 h-4" />
+ <Card className="p-3 md:p-4 w-full flex justify-between items-center">
+ <div className="flex items-center space-x-2 flex-1 min-w-0">
+ <IconLogo className="w-4 h-4 flex-shrink-0" />
<h5 className="text-muted-foreground text-xs truncate">
{updatedQuery()}
</h5>
</div>
- <Check size={16} className="text-green-500" />
+ <Check size={16} className="text-green-500 w-4 h-4" />
</Card>
)
} else {
diff --git a/components/footer.tsx b/components/footer.tsx
index 1bfc8ca2..e3f53c7e 100644
--- a/components/footer.tsx
+++ b/components/footer.tsx
@@ -5,7 +5,7 @@ import { Button } from './ui/button'
const Footer: React.FC = () => {
return (
- <footer className="w-fit p-2 fixed bottom-0 right-0">
+ <footer className="w-fit p-1 md:p-2 fixed bottom-0 right-0">
<div className="flex justify-end">
{/* <Button
variant={'ghost'}
diff --git a/components/header.tsx b/components/header.tsx
index c091bab6..d9ec989c 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -8,7 +8,7 @@ import { cn } from '@/lib/utils'
export const Header: React.FC = () => {
return (
- <header className="fixed w-full p-2 flex justify-between items-center z-10">
+ <header className="fixed w-full p-0 md:p-2 flex justify-between items-center z-10 backdrop-blur md:backdrop-blur-none bg-background/80 md:bg-transparent">
<div className="p-2">
<a href="/">
<IconLogo className={cn('w-5 h-5')} />
diff --git a/components/search-related.tsx b/components/search-related.tsx
index 7b611a39..5bc6057a 100644
--- a/components/search-related.tsx
+++ b/components/search-related.tsx
@@ -52,15 +52,15 @@ export const SearchRelated: React.FC<SearchRelatedProps> = ({
{data?.items
?.filter(item => item?.query !== '')
.map((item, index) => (
- <div className="w-full" key={index}>
+ <div className="flex items-start w-full" key={index}>
+ <ArrowRight className="h-4 w-4 mr-2 mt-1 flex-shrink-0 text-accent-foreground/50" />
<Button
variant="link"
- className="w-fit justify-start px-0 py-1 h-fit font-semibold text-accent-foreground/50 whitespace-normal text-left"
+ className="flex-1 justify-start px-0 py-1 h-fit font-semibold text-accent-foreground/50 whitespace-normal text-left"
type="submit"
name={'related_query'}
value={item?.query}
>
- <ArrowRight className="h-4 w-4 mr-2 text-accent-foreground/50" />
{item?.query}
</Button>
</div>
diff --git a/components/search-results-image.tsx b/components/search-results-image.tsx
index cfded555..35bb9f45 100644
--- a/components/search-results-image.tsx
+++ b/components/search-results-image.tsx
@@ -59,12 +59,12 @@ export const SearchResultsImageSection: React.FC<
}
return (
- <div className="flex space-x-2">
+ <div className="flex flex-wrap gap-2">
{images.slice(0, 4).map((image: any, index: number) => (
<Dialog key={index}>
<DialogTrigger asChild>
<div
- className="w-1/4 aspect-video cursor-pointer relative"
+ className="w-[calc(50%-0.5rem)] md:w-[calc(25%-0.5rem)] aspect-video cursor-pointer relative"
onClick={() => setSelectedIndex(index)}
>
<Card className="flex-1 h-full">
@@ -80,11 +80,6 @@ export const SearchResultsImageSection: React.FC<
)}
</CardContent>
</Card>
- {/* {index === 3 && images.length > 4 && (
- <div className="absolute inset-0 bg-black bg-opacity-50 rounded-md flex items-center justify-center text-white/80 text-sm">
- View more
- </div>
- )} */}
</div>
</DialogTrigger>
<DialogContent className="sm:max-w-3xl">
diff --git a/components/search-results.tsx b/components/search-results.tsx
index 78d3db5f..75c11bfd 100644
--- a/components/search-results.tsx
+++ b/components/search-results.tsx
@@ -24,7 +24,7 @@ export function SearchResults({ results }: SearchResultsProps) {
return (
<div className="flex flex-wrap">
{displayedResults.map((result: any, index: any) => (
- <div className="w-1/4 p-1" key={index}>
+ <div className="w-1/2 md:w-1/4 p-1" key={index}>
<Link href={result.url} passHref target="_blank">
<Card className="flex-1">
<CardContent className="p-2">
@@ -51,7 +51,7 @@ export function SearchResults({ results }: SearchResultsProps) {
</div>
))}
{!showAllResults && additionalResultsCount > 0 && (
- <div className="w-1/4 p-1">
+ <div className="w-1/2 md:w-1/4 p-1">
<Card className="flex-1 flex h-full items-center justify-center">
<CardContent className="p-2">
<Button
diff --git a/components/search-skeleton.tsx b/components/search-skeleton.tsx
index 17d4039c..248f13b1 100644
--- a/components/search-skeleton.tsx
+++ b/components/search-skeleton.tsx
@@ -7,9 +7,12 @@ export const SearchSkeleton = () => {
return (
<div>
<Skeleton className="h-6 w-48" />
- <div className="flex flex-wrap space-x-2">
+ <div className="flex flex-wrap gap-2">
{Array.from({ length: 4 }).map((_, index) => (
- <div className="w-[24%]" key={index}>
+ <div
+ className="w-[calc(50%-0.5rem)] md:w-[calc(25%-0.5rem)] p-2"
+ key={index}
+ >
<div className="flex-1">
<div className="pt-2">
<Skeleton className="h-6 mb-2" />