fix: misspellings

This commit is contained in:
ner committed 2024-10-25 12:56:28 +03:00
1 parent d8363ca250
commit f3b90f30c3
10 files changed
+109 -2636

No files matched your search

+28 -29
View File
@@ -1,11 +1,13 @@
'use client';
import { Bookmark, Copy, Heart, Play, Star } from 'lucide-react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import showTorrentsModal from '@/components/Preview/components/Torrents';
import { Button } from '@/components/ui/button';
import ButtonsGroup from '@/components/ui/buttons-group';
import useShowState, { useMutateShowState } from '@/hooks/useShowState';
import useTheme from '@/hooks/useTheme';
import { cn } from '@/lib/utils';
interface Props {
@@ -15,27 +17,24 @@ interface Props {
}
const Actions = ({ onClose, show, className }: Props) => {
const router = useRouter();
const [theme] = useTheme();
const state = useShowState({ showId: show.id, showType: show.type });
const toggle = useMutateShowState(show);
const groupClassName = 'flex bg-input gap-[1px] rounded-md md:flex-grow-0 flex-grow';
const leftClassName = 'h-8 gap-1 flex-grow border-r-0 rounded-none rounded-l-md md:px-3 px-2';
const rightClassName = 'h-8 gap-1 flex-grow border-l-0 rounded-none rounded-r-md md:px-3 px-2';
return (
<div className={cn('flex gap-2 flex-wrap md:flex-grow-0 flex-grow', className)}>
<div className={cn(groupClassName, 'pointer-events-none')}>
<Button aria-label='Show rating' className={leftClassName} variant='outline'>
<ButtonsGroup className='pointer-events-none'>
<Button aria-label='Show rating' variant='outline'>
<Star size={14} />
</Button>
<Button className={rightClassName} variant='outline'>
{show.rating.toFixed(1)}
</Button>
</div>
<div className={groupClassName}>
<Button variant='outline'>{show.rating.toFixed(1)}</Button>
</ButtonsGroup>
<ButtonsGroup>
<Button
aria-label='Toggle favorite'
className={leftClassName}
variant='outline'
disabled={toggle.list === 'favorite' && toggle.isPending}
onClick={() => toggle.mutate({ list: 'favorite', value: !state?.favorite })}
@@ -44,28 +43,28 @@ const Actions = ({ onClose, show, className }: Props) => {
</Button>
<Button
aria-label='Toggle watch list'
className={rightClassName}
variant='outline'
disabled={toggle.list === 'watchlist' && toggle.isPending}
onClick={() => toggle.mutate({ list: 'watchlist', value: !state?.watchlist })}
>
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
</Button>
</div>
<div className={cn(groupClassName, 'gap-0')}>
<Link
className='flex grow'
href={`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`}
onClick={onClose}
>
<Button aria-label='Similar show' className={leftClassName} variant='outline'>
<Copy size={14} />
Similar
</Button>
</Link>
</ButtonsGroup>
<ButtonsGroup className='gap-0'>
<Button
aria-label='Watch show'
className={cn(rightClassName, 'bg-red-700')}
onClick={() => {
onClose?.();
router.push(`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`);
}}
aria-label='Similar show'
variant='outline'
>
<Copy size={14} />
Similar
</Button>
<Button
aria-label='Watch'
className={cn({ 'bg-red-600': theme === 'light', 'bg-red-700': theme === 'dark' })}
variant='destructive'
onClick={() =>
showTorrentsModal({
@@ -79,7 +78,7 @@ const Actions = ({ onClose, show, className }: Props) => {
<Play size={15} />
Watch
</Button>
</div>
</ButtonsGroup>
</div>
);
};
@@ -1,9 +1,12 @@
import { FC, Fragment } from 'react';
import { Cast, Copy, ListVideo, Magnet, Play } from 'lucide-react';
import { Cast, ListVideo, Magnet, Play } from 'lucide-react';
import { Sort } from '@/api/parsers';
import { Quality } from '@/api/parsers/yts/models';
import { Button } from '@/components/ui/button';
import ButtonsGroup from '@/components/ui/buttons-group';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
import { cn } from '@/lib/utils';
import { providers } from '../../constants';
import { useCastMagnet, usePrefix } from '../../hooks/useMagnetHosts';
@@ -18,10 +21,11 @@ interface Props {
sort: Sort;
sortable: boolean;
provider: string;
year: number;
onChangeSort: (sort: Sort) => void;
}
const TorrentsTable: FC<Props> = ({ title, torrents, backdrop, sort, sortable, provider, onChangeSort }) => {
const TorrentsTable: FC<Props> = ({ title, torrents, backdrop, sort, sortable, provider, year, onChangeSort }) => {
const prefix = usePrefix();
const cast = useCastMagnet();
@@ -31,7 +35,7 @@ const TorrentsTable: FC<Props> = ({ title, torrents, backdrop, sort, sortable, p
<Table className='overflow-hidden rounded-xl'>
{Boolean(torrents?.length) && (
<TableHeader>
<TableRow>
<TableRow className='hover:bg-transparent'>
<TableHead className='hidden px-2 md:table-cell'>Title</TableHead>
<TableHead className='hidden px-2 md:table-cell'>Resolution</TableHead>
<TableHeadSortable sortable={sortable} title='Size' sort={Sort.size} value={sort} onChange={onChangeSort} />
@@ -59,18 +63,20 @@ const TorrentsTable: FC<Props> = ({ title, torrents, backdrop, sort, sortable, p
const supportedForCast = prefix && !prefix.includes('{host}');
const yearView = torrent.year && year.toString() != torrent.year && `[${torrent.year}]`;
return (
<Fragment key={torrent.magnet + torrent.id}>
<TableRow className='table-row border-b-0 md:hidden'>
<TableRow className='table-row border-b-0 hover:bg-transparent md:hidden'>
<TableCell className='break-all p-2' colSpan={colSpan}>
<span className='flex w-full flex-wrap items-center gap-3'>
{torrent.title} {torrent.year && `[${torrent.year}]`} {torrent.quality && `[${torrent.quality}]`}
{torrent.title} {yearView} {torrent.quality && `[${torrent.quality}]`}
</span>
</TableCell>
</TableRow>
<TableRow>
<TableRow className='hover:bg-transparent'>
<TableCell className='hidden break-all p-2 md:table-cell' title={torrent.originalTitle}>
{torrent.title} {torrent.year && `[${torrent.year}]`}{' '}
{torrent.title} {yearView}{' '}
<span className='uppercase'>{torrent.source && `[${torrent.source}]`}</span>
</TableCell>
<TableCell className='hidden p-2 md:table-cell'>
@@ -81,48 +87,40 @@ const TorrentsTable: FC<Props> = ({ title, torrents, backdrop, sort, sortable, p
</TableCell>
<TableCell className='truncate p-2'>{torrent.seeders}</TableCell>
<TableCell className='p-1 pr-2 text-center'>
<div className='no-scrollbar flex max-w-full justify-end gap-2 overflow-auto'>
<ButtonsGroup className='ml-auto w-fit grow-0'>
{supportedForStream && (
<div
className='flex size-8 cursor-pointer items-center justify-center rounded-md border'
<Button
variant='destructive'
className={cn('flex-grow-0 px-3 bg-red-600')}
onClick={() => showPlayer({ magnet: torrent.magnet, backdrop, title })}
title='Play show'
title='Play'
>
<Play size={20} />
</div>
<Play size={15} />
</Button>
)}
<a
href={`${process.env.NEXT_PUBLIC_TORRENT_PROXY}/stream?m3u&link=${encodeURIComponent(
torrent.magnet
)}`}
className='flex size-8 items-center justify-center rounded-md border'
title='Open using you native video player'
<Button
variant='outline'
className='relative grow-0 px-3'
title='Play using your native video player'
>
<a
className='absolute left-0 top-0 size-full'
href={`${process.env.NEXT_PUBLIC_TORRENT_PROXY}/stream?m3u&link=${encodeURIComponent(
torrent.magnet
)}`}
/>
<ListVideo size={20} />
</a>
<a
href={torrent.magnet}
className='flex size-8 items-center justify-center rounded-md border'
title='Download magnet'
>
</Button>
<Button className='relative grow-0 px-3' variant='outline' title='Download magnet'>
<a className='absolute left-0 top-0 size-full' href={torrent.magnet} />
<Magnet size={20} />
</a>
<div
className='flex size-8 cursor-pointer items-center justify-center rounded-md border'
onClick={() => navigator.clipboard.writeText(torrent.magnet)}
title='Copy magnet into clipboard'
>
<Copy size={20} />
</div>
</Button>
{supportedForCast && (
<div
onClick={() => cast(torrent.magnet!)}
className='flex size-8 cursor-pointer items-center justify-center rounded-md border'
>
<Button className='grow-0 px-3' variant='outline' onClick={() => cast(torrent.magnet!)}>
<Cast size={20} />
</div>
</Button>
)}
</div>
</ButtonsGroup>
</TableCell>
</TableRow>
</Fragment>
@@ -89,6 +89,7 @@ const showTorrentsModal = create(({ title, year, imdbID, backdrop, onResolve }:
return (
<TabsContent className='pb-1' key={provider.key} value={provider.key}>
<TorrentsTable
year={year}
title={title}
backdrop={backdrop}
sort={sort}
+12 -8
View File
@@ -41,13 +41,17 @@ const Preview: FC<Props> = ({ show: baseShow, className, onClose, poster }) => {
<div className='order-3 mb-4 flex w-full flex-wrap gap-5 whitespace-nowrap text-sm md:order-2'>
<span>{new Date(show.release).getFullYear()}</span>
{show.runtime && <span>{show.runtime} minutes</span>}
<span>
{show.genres
?.slice(0, 3)
.map(({ name }) => name)
.join(' | ')}
</span>
{Boolean(show.runtime) && (
<span className='animate-fade-aside-slide-in opacity-0'>{show.runtime} minutes</span>
)}
{Boolean(show.genres) && (
<span className='animate-fade-aside-slide-in opacity-0'>
{show.genres
?.slice(0, 3)
.map(({ name }) => name)
.join(' | ')}
</span>
)}
</div>
<Actions className='order-1 mb-4 mt-1 md:order-2 md:mt-0' show={show} onClose={onClose} />
@@ -68,9 +72,9 @@ export const showPreviewModal = create(({ onResolve, onClose, show }: Props & In
<Preview
show={show}
onClose={() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
onClose?.();
onResolve();
window.scrollTo({ top: 0, behavior: 'smooth' });
}}
/>
</Modal>
+25
View File
@@ -0,0 +1,25 @@
import { Children, cloneElement, FC, isValidElement, ReactElement, ReactNode } from 'react';
import { cn } from '@/lib/utils';
interface Props {
children: ReactNode;
className?: string;
}
const ButtonsGroup: FC<Props> = ({ children, className }) => (
<div className={cn('flex bg-input gap-[1px] rounded-md md:flex-grow-0 flex-grow group', className)}>
{Children.map(children, (child) => {
if (!isValidElement(child)) return null;
return cloneElement(child as ReactElement<{ className?: string }>, {
className: cn(
'h-8 gap-1 flex-grow md:px-3 px-2 [&:not(:first-child):not(:last-child)]:border-x-0 rounded-none first:border-r-0 first:rounded-l-md last:border-l-0 last:rounded-r-md',
child.props.className
)
});
})}
</div>
);
export default ButtonsGroup;