Skip to content

Commit 9a872fc

Browse files
authored
Merge pull request #463 from miurla/feat/unified-header-navigation
feat: Unify navigation in header for all devices
2 parents 3e57e9e + 42624f7 commit 9a872fc

File tree

5 files changed

+14
-37
lines changed

5 files changed

+14
-37
lines changed

app/layout.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Footer from '@/components/footer'
22
import Header from '@/components/header'
3-
import { Sidebar } from '@/components/sidebar'
43
import { ThemeProvider } from '@/components/theme-provider'
54
import { Toaster } from '@/components/ui/sonner'
65
import { cn } from '@/lib/utils'
@@ -45,8 +44,6 @@ export default function RootLayout({
4544
}: Readonly<{
4645
children: React.ReactNode
4746
}>) {
48-
const enableSaveChatHistory =
49-
process.env.ENABLE_SAVE_CHAT_HISTORY === 'true'
5047
return (
5148
<html lang="en" suppressHydrationWarning>
5249
<body className={cn('font-sans antialiased', fontSans.variable)}>
@@ -58,7 +55,6 @@ export default function RootLayout({
5855
>
5956
<Header />
6057
{children}
61-
{enableSaveChatHistory && <Sidebar />}
6258
<Footer />
6359
<Toaster />
6460
</ThemeProvider>

components/header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IconLogo } from './ui/icons'
66

77
export const Header: React.FC = async () => {
88
return (
9-
<header className="fixed w-full p-2 flex justify-between items-center z-10 backdrop-blur md:backdrop-blur-none bg-background/80 md:bg-transparent">
9+
<header className="fixed w-full p-2 flex justify-between items-center z-10 backdrop-blur lg:backdrop-blur-none bg-background/80 lg:bg-transparent">
1010
<div>
1111
<a href="/">
1212
<IconLogo className={cn('w-5 h-5')} />
@@ -15,7 +15,7 @@ export const Header: React.FC = async () => {
1515
</div>
1616
<div className="flex gap-0.5">
1717
<ModeToggle />
18-
<HistoryContainer location="header" />
18+
<HistoryContainer />
1919
</div>
2020
</header>
2121
)

components/history-container.tsx

+4-13
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,15 @@ import React from 'react'
22
import { History } from './history'
33
import { HistoryList } from './history-list'
44

5-
type HistoryContainerProps = {
6-
location: 'sidebar' | 'header'
7-
}
8-
9-
const HistoryContainer: React.FC<HistoryContainerProps> = async ({
10-
location
11-
}) => {
12-
const enableSaveChatHistory =
13-
process.env.ENABLE_SAVE_CHAT_HISTORY === 'true'
5+
const HistoryContainer: React.FC = async () => {
6+
const enableSaveChatHistory = process.env.ENABLE_SAVE_CHAT_HISTORY === 'true'
147
if (!enableSaveChatHistory) {
158
return null
169
}
1710

1811
return (
19-
<div
20-
className={location === 'header' ? 'block lg:hidden' : 'hidden sm:block'}
21-
>
22-
<History location={location}>
12+
<div>
13+
<History>
2314
<HistoryList userId="anonymous" />
2415
</History>
2516
</div>

components/history.tsx

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
'use client'
22

3-
import { useTransition } from 'react'
4-
import { useRouter } from 'next/navigation'
3+
import { Button } from '@/components/ui/button'
54
import {
65
Sheet,
76
SheetContent,
87
SheetHeader,
98
SheetTitle,
109
SheetTrigger
1110
} from '@/components/ui/sheet'
12-
import { Button } from '@/components/ui/button'
13-
import { ChevronLeft, Menu } from 'lucide-react'
14-
import { cn } from '@/lib/utils'
15-
import { History as HistoryIcon } from 'lucide-react'
16-
import { Suspense } from 'react'
11+
import { History as HistoryIcon, Menu } from 'lucide-react'
12+
import { useRouter } from 'next/navigation'
13+
import { Suspense, useTransition } from 'react'
1714
import { HistorySkeleton } from './history-skeleton'
1815

1916
type HistoryProps = {
20-
location: 'sidebar' | 'header'
2117
children?: React.ReactNode
2218
}
2319

24-
export function History({ location, children }: HistoryProps) {
20+
export function History({ children }: HistoryProps) {
2521
const router = useRouter()
2622
const [isPending, startTransition] = useTransition()
2723

@@ -36,14 +32,8 @@ export function History({ location, children }: HistoryProps) {
3632
return (
3733
<Sheet onOpenChange={onOpenChange}>
3834
<SheetTrigger asChild>
39-
<Button
40-
variant="ghost"
41-
size="icon"
42-
className={cn({
43-
'rounded-full text-foreground/30': location === 'sidebar'
44-
})}
45-
>
46-
{location === 'header' ? <Menu /> : <ChevronLeft size={16} />}
35+
<Button variant="ghost" size="icon">
36+
<Menu />
4737
</Button>
4838
</SheetTrigger>
4939
<SheetContent className="w-64 rounded-tl-xl rounded-bl-xl">

components/sidebar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import HistoryContainer from './history-container'
33
export async function Sidebar() {
44
return (
55
<div className="h-screen p-2 fixed top-0 right-0 flex-col justify-center pb-24 hidden lg:flex">
6-
<HistoryContainer location="sidebar" />
6+
<HistoryContainer />
77
</div>
88
)
99
}

0 commit comments

Comments
 (0)