fix: header
This commit is contained in:
1 parent
095f7361fa
commit
1a762d00c5
13 files changed
+432
-105
No files matched your search
@@ -1,29 +1,76 @@
|
||||
'use client';
|
||||
|
||||
import { Menu } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuRadioGroup,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
NavigationMenu,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuLink,
|
||||
NavigationMenuList,
|
||||
navigationMenuTriggerStyle
|
||||
} from '@/components/ui/navigation-menu';
|
||||
|
||||
export default function Navigation() {
|
||||
const path = usePathname();
|
||||
const paths = [
|
||||
{ path: '/popular', title: 'Popular' },
|
||||
{ path: '/top', title: 'Top rated' },
|
||||
{ path: '/favorites', title: 'Favorites' }
|
||||
];
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function NavigationSmall({ className }: Props) {
|
||||
const currentPath = usePathname();
|
||||
|
||||
return (
|
||||
<Tabs value={path} className='flex-grow'>
|
||||
<TabsList className='flex w-full'>
|
||||
{[
|
||||
{ path: '/', title: 'Random' },
|
||||
{ path: '/popular', title: 'Popular' },
|
||||
{ path: '/top', title: 'Top rated' },
|
||||
{ path: '/favorites', title: 'Favorites' }
|
||||
].map(({ path, title }) => (
|
||||
<Link href={path} className='w-full' key={path} shallow>
|
||||
<TabsTrigger className='w-full' value={path}>
|
||||
{title}
|
||||
</TabsTrigger>
|
||||
</Link>
|
||||
<div className={className}>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant='ghost' size='icon'>
|
||||
<Menu size={19} />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuRadioGroup value={currentPath}>
|
||||
{paths.map(({ path, title }) => (
|
||||
<Link href={path} legacyBehavior shallow key={path}>
|
||||
<DropdownMenuRadioItem value={path}>{title}</DropdownMenuRadioItem>
|
||||
</Link>
|
||||
))}
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Navigation({ className }: Props) {
|
||||
const currentPath = usePathname();
|
||||
|
||||
return (
|
||||
<NavigationMenu className={className}>
|
||||
<NavigationMenuList>
|
||||
{paths.map(({ path, title }) => (
|
||||
<NavigationMenuItem key={path}>
|
||||
<Link href={path} shallow passHref legacyBehavior>
|
||||
<NavigationMenuLink active={path === currentPath} className={navigationMenuTriggerStyle()}>
|
||||
{title}
|
||||
</NavigationMenuLink>
|
||||
</Link>
|
||||
</NavigationMenuItem>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
</NavigationMenuList>
|
||||
</NavigationMenu>
|
||||
);
|
||||
}
|
||||
@@ -76,8 +76,8 @@ export const showSearchModal = create(Search);
|
||||
|
||||
export default function ToggleSearch() {
|
||||
return (
|
||||
<Button variant='outline' size='icon' onClick={() => showSearchModal()}>
|
||||
<SearchIcon />
|
||||
<Button variant='ghost' size='icon' onClick={() => showSearchModal()}>
|
||||
<SearchIcon size={19} />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import { useTheme } from '@/hooks/useTheme';
|
||||
export default function ThemeToggle() {
|
||||
const [theme, setTheme] = useTheme();
|
||||
return (
|
||||
<Button variant='outline' size='icon' onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
|
||||
{theme === 'light' ? <Moon /> : <Sun />}
|
||||
<Button variant='ghost' size='icon' onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
|
||||
{theme === 'light' ? <Moon size={19} /> : <Sun size={19} />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -3,23 +3,22 @@ import Link from 'next/link';
|
||||
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
|
||||
import Navigation from './components/Navigation';
|
||||
import Navigation, { NavigationSmall } from './components/Navigation';
|
||||
import ToggleSearch from './components/Search';
|
||||
import ToggleTheme from './components/ThemeToggle';
|
||||
|
||||
const Header: FC = () => (
|
||||
<header className='flex justify-center bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 sticky pt-2 pb-2 top-0 z-10'>
|
||||
<div className='max-w-[1260px] w-full px-[12px]'>
|
||||
<div className='flex items-center justify-between gap-2 flex-wrap md:flex-nowrap'>
|
||||
<Link href='/' shallow>
|
||||
<header className='flex justify-center bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 sticky py-2 top-0 z-10'>
|
||||
<div className='max-w-[1260px] w-full px-2'>
|
||||
<div className='flex items-center justify-between gap-2 md:flex-nowrap'>
|
||||
<Link href='/' shallow legacyBehavior>
|
||||
<Badge className='whitespace-nowrap'>Movie advisor</Badge>
|
||||
</Link>
|
||||
<div className='w-full order-3 md:order-none'>
|
||||
<Navigation />
|
||||
</div>
|
||||
<Navigation className='hidden sm:flex' />
|
||||
<div className='flex items-center gap-2'>
|
||||
<ToggleTheme />
|
||||
<ToggleSearch />
|
||||
<NavigationSmall className='flex sm:hidden' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user