refactoring: improvements for lighthouse

This commit is contained in:
ner committed 2024-10-21 15:35:08 +03:00
1 parent f2f242a684
commit 38aebcbe28
27 files changed
+132 -93

No files matched your search

@@ -25,7 +25,7 @@ const Actions = ({ onClose, show, className }: Props) => {
return (
<div className={cn('flex gap-2 flex-wrap md:flex-grow-0 flex-grow', className)}>
<div className={cn(groupClassName, 'pointer-events-none')}>
<Button className={leftClassName} variant='outline'>
<Button aria-label='Show rating' className={leftClassName} variant='outline'>
<Star size={14} />
</Button>
<Button className={rightClassName} variant='outline'>
@@ -34,6 +34,7 @@ const Actions = ({ onClose, show, className }: Props) => {
</div>
<div className={groupClassName}>
<Button
aria-label='Toggle favorite'
className={leftClassName}
variant='outline'
disabled={toggle.list === 'favorite' && toggle.isPending}
@@ -42,6 +43,7 @@ const Actions = ({ onClose, show, className }: Props) => {
<Heart size={14} className={cn({ 'fill-secondary-foreground': state?.favorite })} />
</Button>
<Button
aria-label='Toggle watch list'
className={rightClassName}
variant='outline'
disabled={toggle.list === 'watchlist' && toggle.isPending}
@@ -56,12 +58,13 @@ const Actions = ({ onClose, show, className }: Props) => {
href={`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`}
onClick={onClose}
>
<Button className={leftClassName} variant='outline'>
<Button aria-label='Similar show' className={leftClassName} variant='outline'>
<Copy size={14} />
Similar
</Button>
</Link>
<Button
aria-label='Watch show'
className={cn(rightClassName, 'bg-red-600')}
variant='destructive'
onClick={() =>
@@ -53,6 +53,7 @@ const components: VirtuosoProps<Actor, Context>['components'] = {
className='relative shrink-0 cursor-pointer snap-start self-end bg-card text-card-foreground transition-shadow hover:shadow-lg'
>
<Link
prefetch={false}
href={`/starring?actorId=${actor.id}&title=${encodeURIComponent(actor.name)}`}
onClick={() => context?.onClick?.(actor.id.toString())}
>
@@ -3,13 +3,15 @@ import { useQuery } from '@tanstack/react-query';
import { credits } from '@/api';
interface Props {
showId: Show['id'];
showId?: Show['id'];
showType?: Show['type'];
}
export const KEY = ({ showId, showType }: Props) => ['credits', showId, showType];
const useCredits = ({ showId, showType }: Props) => {
return useQuery({
queryKey: ['credits', showId, showType],
queryKey: KEY({ showId, showType }),
queryFn: () => credits({ showId, showType }),
enabled: Boolean(showId)
});
@@ -19,6 +19,9 @@ import CaptionsMenu from './components/CaptionsMenu';
import VideosMenu from './components/VideosMenu';
import useSource from './useSource';
import '@vidstack/react/player/styles/base.css';
import '@vidstack/react/player/styles/plyr/theme.css';
interface Props {
magnet: string;
subtitles: Source[];