fix: preview layout
This commit is contained in:
1 parent
ca40872b98
commit
74bfe5726e
4 files changed
+50
-18
No files matched your search
@@ -16,6 +16,7 @@ const Container: FC<Props> = ({ showId, showType }) => (
|
|||||||
showType={showType}
|
showType={showType}
|
||||||
className='rounded-lg bg-background'
|
className='rounded-lg bg-background'
|
||||||
posterClassName='md:rounded-lg'
|
posterClassName='md:rounded-lg'
|
||||||
|
externalLink={false}
|
||||||
/>
|
/>
|
||||||
<div className='h-2 w-full' />
|
<div className='h-2 w-full' />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,13 +12,30 @@ import { cn } from '@/lib/utils';
|
|||||||
interface Props {
|
interface Props {
|
||||||
show: Show & Partial<Details>;
|
show: Show & Partial<Details>;
|
||||||
className: string;
|
className: string;
|
||||||
|
externalLink: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Actions = ({ show, className }: Props) => {
|
const Actions = ({ show, className, externalLink }: Props) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const state = useShowState({ showId: show.id, showType: show.type });
|
const state = useShowState({ showId: show.id, showType: show.type });
|
||||||
const toggle = useMutateShowState(show);
|
const toggle = useMutateShowState(show);
|
||||||
|
|
||||||
|
const copyLink = (
|
||||||
|
<Button
|
||||||
|
aria-label='Copy link'
|
||||||
|
title='Copy link'
|
||||||
|
variant='outline'
|
||||||
|
className='h-8 px-3'
|
||||||
|
onClick={() =>
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(`${location.origin}/${show.type}/${show.id}`)
|
||||||
|
.then(() => toast({ description: 'Link has been copied' }))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Link size={14} />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('flex gap-2 flex-grow-0', className)}>
|
<div className={cn('flex gap-2 flex-grow-0', className)}>
|
||||||
<ButtonsGroup className='pointer-events-none'>
|
<ButtonsGroup className='pointer-events-none'>
|
||||||
@@ -49,21 +66,16 @@ const Actions = ({ show, className }: Props) => {
|
|||||||
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
|
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonsGroup>
|
</ButtonsGroup>
|
||||||
<ButtonsGroup className='ml-auto sm:ml-0'>
|
{externalLink ? (
|
||||||
|
<ButtonsGroup>
|
||||||
|
{copyLink}
|
||||||
|
{externalLink && (
|
||||||
<Button
|
<Button
|
||||||
aria-label='Copy link'
|
aria-label='Open in new tab'
|
||||||
title='Copy link'
|
title='Open in new tab'
|
||||||
variant='outline'
|
variant='outline'
|
||||||
className='h-8 px-3'
|
className='relative h-8 px-3'
|
||||||
onClick={() =>
|
|
||||||
navigator.clipboard
|
|
||||||
.writeText(`${location.origin}/${show.type}/${show.id}`)
|
|
||||||
.then(() => toast({ description: 'Link has been copied' }))
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Link size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button aria-label='Open in new tab' title='Open in new tab' variant='outline' className='relative h-8 px-3'>
|
|
||||||
<a
|
<a
|
||||||
className='absolute left-0 top-0 size-full'
|
className='absolute left-0 top-0 size-full'
|
||||||
target='_blank'
|
target='_blank'
|
||||||
@@ -72,8 +84,11 @@ const Actions = ({ show, className }: Props) => {
|
|||||||
/>
|
/>
|
||||||
<ExternalLink size={14} />
|
<ExternalLink size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</ButtonsGroup>
|
</ButtonsGroup>
|
||||||
|
) : (
|
||||||
|
copyLink
|
||||||
|
)}
|
||||||
<ButtonsGroup className='ml-auto sm:ml-0'>
|
<ButtonsGroup className='ml-auto sm:ml-0'>
|
||||||
<Button
|
<Button
|
||||||
aria-label='Watch'
|
aria-label='Watch'
|
||||||
|
|||||||
@@ -19,9 +19,19 @@ interface Props {
|
|||||||
posterClassName?: string;
|
posterClassName?: string;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
poster?: ReactNode;
|
poster?: ReactNode;
|
||||||
|
externalLink?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Preview: FC<Props> = ({ show: baseShow, showType, showId, className, posterClassName, onClose, poster }) => {
|
const Preview: FC<Props> = ({
|
||||||
|
show: baseShow,
|
||||||
|
showType,
|
||||||
|
showId,
|
||||||
|
className,
|
||||||
|
posterClassName,
|
||||||
|
onClose,
|
||||||
|
poster,
|
||||||
|
externalLink = true
|
||||||
|
}) => {
|
||||||
const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type });
|
const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type });
|
||||||
|
|
||||||
if (!baseShow && !detailedShow) return null;
|
if (!baseShow && !detailedShow) return null;
|
||||||
@@ -57,7 +67,7 @@ const Preview: FC<Props> = ({ show: baseShow, showType, showId, className, poste
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Actions className='order-1 mb-4 md:order-2' show={show} />
|
<Actions externalLink={externalLink} className='order-1 mb-4 md:order-2' show={show} />
|
||||||
|
|
||||||
<p key={show.id} className='order-4 md:order-4 md:line-clamp-3' title={show.overview}>
|
<p key={show.id} className='order-4 md:order-4 md:line-clamp-3' title={show.overview}>
|
||||||
{show.overview}
|
{show.overview}
|
||||||
|
|||||||
@@ -17,9 +17,15 @@ const Gallery: FC<Props> = ({ shows }) => (
|
|||||||
ref={setScrollElement}
|
ref={setScrollElement}
|
||||||
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
|
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
|
||||||
>
|
>
|
||||||
{shows.map((show) => (
|
{shows
|
||||||
|
.filter((show) => show.poster['1x'])
|
||||||
|
.map((show) => (
|
||||||
<li key={show.id} className='snap-start'>
|
<li key={show.id} className='snap-start'>
|
||||||
<Poster className='!h-[350px] !w-[230px] text-sm' show={show} onClick={() => showPreviewModal({ show })} />
|
<Poster
|
||||||
|
className='!h-[350px] !w-[230px] text-sm'
|
||||||
|
show={show}
|
||||||
|
onClick={() => showPreviewModal({ show })}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in new issue
Block a user