Skip to content

Commit

Permalink
fix: skip peek on mobile
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 3, 2023
1 parent e1b0b57 commit b3f7cc6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
51 changes: 28 additions & 23 deletions src/app/timeline/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,42 +222,47 @@ const Item = memo<{
const router = useRouter()
const isMobile = useIsMobile()
const { present } = useModalStack()
const handlePeek = useCallback((e: SyntheticEvent) => {
if (item.type === ArticleType.Note) {
{

const handlePeek = useCallback(
(e: SyntheticEvent) => {
if (isMobile) return
if (item.type === ArticleType.Note) {
{
e.preventDefault()
present({
clickOutsideToDismiss: true,
title: 'Preview',
modalClassName: 'flex justify-center',
modalContainerClassName: 'flex justify-center',
CustomModalComponent: () => (
<PeekModal to={item.href}>
<NotePreview noteId={parseInt(item.href.split('/').pop()!)} />
</PeekModal>
),
content: () => null,
})
}
} else if (item.type === ArticleType.Post) {
e.preventDefault()
const splitpath = item.href.split('/')
const slug = splitpath.pop()!
const category = splitpath.pop()!
present({
clickOutsideToDismiss: true,
title: 'Preview',
modalClassName: 'flex justify-center',
modalContainerClassName: 'flex justify-center',
CustomModalComponent: () => (
<PeekModal to={item.href}>
<NotePreview noteId={parseInt(item.href.split('/').pop()!)} />
<PostPreview category={category} slug={slug} />
</PeekModal>
),
content: () => null,
})
}
} else if (item.type === ArticleType.Post) {
e.preventDefault()
const splitpath = item.href.split('/')
const slug = splitpath.pop()!
const category = splitpath.pop()!
present({
clickOutsideToDismiss: true,
title: 'Preview',
modalClassName: 'flex justify-center',
modalContainerClassName: 'flex justify-center',
CustomModalComponent: () => (
<PeekModal to={item.href}>
<PostPreview category={category} slug={slug} />
</PeekModal>
),
content: () => null,
})
}
}, [])
},
[isMobile],
)
return (
<li
key={item.id}
Expand Down
1 change: 1 addition & 0 deletions src/components/layout/container/Paper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const Paper: Component<{
'-m-4 p-[2rem_1rem] md:m-0 lg:p-[30px_45px]',
'rounded-[0_6px_6px_0] border-neutral-100 shadow-sm dark:border-neutral-800 dark:shadow-[#333] lg:border',
'note-layout-main',
'min-w-0',
className,
)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/peek/PostPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const PostPreview: FC<PostPreviewProps> = (props) => {
<CurrentPostDataAtomProvider overrideAtom={overrideAtom}>
<CurrentPostDataProvider data={data} />
<Paper>
<article className="prose">
<article className="prose relative w-full min-w-0">
<header className="mb-8">
<h1 className="text-center">
<Balancer>{data.title}</Balancer>
Expand Down

1 comment on commit b3f7cc6

@vercel
Copy link

@vercel vercel bot commented on b3f7cc6 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

springtide.vercel.app
shiro-innei.vercel.app
shiro-git-main-innei.vercel.app
innei.in

Please sign in to comment.