feat: aspect-ratio instead of width measurer
This commit is contained in:
1 parent
375ebf93d9
commit
279a61ddcd
15 files changed
+168
-313
No files matched your search
@@ -21,7 +21,7 @@ export function MobileNavigation() {
|
||||
const currentPath = usePathname();
|
||||
|
||||
return (
|
||||
<div className='flex xs:hidden'>
|
||||
<div className='flex md:hidden'>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant='ghost' size='icon'>
|
||||
@@ -58,7 +58,7 @@ export function DesktopNavigation() {
|
||||
}, [currentPath]);
|
||||
|
||||
return (
|
||||
<ul className='relative hidden xs:flex items-center whitespace-nowrap text-sm gap-3'>
|
||||
<ul className='relative hidden md:flex items-center whitespace-nowrap text-sm gap-3'>
|
||||
{paths.map(({ path, title }) => (
|
||||
<li
|
||||
key={path}
|
||||
|
||||
+24
-27
@@ -2,7 +2,6 @@ import { FC } from 'react';
|
||||
|
||||
import Poster from '@/components/Movie/components/Poster';
|
||||
import Rating from '@/components/Movie/components/Rating';
|
||||
import { AspectRatio } from '@/components/ui/aspect-ratio';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import Favorite from './components/Favorite';
|
||||
@@ -12,38 +11,36 @@ interface Props {
|
||||
movie?: Movie;
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
containerProps?: unknown;
|
||||
}
|
||||
|
||||
const Card: FC<Props> = ({ movie, onClick, className }) => {
|
||||
const Card: FC<Props> = ({ movie, onClick, className, containerProps }) => {
|
||||
if (!movie) return null;
|
||||
|
||||
return (
|
||||
<div className='xs:w-[300px] xs:h-[450px] w-full h-full shrink-0'>
|
||||
<AspectRatio ratio={2 / 3}>
|
||||
<div
|
||||
className={cn(
|
||||
'h-full relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className='flex w-full h-full'>
|
||||
<Poster title={movie.name || movie.title} poster={movie.poster_path} />
|
||||
</div>
|
||||
<div className='text-white absolute w-full h-full top-0 left-0 rounded-md flex flex-col justify-between p-2 card-gradient'>
|
||||
<Handlers movie={movie} onClick={onClick} />
|
||||
<div className='grid grid-cols-[1fr_auto] text-lg opacity-75 gap-2'>
|
||||
<span className='overflow-ellipsis overflow-hidden whitespace-nowrap'>{movie.name || movie.title}</span>
|
||||
{Boolean(movie.release_date) && <span>{new Date(movie.release_date).getFullYear()}</span>}
|
||||
</div>
|
||||
<div className='opacity-75 mb-[-5px]'>
|
||||
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between z-[1]'>
|
||||
<Favorite movie={movie} />
|
||||
<Rating rating={movie.vote_average} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
{...(containerProps || {})}
|
||||
className={cn(
|
||||
'card-aspect-ratio relative bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg overflow-hidden rounded-lg',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div className='flex w-full h-full'>
|
||||
<Poster title={movie.name || movie.title} poster={movie.poster_path} />
|
||||
</div>
|
||||
<div className='text-white absolute w-full h-full top-0 left-0 rounded-md flex flex-col justify-between p-2 card-gradient'>
|
||||
<Handlers movie={movie} onClick={onClick} />
|
||||
<div className='grid grid-cols-[1fr_auto] text-lg opacity-75 gap-2'>
|
||||
<span className='overflow-ellipsis overflow-hidden whitespace-nowrap'>{movie.name || movie.title}</span>
|
||||
{Boolean(movie.release_date) && <span>{new Date(movie.release_date).getFullYear()}</span>}
|
||||
</div>
|
||||
</AspectRatio>
|
||||
<div className='opacity-75 mb-[-5px]'>
|
||||
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between z-[1]'>
|
||||
<Favorite movie={movie} />
|
||||
<Rating rating={movie.vote_average} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -49,14 +49,12 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, onPreviewClose, ty
|
||||
<>
|
||||
<VirtuosoGrid
|
||||
useWindowScroll
|
||||
listClassName='flex gap-2 flex-wrap justify-center grow empty:hidden opacity-0 animate-fade-in-slide-in'
|
||||
customScrollParent={customScrollParent}
|
||||
totalCount={shows.length}
|
||||
overscan={4}
|
||||
endReached={handleFetchMore}
|
||||
data={shows}
|
||||
context={context}
|
||||
components={components}
|
||||
listClassName='flex gap-2 flex-wrap justify-center grow empty:hidden opacity-0 animate-fade-in-slide-in'
|
||||
customScrollParent={customScrollParent}
|
||||
endReached={handleFetchMore}
|
||||
/>
|
||||
<div className='h-2 w-full' />
|
||||
</>
|
||||
|
||||
@@ -25,21 +25,19 @@ const Preview: FC<Props> = ({ movie, className, onClose, children, card, type =
|
||||
if (!movie) return null;
|
||||
|
||||
return (
|
||||
<div className={cn('rounded-xl text-card-foreground', { 'p-2': Boolean(onClose) }, className)}>
|
||||
<div className='flex flex-col md:flex-row max-w-[100%] gap-2'>
|
||||
{card || <Card className='mx-auto' movie={movie} />}
|
||||
<div className='flex flex-col grow'>
|
||||
{children && <div className='flex hover-none:hidden w-full max-sm:mb-0 mb-2 gap-2'>{children}</div>}
|
||||
<div className='flex w-full gap-2'>
|
||||
<Actions type={type} movie={movie} onClose={onClose} />
|
||||
</div>
|
||||
<Separator className='my-2' />
|
||||
<p key={movie.id} className='leading-7 mb-3'>
|
||||
{movie.overview}
|
||||
</p>
|
||||
<div className='mt-auto grid grid-cols-1 rounded-lg'>
|
||||
<Credits type={type} movieId={movie.id} onPersonClick={onClose} />
|
||||
</div>
|
||||
<div className={cn('flex flex-col md:flex-row gap-2 rounded-xl', { 'p-2': Boolean(onClose) }, className)}>
|
||||
{card || <Card className='mx-auto' movie={movie} />}
|
||||
<div className='flex flex-col grow'>
|
||||
{children && <div className='flex hover-none:hidden w-full max-sm:mb-0 mb-2 gap-2'>{children}</div>}
|
||||
<div className='flex w-full gap-2'>
|
||||
<Actions type={type} movie={movie} onClose={onClose} />
|
||||
</div>
|
||||
<Separator className='my-2' />
|
||||
<p key={movie.id} className='leading-7 mb-3'>
|
||||
{movie.overview}
|
||||
</p>
|
||||
<div className='mt-auto grid grid-cols-1 rounded-lg'>
|
||||
<Credits type={type} movieId={movie.id} onPersonClick={onClose} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,10 +17,11 @@ const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey
|
||||
if (!trailerKey) return;
|
||||
|
||||
return (
|
||||
<Modal className='block p-0 min-h-[400px] border-none aspect-w-16 aspect-h-9' onClose={onResolve}>
|
||||
<Modal className='block p-0 min-h-[400px] border-none' style={{ aspectRatio: '16/9' }} onClose={onResolve}>
|
||||
<iframe
|
||||
allow='autoplay'
|
||||
className='border-none rounded-lg'
|
||||
style={{ aspectRatio: '16/9' }}
|
||||
width='100%'
|
||||
height='100%'
|
||||
src={`//www.youtube.com/embed/${trailerKey}?autoplay=1`}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import * as AspectRatioPrimitive from '@radix-ui/react-aspect-ratio';
|
||||
|
||||
const AspectRatio = AspectRatioPrimitive.Root;
|
||||
|
||||
export { AspectRatio };
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useState } from 'react';
|
||||
import { CSSProperties, useState } from 'react';
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||
|
||||
import useScrollDelta from '@/hooks/useScrollDelta';
|
||||
@@ -157,9 +157,10 @@ DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
const Modal: React.FC<{
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
onClose: () => void;
|
||||
scrollRef?: React.MutableRefObject<HTMLDivElement>;
|
||||
}> = ({ children, onClose, className, scrollRef }) => {
|
||||
}> = ({ children, onClose, className, style, scrollRef }) => {
|
||||
const [open, setOpen] = useState(true);
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -172,7 +173,7 @@ const Modal: React.FC<{
|
||||
<DialogHeader>
|
||||
<DialogTitle />
|
||||
</DialogHeader>
|
||||
<DialogContent scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
|
||||
<DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
|
||||
{children}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
Reference in new issue
Block a user