diff --git a/app/(site)/components/Carousel/index.tsx b/app/(site)/components/Carousel/index.tsx index bb0a6e7..84b7100 100644 --- a/app/(site)/components/Carousel/index.tsx +++ b/app/(site)/components/Carousel/index.tsx @@ -31,14 +31,14 @@ export const Measurer = ({ children }: { children: (width: number) => ReactNode }; export const Carousel = ({ + index, movies, width: initialWidth, - index, onIndexChange }: { + index: number; movies?: Movie[]; width: number; - index: number; onIndexChange: (index: number) => void; }) => { const timeout = useRef(); @@ -57,16 +57,21 @@ export const Carousel = ({ }, []); useEffect(() => { - const scrollTo = (event: globalThis.KeyboardEvent) => { - if (event.key === 'ArrowLeft') { - if (index <= 0) return; + let pressed = false; + + const scrollTo = ({ key }: globalThis.KeyboardEvent) => { + if (['ArrowLeft', 'ArrowRight'].includes(key)) { + pressed = true; setSnap(false); + } + + if (key === 'ArrowLeft') { + if (index <= 0) return; ref.current?.scrollIntoView({ index: index - 1, behavior: 'smooth' }); } - if (event.key === 'ArrowRight') { + if (key === 'ArrowRight') { if (index >= (movies?.length || 0) - 1) return; - setSnap(false); ref.current?.scrollIntoView({ index: index + 1, behavior: 'smooth' }); } }; @@ -75,7 +80,7 @@ export const Carousel = ({ return () => { document.removeEventListener('keydown', scrollTo); - setTimeout(() => setSnap(true), 100); + pressed && setTimeout(() => setSnap(true), 100); }; }, [index, movies?.length]); diff --git a/app/(site)/container.tsx b/app/(site)/container.tsx index c17a3e9..80207e7 100644 --- a/app/(site)/container.tsx +++ b/app/(site)/container.tsx @@ -1,37 +1,24 @@ 'use client'; -import { motion, Variants } from 'framer-motion'; - import Preview from '@/components/Movie/Preview'; import { Carousel, Measurer } from './components/Carousel'; import useRandomMovie from './useRandomMovie'; -const container: Variants = { - hidden: { y: -20, opacity: 0 }, - visible: { - y: 0, - opacity: 1, - transition: { - delay: 0.1 - } - } -}; - export default function Container() { const { movies, movie, index, onIndexChange } = useRandomMovie(); return ( {(width) => ( - + <> } /> -
- +
+ )} ); diff --git a/components/Header/components/Navigation/index.tsx b/components/Header/components/Navigation/index.tsx index f264595..8f9da1c 100644 --- a/components/Header/components/Navigation/index.tsx +++ b/components/Header/components/Navigation/index.tsx @@ -2,7 +2,6 @@ import { FC, useEffect, useRef, useState } from 'react'; import { DropdownMenuItem } from '@radix-ui/react-dropdown-menu'; -import { motion } from 'framer-motion'; import { Menu } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; @@ -71,11 +70,16 @@ export function DesktopNavigation() { ))} - + ); } -const Cursor: FC<{ position: { left: number; width: number; opacity: number } }> = ({ position }) => { - return ; +const Cursor: FC<{ options: { left: number; width: number; opacity: number } }> = ({ options }) => { + return ( +
  • + ); }; diff --git a/components/Header/components/Search/index.tsx b/components/Header/components/Search/index.tsx index af0032a..4950d1f 100644 --- a/components/Header/components/Search/index.tsx +++ b/components/Header/components/Search/index.tsx @@ -62,7 +62,6 @@ export const showSearchModal = create(({ onResolve }) => { className='pr-10 focus-visible:ring-0' /> ); diff --git a/components/Movie/Card.tsx b/components/Movie/Card.tsx index d7e40dd..cbad288 100644 --- a/components/Movie/Card.tsx +++ b/components/Movie/Card.tsx @@ -31,8 +31,8 @@ const Card: FC = ({ movie, onClick, className }) => {
  • -
    - {movie.name || movie.title} +
    + {movie.name || movie.title} {Boolean(movie.release_date) && {new Date(movie.release_date).getFullYear()}}
    diff --git a/components/Movie/List.tsx b/components/Movie/List.tsx index ab6fbfa..90f273d 100644 --- a/components/Movie/List.tsx +++ b/components/Movie/List.tsx @@ -1,6 +1,5 @@ -import { FC, forwardRef, useMemo } from 'react'; +import { FC, useMemo } from 'react'; import { VirtuosoGrid, VirtuosoGridProps } from 'react-virtuoso'; -import { motion } from 'framer-motion'; import Card from '@/components/Movie/Card'; import { showPreviewModal } from '@/components/Movie/Preview'; @@ -15,27 +14,7 @@ interface Props { onPreviewClose?: () => void; } -const container = { - hidden: { y: -20, opacity: 0 }, - visible: { - y: 0, - opacity: 1 - } -}; - const components: VirtuosoGridProps void }>['components'] = { - List: forwardRef(function List({ context, ...props }, ref) { - return ( - - ); - }), Item: ({ context, 'data-index': index }) => { const { shows, onClick } = context || {}; const movie = shows?.[index]; @@ -70,6 +49,7 @@ const List: FC = ({ pages, hasNextPage, fetchNextPage, onPreviewClose, ty <> void; - type?: ShowType; } -const container = { - hidden: {}, - visible: { - transition: { - staggerChildren: 0.03 - } - } -}; - -const item = { - hidden: { x: -20, opacity: 0 }, - visible: { - x: 0, - opacity: 1 - } -}; - const Credits: FC = ({ movieId, onPersonClick, type = 'movie' }) => { - const router = useRouter(); const { data: credits } = useCredits({ movieId, type }); return ( Boolean(credits?.length) && ( - +
      {credits?.map((actor) => ( - { - router.push(`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`); - onPersonClick?.(actor.id.toString()); - }} className='bg-card text-card-foreground self-end max-w-[120px] w-full shrink-0 cursor-pointer transition-shadow hover:shadow-lg relative snap-start' > -
      - {actor.profile_path ? ( - {actor.name} - ) : ( -
      - -
      - )} -
      -
      -

      {actor.name}

      - {Boolean(actor.character) && ( -

      {actor.character}

      - )} -
      -
      + onPersonClick?.(actor.id.toString())} + > +
      + {actor.profile_path ? ( + {actor.name} + ) : ( +
      + +
      + )} +
      +
      +

      {actor.name}

      + {Boolean(actor.character) && ( +

      {actor.character}

      + )} +
      + + ))} - +
    ) ); }; diff --git a/components/Movie/components/Trailer/index.tsx b/components/Movie/components/Trailer/index.tsx index b30f7d7..8354fdb 100644 --- a/components/Movie/components/Trailer/index.tsx +++ b/components/Movie/components/Trailer/index.tsx @@ -2,7 +2,6 @@ import { FC, ReactNode } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; -import { motion } from 'framer-motion'; import { Play } from 'lucide-react'; import useTrailer from '@/app/(site)/useTrailer'; @@ -39,12 +38,12 @@ export default function ToggleTrailer({ movieId, type = 'movie', children }: Pro return children ? children({ onPlay: () => showTrailerModal({ trailerKey: trailer?.key }), disabled: isFetched && !trailer }) : trailer && ( - showTrailerModal({ trailerKey: trailer?.key })} +
    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' > - +
    ); } diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 4521f57..9b3479c 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -1,7 +1,5 @@ import * as React from 'react'; -import { useRef, useState } from 'react'; import { cva, type VariantProps } from 'class-variance-authority'; -import { HTMLMotionProps, motion } from 'framer-motion'; import { cn } from '@/lib/utils'; @@ -37,27 +35,8 @@ export interface ButtonProps asChild?: boolean; } -const Button = React.forwardRef< - HTMLButtonElement, - HTMLMotionProps<'button'> & Pick & { base?: boolean } ->(({ className, variant, size, base, ...props }, ref) => { - if (base) - return ( -