Skip to content

Commit 2331603

Browse files
committed
feat: read indicator
Signed-off-by: Innei <[email protected]>
1 parent fb72500 commit 2331603

File tree

4 files changed

+150
-83
lines changed

4 files changed

+150
-83
lines changed

src/app.config.json

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"// example app config": "",
3+
"footer": {
4+
"otherInfo": {
5+
"date": "2020-{{now}}"
6+
},
7+
"linkSections": [
8+
{
9+
"name": "关于",
10+
"links": [
11+
{
12+
"name": "关于本站",
13+
"href": "/about-site"
14+
},
15+
{
16+
"name": "关于我",
17+
"href": "/about-me"
18+
},
19+
{
20+
"name": "关于此项目",
21+
"href": "https://github.com/innei/Shiro",
22+
"external": true
23+
}
24+
]
25+
},
26+
{
27+
"name": "更多",
28+
"links": [
29+
{
30+
"name": "时间线",
31+
"href": "/timeline"
32+
},
33+
{
34+
"name": "友链",
35+
"href": "/friends"
36+
},
37+
{
38+
"name": "监控",
39+
"href": "https://status.shizuri.net/status/main",
40+
"external": true
41+
}
42+
]
43+
},
44+
{
45+
"name": "联系",
46+
"links": [
47+
{
48+
"name": "写留言",
49+
"href": "/message"
50+
},
51+
{
52+
"name": "发邮件",
53+
"href": "mailto:[email protected]",
54+
"external": true
55+
},
56+
{
57+
"name": "GitHub",
58+
"href": "https://github.com/innei",
59+
"external": true
60+
}
61+
]
62+
}
63+
]
64+
},
65+
"config": {
66+
"bg": [
67+
"https://github.com/Innei/static/blob/master/images/F0q8mwwaIAEtird.jpeg?raw=true",
68+
"https://github.com/Innei/static/blob/master/images/IMG_2111.jpeg.webp.jpg?raw=true"
69+
],
70+
"custom": {
71+
"css": [],
72+
"styles": [],
73+
"js": [],
74+
"scripts": []
75+
},
76+
"site": {
77+
"favicon": "/innei.svg"
78+
},
79+
"hero": {
80+
"title": {
81+
"template": [
82+
{
83+
"type": "h1",
84+
"text": "Hi, I'm ",
85+
"class": "font-light text-4xl"
86+
},
87+
{
88+
"type": "h1",
89+
"text": "Innei",
90+
"class": "font-medium mx-2 text-4xl"
91+
},
92+
{
93+
"type": "h1",
94+
"text": "👋。",
95+
"class": "font-light text-4xl"
96+
},
97+
{
98+
"type": "br"
99+
},
100+
{
101+
"type": "h1",
102+
"text": "A NodeJS Full Stack ",
103+
"class": "font-light text-4xl"
104+
},
105+
{
106+
"type": "code",
107+
"text": "<Developer />",
108+
"class": "font-medium mx-2 text-3xl rounded p-1 bg-gray-200 dark:bg-gray-800/0 hover:dark:bg-gray-800/100 bg-opacity-0 hover:bg-opacity-100 transition-background duration-200"
109+
},
110+
{
111+
"type": "span",
112+
"class": "inline-block w-[1px] h-8 -bottom-2 relative bg-gray-800/80 dark:bg-gray-200/80 opacity-0 group-hover:opacity-100 transition-opacity duration-200 group-hover:animation-blink"
113+
}
114+
]
115+
},
116+
"description": "An independent developer coding with love."
117+
},
118+
"module": {
119+
"donate": {
120+
"enable": true,
121+
"link": "https://afdian.net/@Innei",
122+
"qrcode": [
123+
"https://cdn.jsdelivr.net/gh/Innei/img-bed@master/20191211132347.png",
124+
"https://cdn.innei.ren/bed/2023/0424213144.png"
125+
]
126+
},
127+
"bilibili": {
128+
"liveId": 1434499
129+
}
130+
}
131+
}
132+
}

src/app.config.ts

-65
This file was deleted.

src/components/layout/footer/config.ts

-11
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,3 @@ export interface FooterConfig {
7676
linkSections: LinkSection[]
7777
otherInfo: OtherInfo
7878
}
79-
80-
// export const footerConfig = {
81-
// linkSections,
82-
// otherInfo: {
83-
// date: '2020-{{now}}',
84-
// // icp: {
85-
// // text: '浙 ICP 备 20028356 号',
86-
// // link: 'http://www.beian.miit.gov.cn/',
87-
// // }
88-
// } as OtherInfo,
89-
// }

src/components/widgets/shared/ReadIndicator.tsx

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useDeferredValue } from 'react'
4-
import clsx from 'clsx'
4+
import { useInView } from 'react-intersection-observer'
55
import type { ElementType } from 'react'
66

77
import { useIsMobile } from '~/atoms'
@@ -17,25 +17,30 @@ export const ReadIndicator: Component<{
1717
}> = ({ className, as }) => {
1818
const readPercent = useDebounceValue(useReadPercent(), 200)
1919
const As = as || 'span'
20+
21+
const { ref, inView } = useInView()
22+
2023
return (
21-
<As className={clsxm('text-gray-800 dark:text-neutral-300', className)}>
24+
<As
25+
className={clsxm('text-gray-800 dark:text-neutral-300', className)}
26+
ref={ref}
27+
>
2228
<NumberSmoothTransition>{readPercent}</NumberSmoothTransition>%
29+
{!inView && <ReadIndicatorVertical className="right-[10px]" />}
2330
</As>
2431
)
2532
}
2633

27-
export const ReadIndicatorForMobile: Component<{}> = () => {
34+
const ReadIndicatorVertical: Component = ({ className }) => {
2835
const readPercent = useDeferredValue(useReadPercent())
2936
const isEOA = useIsEOWrappedElement()
30-
const isMobile = useIsMobile()
31-
if (!isMobile) return null
32-
3337
return (
3438
<RootPortal>
3539
<div
36-
className={clsx(
40+
className={clsxm(
3741
'fixed bottom-0 right-0 top-0 z-[99] w-[1px] transition-opacity duration-200 ease-in-out',
3842
isEOA ? 'opacity-0' : 'opacity-100',
43+
className,
3944
)}
4045
>
4146
<div
@@ -48,3 +53,9 @@ export const ReadIndicatorForMobile: Component<{}> = () => {
4853
</RootPortal>
4954
)
5055
}
56+
export const ReadIndicatorForMobile: Component<{}> = () => {
57+
const isMobile = useIsMobile()
58+
if (!isMobile) return null
59+
60+
return <ReadIndicatorVertical />
61+
}

0 commit comments

Comments
 (0)