fix: swiper

This commit is contained in:
ner committed 2024-03-25 15:31:17 +02:00
1 parent 1b87355925
commit 1aa145a98c
13 files changed
+125 -123

No files matched your search

+2 -2
View File
@@ -27,7 +27,7 @@ const Card: FC<Props> = ({ movie, onClick, fit }) => {
<div
onDoubleClick={handleToggleFavorite}
className={cn(
'w-[300px] h-[450px] min-w-[300px] shrink-0 mx-auto',
'w-[300px] h-[450px] min-w-[300px] min-h-[450px] shrink-0 mx-auto',
fit ? 'w-full h-auto xs:w-[300px] xs:h-[450px]' : undefined
)}
>
@@ -37,7 +37,7 @@ const Card: FC<Props> = ({ movie, onClick, fit }) => {
title={movie.title}
size={100}
poster={movie.poster_path}
className={fit ? 'h-auto xs:h-full' : undefined}
className={fit ? 'h-auto min-h-[450px] xs:h-full' : undefined}
/>
</motion.div>
<div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-75 rounded-t-lg'>
+2 -19
View File
@@ -2,8 +2,7 @@ import { FC, Fragment, useLayoutEffect, useState } from 'react';
import { motion } from 'framer-motion';
import Card from '@/components/Movie/Card';
import Preview from '@/components/Movie/Preview';
import { Modal } from '@/components/ui/dialog';
import { showPreviewModal } from '@/components/Movie/Preview';
import filterUnknownMovies from '@/lib/filterUnknownMovies';
interface Props {
@@ -32,7 +31,6 @@ const item = {
};
const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = true, onPreviewClose }) => {
const [movie, setMovie] = useState<Movie | null>(null);
const [loader, setLoader] = useState<HTMLLIElement>();
useLayoutEffect(() => {
@@ -74,7 +72,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
className='flex cursor-pointer'
ref={isAnchor ? (element) => setLoader(element!) : undefined}
>
<Card fit movie={movie} onClick={() => setMovie(movie)} />
<Card fit movie={movie} onClick={() => showPreviewModal({ movie, onClose: onPreviewClose })} />
</motion.li>
);
})}
@@ -82,21 +80,6 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr
))}
</motion.ul>
{withBottomGap && <div className='h-4 w-full' />}
<Modal isOpen={Boolean(movie)} onClose={() => setMovie(null)} className='block p-0'>
{movie && (
<Preview
fit
key={movie.id}
movie={movie}
className='border-none'
onClose={() => {
setMovie(null);
window.scrollTo({ top: 0, behavior: 'smooth' });
onPreviewClose?.();
}}
/>
)}
</Modal>
</>
);
};
+20 -3
View File
@@ -1,8 +1,10 @@
'use client';
import { FC, ReactNode } from 'react';
import { create, InstanceProps } from 'react-modal-promise';
import Credits from '@/components/Movie/components/Credits';
import { Modal } from '@/components/ui/dialog';
import { Separator } from '@/components/ui/separator';
import { cn } from '@/lib/utils';
@@ -16,16 +18,16 @@ interface Props {
className?: string;
onClose?: () => void;
children?: ReactNode;
renderCard?: () => ReactNode;
card?: ReactNode;
}
const Preview: FC<Props> = ({ movie, className, onClose, children, renderCard, fit }) => {
const Preview: FC<Props> = ({ movie, className, onClose, children, card, fit }) => {
if (!movie) return null;
return (
<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-2'>
{renderCard?.() || <Card fit={fit} movie={movie} />}
{card || <Card fit={fit} movie={movie} />}
<div className='flex flex-col grow'>
{children && <div className='flex hover-none:hidden w-full mb-2 gap-2'>{children}</div>}
<div className='flex w-full gap-2'>
@@ -42,4 +44,19 @@ const Preview: FC<Props> = ({ movie, className, onClose, children, renderCard, f
);
};
export const showPreviewModal = create(({ onResolve, onClose, movie }: Props & InstanceProps<void>) => (
<Modal className='block p-0' onClose={onResolve}>
<Preview
fit
movie={movie}
className='border-none'
onClose={() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
onClose?.();
onResolve();
}}
/>
</Modal>
));
export default Preview;
@@ -51,10 +51,10 @@ const TableHeadSortable = ({
const hostAtom = atomWithStorage<string>('magnet-host', '');
const showHostManagerModal = create(({ onResolve, isOpen }) => {
const showHostManagerModal = create(({ onResolve }) => {
const [host, setHost] = useAtom(hostAtom);
return (
<Modal className='p-3 max-w-[200px] m-auto' isOpen={isOpen} onClose={() => onResolve()}>
<Modal className='p-3 max-w-[200px] m-auto' onClose={onResolve}>
<Input
autoFocus
placeholder='Enter host of Elementum'
@@ -66,7 +66,7 @@ const showHostManagerModal = create(({ onResolve, isOpen }) => {
);
});
const Torrents: FC<Props> = ({ title, year, isOpen, onResolve }) => {
const Torrents: FC<Props> = ({ title, year, onResolve }) => {
const hosts = useAtomValue(hostAtom);
const [sorting, setSorting] = useState<Sorting>({ by: ORDER.seeders });
const [withYear, setWithYear] = useState(true);
@@ -87,7 +87,7 @@ const Torrents: FC<Props> = ({ title, year, isOpen, onResolve }) => {
};
return (
<Modal className='p-0' isOpen={isOpen} onClose={() => onResolve()}>
<Modal className='p-0' onClose={onResolve}>
<Table className='rounded-xl overflow-hidden'>
<TableHeader>
<TableRow>
@@ -13,15 +13,11 @@ interface Props {
children?: ({ onPlay, disabled }: { onPlay: () => void; disabled: boolean }) => ReactNode;
}
const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey, onResolve, isOpen }) => {
const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey, onResolve }) => {
if (!trailerKey) return;
return (
<Modal
className='block p-0 min-h-[400px] border-none aspect-w-16 aspect-h-9'
onClose={() => onResolve()}
isOpen={isOpen}
>
<Modal className='block p-0 min-h-[400px] border-none aspect-w-16 aspect-h-9' onClose={onResolve}>
<iframe
allow='autoplay'
className='border-none rounded-lg'