fix: preview layout

This commit is contained in:
ner committed 2024-11-16 20:36:50 +02:00
1 parent ca40872b98
commit 74bfe5726e
4 files changed
+65 -33

No files matched your search

+41 -26
View File
@@ -12,13 +12,30 @@ import { cn } from '@/lib/utils';
interface Props {
show: Show & Partial<Details>;
className: string;
externalLink: boolean;
}
const Actions = ({ show, className }: Props) => {
const Actions = ({ show, className, externalLink }: Props) => {
const { toast } = useToast();
const state = useShowState({ showId: show.id, showType: show.type });
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 (
<div className={cn('flex gap-2 flex-grow-0', className)}>
<ButtonsGroup className='pointer-events-none'>
@@ -49,31 +66,29 @@ const Actions = ({ show, className }: Props) => {
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
</Button>
</ButtonsGroup>
<ButtonsGroup className='ml-auto sm:ml-0'>
<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>
<Button aria-label='Open in new tab' title='Open in new tab' variant='outline' className='relative h-8 px-3'>
<a
className='absolute left-0 top-0 size-full'
target='_blank'
rel='noopener noreferrer'
href={`${SITE_URL}/${show.type}/${show.id}`}
/>
<ExternalLink size={14} />
</Button>
</ButtonsGroup>
{externalLink ? (
<ButtonsGroup>
{copyLink}
{externalLink && (
<Button
aria-label='Open in new tab'
title='Open in new tab'
variant='outline'
className='relative h-8 px-3'
>
<a
className='absolute left-0 top-0 size-full'
target='_blank'
rel='noopener noreferrer'
href={`${SITE_URL}/${show.type}/${show.id}`}
/>
<ExternalLink size={14} />
</Button>
)}
</ButtonsGroup>
) : (
copyLink
)}
<ButtonsGroup className='ml-auto sm:ml-0'>
<Button
aria-label='Watch'
+12 -2
View File
@@ -19,9 +19,19 @@ interface Props {
posterClassName?: string;
onClose?: () => void;
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 });
if (!baseShow && !detailedShow) return null;
@@ -57,7 +67,7 @@ const Preview: FC<Props> = ({ show: baseShow, showType, showId, className, poste
)}
</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}>
{show.overview}