Skip to content

Commit b3f7cc6

Browse files
committed
fix: skip peek on mobile
Signed-off-by: Innei <[email protected]>
1 parent e1b0b57 commit b3f7cc6

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/app/timeline/page.tsx

+28-23
Original file line numberDiff line numberDiff line change
@@ -222,42 +222,47 @@ const Item = memo<{
222222
const router = useRouter()
223223
const isMobile = useIsMobile()
224224
const { present } = useModalStack()
225-
const handlePeek = useCallback((e: SyntheticEvent) => {
226-
if (item.type === ArticleType.Note) {
227-
{
225+
226+
const handlePeek = useCallback(
227+
(e: SyntheticEvent) => {
228+
if (isMobile) return
229+
if (item.type === ArticleType.Note) {
230+
{
231+
e.preventDefault()
232+
present({
233+
clickOutsideToDismiss: true,
234+
title: 'Preview',
235+
modalClassName: 'flex justify-center',
236+
modalContainerClassName: 'flex justify-center',
237+
CustomModalComponent: () => (
238+
<PeekModal to={item.href}>
239+
<NotePreview noteId={parseInt(item.href.split('/').pop()!)} />
240+
</PeekModal>
241+
),
242+
content: () => null,
243+
})
244+
}
245+
} else if (item.type === ArticleType.Post) {
228246
e.preventDefault()
247+
const splitpath = item.href.split('/')
248+
const slug = splitpath.pop()!
249+
const category = splitpath.pop()!
229250
present({
230251
clickOutsideToDismiss: true,
231252
title: 'Preview',
232253
modalClassName: 'flex justify-center',
233254
modalContainerClassName: 'flex justify-center',
234255
CustomModalComponent: () => (
235256
<PeekModal to={item.href}>
236-
<NotePreview noteId={parseInt(item.href.split('/').pop()!)} />
257+
<PostPreview category={category} slug={slug} />
237258
</PeekModal>
238259
),
239260
content: () => null,
240261
})
241262
}
242-
} else if (item.type === ArticleType.Post) {
243-
e.preventDefault()
244-
const splitpath = item.href.split('/')
245-
const slug = splitpath.pop()!
246-
const category = splitpath.pop()!
247-
present({
248-
clickOutsideToDismiss: true,
249-
title: 'Preview',
250-
modalClassName: 'flex justify-center',
251-
modalContainerClassName: 'flex justify-center',
252-
CustomModalComponent: () => (
253-
<PeekModal to={item.href}>
254-
<PostPreview category={category} slug={slug} />
255-
</PeekModal>
256-
),
257-
content: () => null,
258-
})
259-
}
260-
}, [])
263+
},
264+
[isMobile],
265+
)
261266
return (
262267
<li
263268
key={item.id}

src/components/layout/container/Paper.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const Paper: Component<{
1010
'-m-4 p-[2rem_1rem] md:m-0 lg:p-[30px_45px]',
1111
'rounded-[0_6px_6px_0] border-neutral-100 shadow-sm dark:border-neutral-800 dark:shadow-[#333] lg:border',
1212
'note-layout-main',
13+
'min-w-0',
1314
className,
1415
)}
1516
>

src/components/widgets/peek/PostPreview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const PostPreview: FC<PostPreviewProps> = (props) => {
3838
<CurrentPostDataAtomProvider overrideAtom={overrideAtom}>
3939
<CurrentPostDataProvider data={data} />
4040
<Paper>
41-
<article className="prose">
41+
<article className="prose relative w-full min-w-0">
4242
<header className="mb-8">
4343
<h1 className="text-center">
4444
<Balancer>{data.title}</Balancer>

0 commit comments

Comments
 (0)