Skip to content

Commit d36a8d2

Browse files
committed
fix: read indicator style in note toc
Signed-off-by: Innei <[email protected]>
1 parent 30d5395 commit d36a8d2

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/app/notes/[id]/page.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { ClientOnly } from '~/components/common/ClientOnly'
1414
import { PageDataHolder } from '~/components/common/PageHolder'
1515
import { MdiClockOutline } from '~/components/icons/clock'
1616
import { useSetHeaderMetaInfo } from '~/components/layout/header/internal/hooks'
17-
import { Divider } from '~/components/ui/divider'
1817
import { FloatPopover } from '~/components/ui/float-popover'
1918
import { Loading } from '~/components/ui/loading'
2019
import { Markdown } from '~/components/ui/markdown'
@@ -116,7 +115,7 @@ const NotePage = memo(({ note }: { note: NoteModel }) => {
116115
<TocAside
117116
className="sticky top-[120px] ml-4 mt-[120px]"
118117
treeClassName="max-h-[calc(100vh-6rem-4.5rem-300px)] h-[calc(100vh-6rem-4.5rem-300px)] min-h-[120px] relative"
119-
accessory={NoteReadIndicator}
118+
accessory={ReadIndicator}
120119
>
121120
<NoteActionAside className="translate-y-full" />
122121
</TocAside>
@@ -133,14 +132,6 @@ const NotePage = memo(({ note }: { note: NoteModel }) => {
133132
</Suspense>
134133
)
135134
})
136-
const NoteReadIndicator = () => {
137-
return (
138-
<li>
139-
<Divider />
140-
<ReadIndicator className="text-sm" />
141-
</li>
142-
)
143-
}
144135

145136
const NoteTitle = () => {
146137
const note = useNoteData()

src/components/common/ReadIndicator.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
2-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
31
'use client'
42

53
import type { ElementType } from 'react'

src/components/widgets/toc/Toc.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { atom, useAtom } from 'jotai'
44
import type { FC } from 'react'
55
import type { ITocItem } from './TocItem'
66

7+
import { Divider } from '~/components/ui/divider'
78
import { RightToLeftTransitionView } from '~/components/ui/transition/RightToLeftTransitionView'
89
import { throttle } from '~/lib/_'
910
import { useArticleElement } from '~/providers/article/article-element-provider'
@@ -130,6 +131,12 @@ const TocTree: Component<
130131
},
131132
[],
132133
)
134+
const accessoryElement = useMemo(() => {
135+
if (!accessory) return null
136+
return React.isValidElement(accessory)
137+
? accessory
138+
: React.createElement(accessory as FC)
139+
}, [accessory])
133140
return (
134141
<ul
135142
className={clsxm(
@@ -150,9 +157,12 @@ const TocTree: Component<
150157
/>
151158
)
152159
})}
153-
{React.isValidElement(accessory)
154-
? accessory
155-
: React.createElement(accessory as FC)}
160+
{accessoryElement && (
161+
<li>
162+
{!!toc.length && <Divider />}
163+
{accessoryElement}
164+
</li>
165+
)}
156166
</ul>
157167
)
158168
}

0 commit comments

Comments
 (0)