Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search page #19

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
11 changes: 7 additions & 4 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Montserrat as FontSans } from "next/font/google";
import localFont from "next/font/local";

import { ReactLenis } from "@/components/common/lenis";
import { SearchHistoryProvider } from "@/components/search/search-history-context";
import { ThemeProvider } from "@/components/theme-provider";
import { Toaster } from "@/components/ui/sonner";
import { cn } from "@/lib/utils";
Expand Down Expand Up @@ -105,10 +106,12 @@ export default async function RootLayout({
)}
>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<TRPCReactProvider>
<ReactLenis>{children}</ReactLenis>
</TRPCReactProvider>
<Toaster />
<SearchHistoryProvider>
<TRPCReactProvider>
<ReactLenis>{children}</ReactLenis>
</TRPCReactProvider>
<Toaster />
</SearchHistoryProvider>
</ThemeProvider>
</body>

Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MoreHorizontalIcon } from "lucide-react";

import { Navbar } from "@/components/common/navbar";
import { Articles } from "@/components/home/articles";
import Sidebar from "@/components/home/sidebar";
import { Sidebar } from "@/components/home/sidebar";
import { Button } from "@/components/ui/button";
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
import { getServerAuthSession } from "@/server/auth";
Expand Down
17 changes: 17 additions & 0 deletions src/app/search/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Navbar } from "@/components/common/navbar";
import { getServerAuthSession } from "@/server/auth";

export default async function SearchLayout({
children,
}: {
children: React.ReactNode;
}) {
const session = await getServerAuthSession();

return (
<>
<Navbar session={session} />
{children}
</>
);
}
9 changes: 9 additions & 0 deletions src/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SearchResult } from "@/components/search/search-result";

export default async function SearchPage() {
return (
<main className="mt-24">
<SearchResult />
</main>
);
}
166 changes: 0 additions & 166 deletions src/components/common/nav.tsx

This file was deleted.

76 changes: 23 additions & 53 deletions src/components/common/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import type { Session } from "next-auth";
import { signOut } from "next-auth/react";
import {
Book,
ListTreeIcon,
LogOut,
Menu,
NewspaperIcon,
Pen,
SearchIcon,
User,
} from "lucide-react";
import { Book, LogOut, Pen, SearchIcon, User } from "lucide-react";

import { NavSheet } from "@/components/common/navsheet";
import { NavSearchInput } from "@/components/search/nav-search-input";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button, buttonVariants } from "@/components/ui/button";
import { buttonVariants } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
Expand All @@ -30,8 +21,6 @@ import {
import logo from "@/images/logo.png";
import { abbreviation, cn } from "@/lib/utils";

import { Nav } from "./nav";

const hideNavbarOnRoutes = ["/login"];

export function Navbar({ session }: { session: Session | null }) {
Expand All @@ -40,57 +29,38 @@ export function Navbar({ session }: { session: Session | null }) {
return (
!hideNavbarOnRoutes.includes(pathname) && (
<nav className="fixed top-0 z-10 w-full drop-shadow-md">
<div className="container flex items-center gap-x-4 bg-background py-2 backdrop-blur-md sm:justify-between">
<div className="container flex items-center justify-between gap-x-4 bg-background py-2 backdrop-blur-md">
<div className="flex items-center gap-x-5">
<div className="flex items-center gap-x-2">
<NavSheet>
<Button size="icon" variant="outline">
<Menu className="h-6 w-6" />
</Button>
</NavSheet>

<Image
src={logo}
alt="HIMARPL Logo"
className="hidden w-12 md:block"
/>
<Link href="/">
<Image src={logo} alt="HIMARPL Logo" className="w-12" />
</Link>
</div>

<Nav
className="hidden md:flex"
links={[
{
title: "Postingan Terbaru",
href: "/",
icon: NewspaperIcon,
variant: "ghost",
},
{
title: "Telusuri Label",
href: "/explore-tags",
icon: ListTreeIcon,
variant: "ghost",
},
{
title: "Cari Postingan",
href: "/search",
icon: SearchIcon,
variant: "ghost",
},
]}
/>
<NavSearchInput />
</div>

{session && (
<div className="flex w-full items-center gap-x-4 sm:ml-auto sm:w-fit">
<div className="flex items-center gap-x-4">
<Link
href="/search"
className={cn(
buttonVariants({ variant: "outline", size: "icon" }),
"w-10 md:hidden",
)}
>
<SearchIcon className="h-5 w-5" />
</Link>

<Link
href="/new"
className={cn(
buttonVariants({ variant: "outline" }),
"w-full md:min-w-20",
buttonVariants({ variant: "outline", size: "icon" }),
"h-10 w-10 md:min-w-20",
)}
>
<Pen className="mr-2 h-4 w-4" /> Buat
<Pen className="h-4 w-4 md:mr-2" />
<span className="hidden md:inline"> Buat</span>
</Link>

<DropdownMenu>
Expand Down
56 changes: 0 additions & 56 deletions src/components/common/navsheet.tsx

This file was deleted.

Loading