fix: navigation
This commit is contained in:
1 parent
c6d306cb7b
commit
585094dd24
9 files changed
+73
-50
No files matched your search
@@ -9,7 +9,7 @@ export default function Navigation() {
|
||||
const path = usePathname();
|
||||
|
||||
return (
|
||||
<Tabs value={path} className='flex-grow mt-2'>
|
||||
<Tabs value={path} className='flex-grow'>
|
||||
<TabsList className='flex w-full'>
|
||||
{[
|
||||
{ path: '/', title: 'Random' },
|
||||
|
||||
@@ -8,17 +8,21 @@ import ToggleSearch from './components/Search';
|
||||
import ToggleTheme from './components/ThemeToggle';
|
||||
|
||||
const Header: FC = () => (
|
||||
<header className='bg-background sticky pt-[12px] pb-2 top-0 z-10'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<Link href='/'>
|
||||
<Badge className='whitespace-nowrap'>Movie advisor</Badge>
|
||||
</Link>
|
||||
<div className='flex items-center gap-2'>
|
||||
<ToggleTheme />
|
||||
<ToggleSearch />
|
||||
<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='/'>
|
||||
<Badge className='whitespace-nowrap'>Movie advisor</Badge>
|
||||
</Link>
|
||||
<div className='w-full order-3 md:order-none'>
|
||||
<Navigation />
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<ToggleTheme />
|
||||
<ToggleSearch />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Navigation />
|
||||
</header>
|
||||
);
|
||||
|
||||
|
||||
+14
-10
@@ -64,16 +64,20 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
|
||||
>
|
||||
{pages.map((page) => (
|
||||
<Fragment key={page.page}>
|
||||
{filterUnknownMovies(page.results)?.map((movie, index, array) => (
|
||||
<motion.li
|
||||
key={movie.id}
|
||||
variants={item}
|
||||
className='flex basis-[300px] cursor-pointer'
|
||||
ref={array.length / 2 !== index ? undefined : (element) => setLoader(element!)}
|
||||
>
|
||||
<Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} />
|
||||
</motion.li>
|
||||
))}
|
||||
{filterUnknownMovies(page.results)?.map((movie, index, array) => {
|
||||
const isAnchor = Math.round(array.length / 2) === index;
|
||||
|
||||
return (
|
||||
<motion.li
|
||||
key={movie.id}
|
||||
variants={item}
|
||||
className='flex basis-[300px] cursor-pointer'
|
||||
ref={isAnchor ? (element) => setLoader(element!) : undefined}
|
||||
>
|
||||
<Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} />
|
||||
</motion.li>
|
||||
);
|
||||
})}
|
||||
</Fragment>
|
||||
))}
|
||||
</motion.ul>
|
||||
|
||||
@@ -16,7 +16,10 @@ export default function Actions({ onClose, movie }: Props) {
|
||||
|
||||
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
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
@@ -33,7 +33,7 @@ const Preview: FC<Props> = ({ movie, className, direction, onClose }) => {
|
||||
if (!movie) return null;
|
||||
|
||||
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='max-w-[300px] min-w-[300px] h-[450px] mx-auto w-[100%] relative overflow-hidden rounded-lg'>
|
||||
<AnimatePresence custom={direction}>
|
||||
|
||||
@@ -9,10 +9,12 @@ import useTorrents from '@/app/(site)/useTorrents';
|
||||
import { Modal } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
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';
|
||||
|
||||
interface Props extends InstanceProps<void> {
|
||||
title: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
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 [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>) => {
|
||||
event.preventDefault();
|
||||
@@ -82,7 +89,17 @@ const Torrents: FC<Props> = ({ title, isOpen, onResolve }) => {
|
||||
<Table className='rounded-xl overflow-hidden'>
|
||||
<TableHeader>
|
||||
<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='Seeders' by={ORDER.seeders} value={sorting} onChange={setSorting} />
|
||||
<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 TogglePrimitive from '@radix-ui/react-toggle'
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import * as React from 'react';
|
||||
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
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',
|
||||
@@ -12,34 +12,28 @@ const toggleVariants = cva(
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-transparent',
|
||||
outline:
|
||||
'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground',
|
||||
outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground'
|
||||
},
|
||||
size: {
|
||||
default: 'h-10 px-3',
|
||||
sm: 'h-9 px-2.5',
|
||||
lg: 'h-11 px-5',
|
||||
},
|
||||
lg: 'h-11 px-5'
|
||||
}
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
size: 'default'
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const Toggle = React.forwardRef<
|
||||
React.ElementRef<typeof TogglePrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
||||
VariantProps<typeof toggleVariants>
|
||||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
|
||||
>(({ className, variant, size, ...props }, ref) => (
|
||||
<TogglePrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(toggleVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
<TogglePrimitive.Root 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 };
|
||||
Reference in new issue
Block a user