feat: swiper
This commit is contained in:
1 parent
cd8928ab54
commit
12223b79d5
20 files changed
+222
-164
No files matched your search
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { FC } from 'react';
|
||||
import { FC, ReactNode } from 'react';
|
||||
import { create, InstanceProps } from 'react-modal-promise';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Play } from 'lucide-react';
|
||||
@@ -10,6 +10,7 @@ import { Modal } from '@/components/ui/dialog';
|
||||
|
||||
interface Props {
|
||||
movieId?: number;
|
||||
children?: ({ onPlay, disabled }: { onPlay: () => void; disabled: boolean }) => ReactNode;
|
||||
}
|
||||
|
||||
const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey, onResolve, isOpen }) => {
|
||||
@@ -35,18 +36,18 @@ const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey
|
||||
|
||||
export const showTrailerModal = create(Trailer);
|
||||
|
||||
export default function ToggleTrailer({ movieId }: Props) {
|
||||
const { data: trailer } = useTrailer({ movieId });
|
||||
export default function ToggleTrailer({ movieId, children }: Props) {
|
||||
const { data: trailer, isFetched } = useTrailer({ movieId });
|
||||
|
||||
return (
|
||||
trailer && (
|
||||
<motion.div
|
||||
onTap={() => showTrailerModal({ trailerKey: trailer?.key })}
|
||||
title='Play trailer'
|
||||
className='absolute w-full h-full left-0 top-0 bg-black cursor-pointer overflow-hidden rounded-lg transition-opacity opacity-0 hover:opacity-70 flex items-center justify-center'
|
||||
>
|
||||
<Play size={100} className='fill-white' />
|
||||
</motion.div>
|
||||
)
|
||||
);
|
||||
return children
|
||||
? children({ onPlay: () => showTrailerModal({ trailerKey: trailer?.key }), disabled: isFetched && !trailer })
|
||||
: trailer && (
|
||||
<motion.div
|
||||
onTap={() => showTrailerModal({ trailerKey: trailer?.key })}
|
||||
title='Play trailer'
|
||||
className='absolute w-full h-full left-0 top-0 bg-black cursor-pointer overflow-hidden rounded-lg transition-opacity opacity-0 hover:opacity-70 flex items-center justify-center'
|
||||
>
|
||||
<Play size={100} className='fill-white' />
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user