mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37:44 +00:00
feat: add search functionality to mobile navigation (#4487)
This commit is contained in:
committed by
Alex Yang
parent
b531dbb272
commit
7d6d4da92b
33
docs/components/mobile-search-icon.tsx
Normal file
33
docs/components/mobile-search-icon.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Search } from "lucide-react";
|
||||||
|
import { useSearchContext } from "fumadocs-ui/provider";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
interface MobileSearchIconProps {
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MobileSearchIcon({ className }: MobileSearchIconProps) {
|
||||||
|
const { setOpenSearch } = useSearchContext();
|
||||||
|
|
||||||
|
const handleSearchClick = () => {
|
||||||
|
setOpenSearch(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
aria-label="Search"
|
||||||
|
onClick={handleSearchClick}
|
||||||
|
className={cn(
|
||||||
|
"flex ring-0 shrink-0 md:hidden size-9 hover:bg-transparent",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Search className="size-4" />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { Logo } from "./logo";
|
|||||||
import LogoContextMenu from "./logo-context-menu";
|
import LogoContextMenu from "./logo-context-menu";
|
||||||
import DarkPng from "../public/branding/better-auth-logo-dark.png";
|
import DarkPng from "../public/branding/better-auth-logo-dark.png";
|
||||||
import WhitePng from "../public/branding/better-auth-logo-light.png";
|
import WhitePng from "../public/branding/better-auth-logo-light.png";
|
||||||
|
import { MobileSearchIcon } from "@/components/mobile-search-icon";
|
||||||
export const Navbar = () => {
|
export const Navbar = () => {
|
||||||
const logoAssets = {
|
const logoAssets = {
|
||||||
darkSvg: `
|
darkSvg: `
|
||||||
@@ -97,6 +98,7 @@ export const Navbar = () => {
|
|||||||
</svg>
|
</svg>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</ul>
|
</ul>
|
||||||
|
<MobileSearchIcon />
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
<NavbarMobileBtn />
|
<NavbarMobileBtn />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { ChevronRight, Menu } from "lucide-react";
|
import { ChevronRight, Menu, Search } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Fragment, createContext, useContext, useState } from "react";
|
import { Fragment, createContext, useContext, useState } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import { contents, examples } from "./sidebar-content";
|
import { contents, examples } from "./sidebar-content";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useSearchContext } from "fumadocs-ui/provider";
|
||||||
|
|
||||||
interface NavbarMobileContextProps {
|
interface NavbarMobileContextProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ export function CustomSearchDialog(props: SharedProps) {
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<SearchDialogOverlay />
|
<SearchDialogOverlay />
|
||||||
<SearchDialogContent>
|
<SearchDialogContent className="mt-12 md:mt-0">
|
||||||
<SearchDialogHeader>
|
<SearchDialogHeader>
|
||||||
<SearchDialogIcon />
|
<SearchDialogIcon />
|
||||||
<SearchDialogInput />
|
<SearchDialogInput />
|
||||||
<SearchDialogClose />
|
<SearchDialogClose className="hidden md:block" />
|
||||||
</SearchDialogHeader>
|
</SearchDialogHeader>
|
||||||
<SearchDialogList items={query.data !== "empty" ? query.data : null} />
|
<SearchDialogList items={query.data !== "empty" ? query.data : null} />
|
||||||
<SearchDialogFooter>
|
<SearchDialogFooter>
|
||||||
|
|||||||
Reference in New Issue
Block a user