feat: new nav
This commit is contained in:
1 parent
5733bc0af0
commit
750d5b12c8
25 files changed
+386
-325
No files matched your search
@@ -0,0 +1,23 @@
|
||||
'use client';
|
||||
|
||||
import { FC } from 'react';
|
||||
import { Heart } from 'lucide-react';
|
||||
|
||||
import { useFavoriteToggle } from '@/app/(site)/favorites/useFavorites';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface Props {
|
||||
movie: Movie;
|
||||
}
|
||||
|
||||
const Favorite: FC<Props> = ({ movie }) => {
|
||||
const { isFavorite, toggle } = useFavoriteToggle(movie);
|
||||
|
||||
return (
|
||||
<span onClick={toggle} className='cursor-pointer' title={isFavorite ? 'Remove from favorites' : 'Add to favorite'}>
|
||||
<Heart className={cn(isFavorite && 'fill-white')} size={20} />
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default Favorite;
|
||||
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import { FC } from 'react';
|
||||
|
||||
import { useFavoriteToggle } from '@/app/(site)/favorites/useFavorites';
|
||||
|
||||
interface Props {
|
||||
movie: Movie;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const Handlers: FC<Props> = ({ onClick, movie }) => {
|
||||
const { toggle } = useFavoriteToggle(movie);
|
||||
|
||||
return <div onClick={onClick} onDoubleClick={toggle} className='absolute top-0 left-0 w-full h-full' />;
|
||||
};
|
||||
|
||||
export default Handlers;
|
||||
@@ -14,7 +14,7 @@ const Poster: FC<Props> = ({ title, poster }) => {
|
||||
alt={title}
|
||||
/>
|
||||
) : (
|
||||
<div className={'w-full flex items-center justify-center rounded-lg grow'}>
|
||||
<div className='w-full flex items-center justify-center rounded-lg grow'>
|
||||
<ImageOff size={100} strokeWidth={1} color='hsl(215.4 16.3% 46.9%)' />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,35 +1,15 @@
|
||||
import { FC } from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Heart, Star } from 'lucide-react';
|
||||
import { Star } from 'lucide-react';
|
||||
|
||||
interface Props {
|
||||
isFavorite: boolean;
|
||||
toggleFavorite: () => void;
|
||||
iconsFillColor?: string;
|
||||
rating?: number;
|
||||
}
|
||||
|
||||
const Rating: FC<Props> = ({ isFavorite, rating, toggleFavorite, iconsFillColor = 'fill-accent-foreground' }) => {
|
||||
return (
|
||||
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between'>
|
||||
<motion.span
|
||||
onTap={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
toggleFavorite();
|
||||
}}
|
||||
className='z-[2] cursor-pointer'
|
||||
title={isFavorite ? 'Remove from favorites' : 'Add to favorite'}
|
||||
>
|
||||
<Heart className={isFavorite ? iconsFillColor : ''} size={20} />
|
||||
</motion.span>
|
||||
<span className='flex items-center'>
|
||||
<Star size={18} className={`mr-1 ${iconsFillColor}`} />
|
||||
<p className='mt-[3px]'>{rating?.toFixed(1)}</p>
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
const Rating: FC<Props> = ({ rating }) => (
|
||||
<span className='flex items-center'>
|
||||
<Star size={18} className='mr-1 fill-white' />
|
||||
<p className='mt-[3px]'>{rating?.toFixed(1)}</p>
|
||||
</span>
|
||||
);
|
||||
|
||||
export default Rating;
|
||||
@@ -1,33 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { FC, useState } from 'react';
|
||||
import Marquee from 'react-fast-marquee';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const Title: FC<Props> = ({ title, className }) => {
|
||||
const [isScrollableTitle, setIsScrollableTitle] = useState(false);
|
||||
return (
|
||||
<Marquee
|
||||
play={isScrollableTitle}
|
||||
gradientWidth={10}
|
||||
className={`movie-title overflow-hidden h-[30px] text-lg font-semibold ${className}`}
|
||||
>
|
||||
<div
|
||||
ref={(element) => {
|
||||
const header = element?.closest('.movie-title') as HTMLDivElement;
|
||||
const isScrollableTitle = (header?.offsetWidth || 0) < (element?.offsetWidth || 0);
|
||||
|
||||
isScrollableTitle && setIsScrollableTitle(isScrollableTitle);
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
</Marquee>
|
||||
);
|
||||
};
|
||||
|
||||
export default Title;
|
||||
Reference in new issue
Block a user