-
-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
12 changed files
with
177 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const FETCH_SIZE = 10 | ||
export const QUERY_KEY = ['recent'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useLayoutEffect } from 'react' | ||
|
||
import { usePeek } from './usePeek' | ||
|
||
declare global { | ||
interface Window { | ||
peek: ReturnType<typeof usePeek> | ||
} | ||
} | ||
|
||
export const PeekPortal = () => { | ||
const peek = usePeek() | ||
|
||
useLayoutEffect(() => { | ||
peek && (window.peek = peek) | ||
}, [peek]) | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useCallback } from 'react' | ||
|
||
import { useIsMobile } from '~/atoms' | ||
import { useModalStack } from '~/providers/root/modal-stack-provider' | ||
|
||
import { PeekModal } from './PeekModal' | ||
|
||
export const usePeek = () => { | ||
const isMobile = useIsMobile() | ||
const { present } = useModalStack() | ||
return useCallback( | ||
(href: string) => { | ||
if (isMobile) return | ||
const basePresentProps = { | ||
clickOutsideToDismiss: true, | ||
title: 'Preview', | ||
modalClassName: | ||
'relative mx-auto mt-[10vh] scrollbar-none max-w-full overflow-auto px-2 lg:max-w-[65rem] lg:p-0', | ||
} | ||
|
||
if (href.startsWith('/notes/')) { | ||
requestAnimationFrame(async () => { | ||
const NotePreview = await import('./NotePreview').then( | ||
(module) => module.NotePreview, | ||
) | ||
present({ | ||
...basePresentProps, | ||
CustomModalComponent: () => ( | ||
<PeekModal to={href}> | ||
<NotePreview noteId={parseInt(href.split('/').pop()!)} /> | ||
</PeekModal> | ||
), | ||
content: () => null, | ||
}) | ||
}) | ||
|
||
return true | ||
} else if (href.startsWith('/posts/')) { | ||
requestAnimationFrame(async () => { | ||
const PostPreview = await import('./PostPreview').then( | ||
(module) => module.PostPreview, | ||
) | ||
const splitpath = href.split('/') | ||
const slug = splitpath.pop()! | ||
const category = splitpath.pop()! | ||
present({ | ||
...basePresentProps, | ||
CustomModalComponent: () => ( | ||
<PeekModal to={href}> | ||
<PostPreview category={category} slug={slug} /> | ||
</PeekModal> | ||
), | ||
content: () => null, | ||
}) | ||
}) | ||
return true | ||
} | ||
|
||
return false | ||
}, | ||
[isMobile, present], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fc6c00e
There was a problem hiding this comment.
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 – ./
innei.in
shiro-innei.vercel.app
springtide.vercel.app
shiro-git-main-innei.vercel.app