From 1a762d00c5b2853a7b983501be893c8b64394ac0 Mon Sep 17 00:00:00 2001 From: ner Date: Fri, 22 Mar 2024 13:41:31 +0200 Subject: [PATCH] fix: header --- app/(site)/container.tsx | 6 +- app/layout.tsx | 13 +- .../Header/components/Navigation/index.tsx | 83 ++++++-- components/Header/components/Search/index.tsx | 4 +- .../Header/components/ThemeToggle/index.tsx | 4 +- components/Header/index.tsx | 15 +- components/Movie/Preview/index.tsx | 2 +- components/Movie/components/Credits/index.tsx | 2 +- .../Movie/components/Torrents/index.tsx | 17 +- components/ui/dropdown-menu.tsx | 200 ++++++++++++++++++ components/ui/navigation-menu.tsx | 120 +++++++++++ components/ui/tabs.tsx | 55 ----- styles/index.css | 16 +- 13 files changed, 432 insertions(+), 105 deletions(-) create mode 100644 components/ui/dropdown-menu.tsx create mode 100644 components/ui/navigation-menu.tsx delete mode 100644 components/ui/tabs.tsx diff --git a/app/(site)/container.tsx b/app/(site)/container.tsx index a79039f..d12edf3 100644 --- a/app/(site)/container.tsx +++ b/app/(site)/container.tsx @@ -34,8 +34,8 @@ export default function Container() { return ( <> {isShowFilter && } -
- -
diff --git a/app/layout.tsx b/app/layout.tsx index 8b85aba..2ec8277 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,6 +1,6 @@ import React, { ReactNode } from 'react'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; -import type { Metadata } from 'next'; +import type { Metadata, Viewport } from 'next'; import { cookies } from 'next/headers'; import Header from '@/components/Header'; @@ -13,19 +13,26 @@ export const metadata: Metadata = { description: 'It is going to help you find a movie for evening' }; +export const viewport: Viewport = { + themeColor: 'black', + width: 'device-width', + initialScale: 1, + maximumScale: 1, + userScalable: false +}; + export default function RootLayout({ children }: { children: ReactNode }) { const theme = cookies().get('theme')?.value as Theme; return ( -
-
{children}
+
{children}
diff --git a/components/Header/components/Navigation/index.tsx b/components/Header/components/Navigation/index.tsx index ff73af9..9decc42 100644 --- a/components/Header/components/Navigation/index.tsx +++ b/components/Header/components/Navigation/index.tsx @@ -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 ( - - - {[ - { path: '/', title: 'Random' }, - { path: '/popular', title: 'Popular' }, - { path: '/top', title: 'Top rated' }, - { path: '/favorites', title: 'Favorites' } - ].map(({ path, title }) => ( - - - {title} - - +
+ + + + + + + {paths.map(({ path, title }) => ( + + {title} + + ))} + + + +
+ ); +} + +export default function Navigation({ className }: Props) { + const currentPath = usePathname(); + + return ( + + + {paths.map(({ path, title }) => ( + + + + {title} + + + ))} -
-
+ + ); } diff --git a/components/Header/components/Search/index.tsx b/components/Header/components/Search/index.tsx index 90d3a37..9f72b03 100644 --- a/components/Header/components/Search/index.tsx +++ b/components/Header/components/Search/index.tsx @@ -76,8 +76,8 @@ export const showSearchModal = create(Search); export default function ToggleSearch() { return ( - ); } diff --git a/components/Header/components/ThemeToggle/index.tsx b/components/Header/components/ThemeToggle/index.tsx index c65be0d..e209585 100644 --- a/components/Header/components/ThemeToggle/index.tsx +++ b/components/Header/components/ThemeToggle/index.tsx @@ -8,8 +8,8 @@ import { useTheme } from '@/hooks/useTheme'; export default function ThemeToggle() { const [theme, setTheme] = useTheme(); return ( - ); } diff --git a/components/Header/index.tsx b/components/Header/index.tsx index e8b77db..6c9a4e4 100644 --- a/components/Header/index.tsx +++ b/components/Header/index.tsx @@ -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 = () => ( -
-
-
- +
+
+
+ Movie advisor -
- -
+
+
diff --git a/components/Movie/Preview/index.tsx b/components/Movie/Preview/index.tsx index 9ee86a1..67dade8 100644 --- a/components/Movie/Preview/index.tsx +++ b/components/Movie/Preview/index.tsx @@ -34,7 +34,7 @@ const Preview: FC = ({ movie, className, direction, onClose }) => { return (
-
+
= ({ movieId, onPersonClick }) => { return ( Boolean(credits?.length) && ( -
+
{credits?.map((actor) => ( { }); const Torrents: FC = ({ title, year, isOpen, onResolve }) => { - const host = useAtomValue(hostAtom); + const hosts = useAtomValue(hostAtom); const [sorting, setSorting] = useState({ by: ORDER.seeders }); const [withYear, setWithYear] = useState(true); @@ -80,8 +80,10 @@ const Torrents: FC = ({ title, year, isOpen, onResolve }) => { const handleCast = (magnet: string) => (event: React.MouseEvent) => { event.preventDefault(); - const link = window.open(`http://${host}:65220/playuri?uri=${magnet}`, '_blank'); - setTimeout(() => link?.close(), 100); + hosts.split(',').forEach((host) => { + const link = window.open(`http://${host}:65220/playuri?uri=${magnet}`, '_blank'); + setTimeout(() => link?.close(), 100); + }); }; return ( @@ -89,8 +91,8 @@ const Torrents: FC = ({ title, year, isOpen, onResolve }) => { - - Title: {title}{' '} + + {title}{' '} = ({ title, year, isOpen, onResolve }) => { {year} + + + Title showHostManagerModal()}> @@ -117,7 +122,7 @@ const Torrents: FC = ({ title, year, isOpen, onResolve }) => { {torrent.seeders}
- {host ? ( + {hosts ? ( , + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, children, ...props }, ref) => ( + + {children} + + +)) +DropdownMenuSubTrigger.displayName = + DropdownMenuPrimitive.SubTrigger.displayName + +const DropdownMenuSubContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DropdownMenuSubContent.displayName = + DropdownMenuPrimitive.SubContent.displayName + +const DropdownMenuContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, sideOffset = 4, ...props }, ref) => ( + + + +)) +DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName + +const DropdownMenuItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, ...props }, ref) => ( + +)) +DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName + +const DropdownMenuCheckboxItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, checked, ...props }, ref) => ( + + + + + + + {children} + +)) +DropdownMenuCheckboxItem.displayName = + DropdownMenuPrimitive.CheckboxItem.displayName + +const DropdownMenuRadioItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + + + + {children} + +)) +DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName + +const DropdownMenuLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean + } +>(({ className, inset, ...props }, ref) => ( + +)) +DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName + +const DropdownMenuSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName + +const DropdownMenuShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ) +} +DropdownMenuShortcut.displayName = "DropdownMenuShortcut" + +export { + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuGroup, + DropdownMenuPortal, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuRadioGroup, +} diff --git a/components/ui/navigation-menu.tsx b/components/ui/navigation-menu.tsx new file mode 100644 index 0000000..af73e42 --- /dev/null +++ b/components/ui/navigation-menu.tsx @@ -0,0 +1,120 @@ +import * as React from 'react'; +import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'; +import { cva } from 'class-variance-authority'; +import { ChevronDown } from 'lucide-react'; + +import { cn } from '@/lib/utils'; + +const NavigationMenu = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + {children} + + +)); +NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName; + +const NavigationMenuList = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName; + +const NavigationMenuItem = NavigationMenuPrimitive.Item; + +const navigationMenuTriggerStyle = cva( + 'group inline-flex h-10 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/90 data-[state=open]:bg-accent/50' +); + +const NavigationMenuTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + {children}{' '} + +)); +NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName; + +const NavigationMenuContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName; + +const NavigationMenuLink = NavigationMenuPrimitive.Link; + +const NavigationMenuViewport = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ +
+)); +NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName; + +const NavigationMenuIndicator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +
+ +)); +NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName; + +export { + NavigationMenu, + NavigationMenuContent, + NavigationMenuIndicator, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + navigationMenuTriggerStyle, + NavigationMenuViewport +}; diff --git a/components/ui/tabs.tsx b/components/ui/tabs.tsx deleted file mode 100644 index 6fcdc41..0000000 --- a/components/ui/tabs.tsx +++ /dev/null @@ -1,55 +0,0 @@ -'use client' - -import * as React from 'react' -import * as TabsPrimitive from '@radix-ui/react-tabs' - -import { cn } from '@/lib/utils' - -const Tabs = TabsPrimitive.Root - -const TabsList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -TabsList.displayName = TabsPrimitive.List.displayName - -const TabsTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -TabsTrigger.displayName = TabsPrimitive.Trigger.displayName - -const TabsContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -TabsContent.displayName = TabsPrimitive.Content.displayName - -export { Tabs, TabsContent,TabsList, TabsTrigger } diff --git a/styles/index.css b/styles/index.css index 0d61458..f77d968 100644 --- a/styles/index.css +++ b/styles/index.css @@ -2,6 +2,16 @@ @tailwind components; @tailwind utilities; +@layer utilities { + .no-scrollbar::-webkit-scrollbar { + display: none; + } + .no-scrollbar { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ + } +} + @layer base { :root { --background: 0 0% 100%; @@ -89,9 +99,3 @@ -ms-user-select: none; user-select: none; } - -main { - max-width: 1260px; - margin: 0 auto; - padding: 0 12px; -}