fix: preview layout
This commit is contained in:
1 parent
ca40872b98
commit
74bfe5726e
4 files changed
+65
-33
No files matched your search
@@ -16,6 +16,7 @@ const Container: FC<Props> = ({ showId, showType }) => (
|
||||
showType={showType}
|
||||
className='rounded-lg bg-background'
|
||||
posterClassName='md:rounded-lg'
|
||||
externalLink={false}
|
||||
/>
|
||||
<div className='h-2 w-full' />
|
||||
</div>
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -17,11 +17,17 @@ const Gallery: FC<Props> = ({ shows }) => (
|
||||
ref={setScrollElement}
|
||||
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
|
||||
>
|
||||
{shows.map((show) => (
|
||||
<li key={show.id} className='snap-start'>
|
||||
<Poster className='!h-[350px] !w-[230px] text-sm' show={show} onClick={() => showPreviewModal({ show })} />
|
||||
</li>
|
||||
))}
|
||||
{shows
|
||||
.filter((show) => show.poster['1x'])
|
||||
.map((show) => (
|
||||
<li key={show.id} className='snap-start'>
|
||||
<Poster
|
||||
className='!h-[350px] !w-[230px] text-sm'
|
||||
show={show}
|
||||
onClick={() => showPreviewModal({ show })}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</ScrollNavigation>
|
||||
|
||||
Reference in new issue
Block a user