fix: navigation
This commit is contained in:
1 parent
c6d306cb7b
commit
585094dd24
9 files changed
+60
-37
No files matched your search
@@ -9,7 +9,7 @@ export default function Navigation() {
|
|||||||
const path = usePathname();
|
const path = usePathname();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs value={path} className='flex-grow mt-2'>
|
<Tabs value={path} className='flex-grow'>
|
||||||
<TabsList className='flex w-full'>
|
<TabsList className='flex w-full'>
|
||||||
{[
|
{[
|
||||||
{ path: '/', title: 'Random' },
|
{ path: '/', title: 'Random' },
|
||||||
|
|||||||
@@ -8,17 +8,21 @@ import ToggleSearch from './components/Search';
|
|||||||
import ToggleTheme from './components/ThemeToggle';
|
import ToggleTheme from './components/ThemeToggle';
|
||||||
|
|
||||||
const Header: FC = () => (
|
const Header: FC = () => (
|
||||||
<header className='bg-background sticky pt-[12px] pb-2 top-0 z-10'>
|
<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='flex items-center justify-between'>
|
<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='/'>
|
<Link href='/'>
|
||||||
<Badge className='whitespace-nowrap'>Movie advisor</Badge>
|
<Badge className='whitespace-nowrap'>Movie advisor</Badge>
|
||||||
</Link>
|
</Link>
|
||||||
|
<div className='w-full order-3 md:order-none'>
|
||||||
|
<Navigation />
|
||||||
|
</div>
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<ToggleTheme />
|
<ToggleTheme />
|
||||||
<ToggleSearch />
|
<ToggleSearch />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Navigation />
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -64,16 +64,20 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
|
|||||||
>
|
>
|
||||||
{pages.map((page) => (
|
{pages.map((page) => (
|
||||||
<Fragment key={page.page}>
|
<Fragment key={page.page}>
|
||||||
{filterUnknownMovies(page.results)?.map((movie, index, array) => (
|
{filterUnknownMovies(page.results)?.map((movie, index, array) => {
|
||||||
|
const isAnchor = Math.round(array.length / 2) === index;
|
||||||
|
|
||||||
|
return (
|
||||||
<motion.li
|
<motion.li
|
||||||
key={movie.id}
|
key={movie.id}
|
||||||
variants={item}
|
variants={item}
|
||||||
className='flex basis-[300px] cursor-pointer'
|
className='flex basis-[300px] cursor-pointer'
|
||||||
ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)}
|
ref={isAnchor ? (element) => setLoader(element!) : undefined}
|
||||||
>
|
>
|
||||||
<Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} />
|
<Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} />
|
||||||
</motion.li>
|
</motion.li>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
))}
|
))}
|
||||||
</motion.ul>
|
</motion.ul>
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ export default function Actions({ onClose, movie }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button className='h-8 grow' onClick={() => showTorrentsModal({ title: movie.title })}>
|
<Button
|
||||||
|
className='h-8 grow'
|
||||||
|
onClick={() => showTorrentsModal({ title: movie.title, year: new Date(movie.release_date).getFullYear() })}
|
||||||
|
>
|
||||||
Torrents
|
Torrents
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const Preview: FC<Props> = ({ movie, className, direction, onClose }) => {
|
|||||||
if (!movie) return null;
|
if (!movie) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('rounded-xl bg-card text-card-foreground', { 'p-2': Boolean(onClose) }, className)}>
|
<div className={cn('rounded-xl text-card-foreground', { 'p-2': Boolean(onClose) }, className)}>
|
||||||
<div className='flex flex-col lg:flex-row max-w-[100%] gap-3'>
|
<div className='flex flex-col lg:flex-row max-w-[100%] gap-3'>
|
||||||
<div className='max-w-[300px] min-w-[300px] h-[450px] mx-auto w-[100%] relative overflow-hidden rounded-lg'>
|
<div className='max-w-[300px] min-w-[300px] h-[450px] mx-auto w-[100%] relative overflow-hidden rounded-lg'>
|
||||||
<AnimatePresence custom={direction}>
|
<AnimatePresence custom={direction}>
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import useTorrents from '@/app/(site)/useTorrents';
|
|||||||
import { Modal } from '@/components/ui/dialog';
|
import { Modal } from '@/components/ui/dialog';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
||||||
|
import { Toggle } from '@/components/ui/toggle';
|
||||||
import { ORDER } from '@/lib/api/parsers/pirate-bay';
|
import { ORDER } from '@/lib/api/parsers/pirate-bay';
|
||||||
|
|
||||||
interface Props extends InstanceProps<void> {
|
interface Props extends InstanceProps<void> {
|
||||||
title: string;
|
title: string;
|
||||||
|
year: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sorting = {
|
type Sorting = {
|
||||||
@@ -64,11 +66,16 @@ const showHostManagerModal = create(({ onResolve, isOpen }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const Torrents: FC<Props> = ({ title, isOpen, onResolve }) => {
|
const Torrents: FC<Props> = ({ title, year, isOpen, onResolve }) => {
|
||||||
const host = useAtomValue(hostAtom);
|
const host = useAtomValue(hostAtom);
|
||||||
const [sorting, setSorting] = useState<Sorting>({ by: ORDER.seeders });
|
const [sorting, setSorting] = useState<Sorting>({ by: ORDER.seeders });
|
||||||
|
const [withYear, setWithYear] = useState(true);
|
||||||
|
|
||||||
const { data: torrents, isLoading, isFetched } = useTorrents({ query: title, order: sorting.by });
|
const {
|
||||||
|
data: torrents,
|
||||||
|
isLoading,
|
||||||
|
isFetched
|
||||||
|
} = useTorrents({ query: withYear ? `${title} ${year || ''}` : title, order: sorting.by });
|
||||||
|
|
||||||
const handleCast = (magnet: string) => (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
const handleCast = (magnet: string) => (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -82,7 +89,17 @@ const Torrents: FC<Props> = ({ title, isOpen, onResolve }) => {
|
|||||||
<Table className='rounded-xl overflow-hidden'>
|
<Table className='rounded-xl overflow-hidden'>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead className='px-2'>Title</TableHead>
|
<TableHead className='px-2'>
|
||||||
|
Title: {title}{' '}
|
||||||
|
<Toggle
|
||||||
|
size='sm'
|
||||||
|
className='p-2 h-7'
|
||||||
|
pressed={withYear}
|
||||||
|
onClick={() => setWithYear((withYear) => !withYear)}
|
||||||
|
>
|
||||||
|
{year}
|
||||||
|
</Toggle>
|
||||||
|
</TableHead>
|
||||||
<TableHeadSortable title='Size' by={ORDER.size} value={sorting} onChange={setSorting} />
|
<TableHeadSortable title='Size' by={ORDER.size} value={sorting} onChange={setSorting} />
|
||||||
<TableHeadSortable title='Seeders' by={ORDER.seeders} value={sorting} onChange={setSorting} />
|
<TableHeadSortable title='Seeders' by={ORDER.seeders} value={sorting} onChange={setSorting} />
|
||||||
<TableHead className='px-2 text-center cursor-pointer select-none' onClick={() => showHostManagerModal()}>
|
<TableHead className='px-2 text-center cursor-pointer select-none' onClick={() => showHostManagerModal()}>
|
||||||
|
|||||||
+16
-22
@@ -1,10 +1,10 @@
|
|||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import * as React from 'react'
|
import * as React from 'react';
|
||||||
import * as TogglePrimitive from '@radix-ui/react-toggle'
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
||||||
import { cva, type VariantProps } from 'class-variance-authority'
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
const toggleVariants = cva(
|
const toggleVariants = cva(
|
||||||
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
|
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
|
||||||
@@ -12,34 +12,28 @@ const toggleVariants = cva(
|
|||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: 'bg-transparent',
|
default: 'bg-transparent',
|
||||||
outline:
|
outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground'
|
||||||
'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground',
|
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
default: 'h-10 px-3',
|
default: 'h-10 px-3',
|
||||||
sm: 'h-9 px-2.5',
|
sm: 'h-9 px-2.5',
|
||||||
lg: 'h-11 px-5',
|
lg: 'h-11 px-5'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
variant: 'default',
|
variant: 'default',
|
||||||
size: 'default',
|
size: 'default'
|
||||||
},
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const Toggle = React.forwardRef<
|
const Toggle = React.forwardRef<
|
||||||
React.ElementRef<typeof TogglePrimitive.Root>,
|
React.ElementRef<typeof TogglePrimitive.Root>,
|
||||||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
|
||||||
VariantProps<typeof toggleVariants>
|
|
||||||
>(({ className, variant, size, ...props }, ref) => (
|
>(({ className, variant, size, ...props }, ref) => (
|
||||||
<TogglePrimitive.Root
|
<TogglePrimitive.Root ref={ref} className={cn(toggleVariants({ variant, size, className }))} {...props} />
|
||||||
ref={ref}
|
));
|
||||||
className={cn(toggleVariants({ variant, size, className }))}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
|
|
||||||
Toggle.displayName = TogglePrimitive.Root.displayName
|
Toggle.displayName = TogglePrimitive.Root.displayName;
|
||||||
|
|
||||||
export { Toggle, toggleVariants }
|
export { Toggle, toggleVariants };
|
||||||
+3
-1
@@ -36,7 +36,9 @@ export const popularMovies = async ({ page }: { page?: string }): Promise<MovieD
|
|||||||
sort_by: 'popularity.desc',
|
sort_by: 'popularity.desc',
|
||||||
'vote_count.gte': 0,
|
'vote_count.gte': 0,
|
||||||
'vote_average.lte': 10,
|
'vote_average.lte': 10,
|
||||||
'vote_average.gte': 0
|
'vote_average.gte': 0,
|
||||||
|
'with_runtime.gte': 0,
|
||||||
|
'with_runtime.lte': 400
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-2
@@ -90,8 +90,7 @@
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
main,
|
main {
|
||||||
header {
|
|
||||||
max-width: 1260px;
|
max-width: 1260px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
|
|||||||
Reference in new issue
Block a user