-
-
Notifications
You must be signed in to change notification settings - Fork 784
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 <[email protected]>
- Loading branch information
Showing
7 changed files
with
43 additions
and
5 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.comment__message { | ||
* { | ||
@apply leading-6; | ||
@apply break-all leading-6; | ||
} | ||
|
||
h1, | ||
|
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 |
---|---|---|
@@ -1,18 +1,50 @@ | ||
'use client' | ||
|
||
import { useDeferredValue } from 'react' | ||
import clsx from 'clsx' | ||
import type { ElementType } from 'react' | ||
|
||
import { useIsMobile } from '~/atoms' | ||
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition' | ||
import { RootPortal } from '~/components/ui/portal' | ||
import useDebounceValue from '~/hooks/common/use-debounce-value' | ||
import { useReadPercent } from '~/hooks/shared/use-read-percent' | ||
import { clsxm } from '~/lib/helper' | ||
import { useIsEOWrappedElement } from '~/providers/shared/WrappedElementProvider' | ||
|
||
export const ReadIndicator: Component<{ | ||
as?: ElementType | ||
}> = ({ className, as }) => { | ||
const readPercent = useReadPercent() | ||
const readPercent = useDebounceValue(useReadPercent(), 200) | ||
const As = as || 'span' | ||
return ( | ||
<As className={clsxm('text-gray-800 dark:text-neutral-300', className)}> | ||
{readPercent}% | ||
<NumberSmoothTransition>{readPercent}</NumberSmoothTransition>% | ||
</As> | ||
) | ||
} | ||
|
||
export const ReadIndicatorForMobile: Component<{}> = () => { | ||
const readPercent = useDeferredValue(useReadPercent()) | ||
const isEOA = useIsEOWrappedElement() | ||
const isMobile = useIsMobile() | ||
if (!isMobile) return null | ||
|
||
return ( | ||
<RootPortal> | ||
<div | ||
className={clsx( | ||
'fixed bottom-0 right-0 top-0 z-[99] w-[1px] transition-opacity duration-200 ease-in-out', | ||
isEOA ? 'opacity-0' : 'opacity-100', | ||
)} | ||
> | ||
<div | ||
className="absolute top-0 w-full bg-accent/80" | ||
style={{ | ||
height: `${readPercent}%`, | ||
}} | ||
/> | ||
</div> | ||
</RootPortal> | ||
) | ||
} |
0130eee
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 – ./
springtide.vercel.app
shiro-innei.vercel.app
innei.in
shiro-git-main-innei.vercel.app