feat: filter can be hidden

This commit is contained in:
ner committed 2023-08-19 13:40:30 +03:00
1 parent c42d5a5298
commit ff506e755c
13 files changed
+73 -83

No files matched your search

+5 -6
View File
@@ -1,5 +1,4 @@
import { FC } from 'react';
import { Star } from 'lucide-react';
import { FC, ReactNode } from 'react';
import Poster from '@/components/Movie/components/Poster';
import Rating from '@/components/Movie/components/Rating';
@@ -8,17 +7,17 @@ import Title from '@/components/Movie/components/Title';
interface Props {
movie?: Movie;
className?: string;
children?: ReactNode;
}
const Card: FC<Props> = ({ movie, className }) => {
const Card: FC<Props> = ({ movie, className, children }) => {
if (!movie) return null;
return (
<div
className={`${className} rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}
>
<div className={`${className} rounded-lg bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}>
<div className='flex justify-center relative grow overflow-hidden rounded-lg'>
<Poster title={movie.title} width={300} height={450} size={100} poster={movie.poster_path} />
{children}
<div className='absolute left-0 top-0 w-full h-20 bg-gradient-to-t from-transparent to-black opacity-80'>
<div className='max-w-[300px] w-full mx-auto pt-1 px-3 text-white'>
<div className='grid items-center grid-cols-[1fr_50px]'>
+1 -2
View File
@@ -1,5 +1,4 @@
import { FC, Fragment, useLayoutEffect, useState } from 'react';
import { InfiniteData, useInfiniteQuery, UseInfiniteQueryResult } from '@tanstack/react-query';
import Card from '@/components/Movie/Card';
import Preview from '@/components/Movie/Preview';
@@ -56,7 +55,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage }) => {
<div className='h-4 w-full' />
{movie && (
<Dialog defaultOpen={true} onOpenChange={(isOpen) => !isOpen && setMovie(null)}>
<DialogContent className='block p-0'>
<DialogContent className='block p-0' onClose={() => setMovie(null)}>
<Preview
key={movie.id}
movie={movie}
+7 -29
View File
@@ -4,15 +4,13 @@ import { useRouter } from 'next/navigation';
import useTrailer from '@/app/(site)/useTrailer';
import Credits from '@/components/Movie/components/Credits';
import Poster from '@/components/Movie/components/Poster';
import Rating from '@/components/Movie/components/Rating';
import Title from '@/components/Movie/components/Title';
import Trailer from '@/components/Movie/components/Trailer';
import { Separator } from '@/components/ui/separator';
import { Button } from '../ui/button';
import Torrents from './components/Torrents';
import Card from './Card';
interface Props {
movie?: Movie;
@@ -31,15 +29,8 @@ const Preview: FC<Props> = ({ movie, className, onClose }) => {
return (
<>
<div className={`p-3 rounded-xl border bg-card text-card-foreground shadow-sm ${className}`}>
<div className='flex flex-col lg:flex-row max-w-[100%] gap-3 overflow-hidden'>
<Poster
className='max-w-[300px]'
title={movie.title}
width={300}
height={450}
size={100}
poster={movie.poster_path}
>
<div className='flex flex-col lg:flex-row max-w-[100%] gap-3'>
<Card movie={movie} className='max-w-[300px] min-w-[300px] mx-auto w-full'>
{trailer && (
<div
onClick={() => setIsShowTrailer(true)}
@@ -49,24 +40,9 @@ const Preview: FC<Props> = ({ movie, className, onClose }) => {
<Play size={100} className='fill-white' />
</div>
)}
</Poster>
</Card>
<div className='flex flex-col grow'>
<div className='flex'>
<div className='flex flex-row flex-wrap w-full text-lg font-semibold'>
<span className='flex w-full items-center'>
<span className='mr-2 w-full'>
<Title title={movie.title} />
</span>
{movie.release_date && <span className='ml-auto'>{new Date(movie.release_date).getFullYear()}</span>}
</span>
<Rating movie={movie} />
</div>
</div>
<Separator className='my-2' />
<div className='flex flex-col items-start grow justify-between'>
<p className='leading-7'>{movie.overview}</p>
</div>
<div className='flex w-full mt-2 gap-2'>
<div className='flex w-full gap-2'>
<Button className='h-8 grow' onClick={() => setIsShowTorrents(true)}>
Torrents
</Button>
@@ -80,6 +56,8 @@ const Preview: FC<Props> = ({ movie, className, onClose }) => {
Similar
</Button>
</div>
<Separator className='my-2' />
<p className='leading-7'>{movie.overview}</p>
</div>
</div>
<Credits movieId={movie.id} onPersonClick={() => onClose?.()} />
+2 -12
View File
@@ -16,16 +16,6 @@ type Sorting = {
by: ORDER;
};
function convertToBytes(size: string) {
const units: Record<string, number> = { B: 1, KiB: 1024, MiB: 1024 * 1024, GiB: 1024 * 1024 * 1024 };
const [value, unit] = size.split(' ');
return parseFloat(value) * units[unit];
}
function compareSizes(size1: string, size2: string) {
return convertToBytes(size1) - convertToBytes(size2);
}
const TableHeadSortable = ({
title,
by,
@@ -60,8 +50,8 @@ const Torrents: FC<Props> = ({ title, onClose }) => {
return (
<Dialog defaultOpen={true} onOpenChange={(isOpen) => !isOpen && onClose()}>
<DialogContent className='p-0'>
<Table>
<DialogContent className='p-0' onClose={onClose}>
<Table className='rounded-xl overflow-hidden'>
<TableHeader>
<TableRow>
<TableHead className='px-2'>Title</TableHead>
@@ -11,7 +11,7 @@ const Trailer: FC<Props> = ({ trailerKey, onClose }) => {
return (
trailerKey && (
<Dialog defaultOpen={true} onOpenChange={(isOpen) => !isOpen && onClose()}>
<DialogContent className='block p-0 min-h-[400px] aspect-w-16 aspect-h-9'>
<DialogContent className='block p-0 min-h-[400px] border-none aspect-w-16 aspect-h-9' onClose={onClose}>
<iframe
allow='autoplay'
className='border-none rounded-lg'