chore: scaffold turbo monorepo with hono api and react admin web
This commit is contained in:
42
apps/web/src/components/layout/app-header.tsx
Normal file
42
apps/web/src/components/layout/app-header.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useRouterState } from '@tanstack/react-router'
|
||||
import { SearchIcon } from 'lucide-react'
|
||||
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { SidebarTrigger } from '@/components/ui/sidebar'
|
||||
import { ThemeToggle } from '@/components/theme-toggle'
|
||||
|
||||
function usePageTitle() {
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname })
|
||||
|
||||
if (pathname === '/') return 'Dashboard'
|
||||
|
||||
const segment = pathname.split('/').filter(Boolean).at(0) ?? ''
|
||||
return segment.charAt(0).toUpperCase() + segment.slice(1)
|
||||
}
|
||||
|
||||
export function AppHeader() {
|
||||
const title = usePageTitle()
|
||||
|
||||
return (
|
||||
<header className="bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-10 flex h-16 shrink-0 items-center gap-2 border-b backdrop-blur">
|
||||
<div className="flex w-full items-center gap-2 px-4">
|
||||
<SidebarTrigger className="-ml-1" />
|
||||
<Separator orientation="vertical" className="mr-2 h-4" />
|
||||
<h1 className="text-sm font-medium">{title}</h1>
|
||||
<div className="ml-auto flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
className="text-muted-foreground hover:bg-accent hover:text-accent-foreground mr-1 hidden items-center gap-2 rounded-md border px-3 py-1.5 text-xs md:flex"
|
||||
>
|
||||
<SearchIcon className="size-3.5" />
|
||||
Search
|
||||
<kbd className="bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-mono text-[10px]">
|
||||
⌘K
|
||||
</kbd>
|
||||
</button>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user