Skip to content

Commit a136560

Browse files
committed
fix: toc tree and read indicator pos
1 parent ac980ef commit a136560

File tree

5 files changed

+44
-30
lines changed

5 files changed

+44
-30
lines changed

src/components/common/404.tsx

-14
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ export const NotFound404 = () => {
77
</div>
88

99
<p>你来到了没有知识的荒原</p>
10-
<style global jsx>
11-
{`
12-
.hit-the-floor {
13-
font-size: 12em;
14-
font-weight: bold;
15-
font-family: Helvetica;
16-
text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb,
17-
0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, 0.1),
18-
0 0 5px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.3),
19-
0 3px 5px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.25),
20-
0 10px 10px rgba(0, 0, 0, 0.2), 0 20px 20px rgba(0, 0, 0, 0.15);
21-
}
22-
`}
23-
</style>
2410
</>
2511
)
2612
}

src/components/widgets/shared/ArticleRightAside.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const ArticleRightAsideImpl: Component = ({ children }) => {
6464
as="div"
6565
className="static ml-4"
6666
treeClassName={clsx(
67-
'absolute h-full min-h-[120px] overflow-auto',
67+
'absolute h-full min-h-[120px] flex flex-col',
6868
isScrollToBottom && 'mask-t',
6969
isScrollToTop && 'mask-b',
7070
canScroll && !isScrollToBottom && !isScrollToTop && 'mask-both',

src/components/widgets/toc/TocItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const TocItem: FC<{
6363
style={useMemo(
6464
() => ({
6565
paddingLeft:
66-
depth >= rootDepth ? `${renderDepth * 0.6}rem` : undefined,
66+
depth >= rootDepth ? `${renderDepth * 0.6 + 0.5}rem` : '0.5rem',
6767
}),
6868
[depth, renderDepth, rootDepth],
6969
)}

src/components/widgets/toc/TocTree.tsx

+22-14
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,28 @@ export const TocTree: Component<
126126
: React.createElement(accessory as FC)
127127
}, [accessory])
128128
return (
129-
<ul className={clsxm('px-2 scrollbar-none', className)} ref={containerRef}>
130-
{toc?.map((heading) => {
131-
return (
132-
<MemoedItem
133-
heading={heading}
134-
isActive={heading.anchorId === activeId}
135-
key={heading.title}
136-
rootDepth={rootDepth}
137-
onClick={handleScrollTo}
138-
/>
139-
)
140-
})}
129+
<ul
130+
className={clsxm(
131+
'flex flex-grow flex-col px-2 scrollbar-none',
132+
className,
133+
)}
134+
ref={containerRef}
135+
>
136+
<ul className="overflow-auto scrollbar-none">
137+
{toc?.map((heading) => {
138+
return (
139+
<MemoedItem
140+
heading={heading}
141+
isActive={heading.anchorId === activeId}
142+
key={heading.title}
143+
rootDepth={rootDepth}
144+
onClick={handleScrollTo}
145+
/>
146+
)
147+
})}
148+
</ul>
141149
{accessoryElement && (
142-
<li>
150+
<li className="flex-shrink-0">
143151
{!!toc.length && <Divider />}
144152
{accessoryElement}
145153
</li>
@@ -177,7 +185,7 @@ const MemoedItem = memo<{
177185
<m.span
178186
layoutId="active-toc-item"
179187
layout
180-
className="absolute -left-2 bottom-[3px] top-[3px] w-[2px] rounded-sm bg-accent"
188+
className="absolute bottom-[3px] left-0 top-[3px] w-[2px] rounded-sm bg-accent"
181189
/>
182190
)}
183191
<TocItem

src/styles/theme.css

+20
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@
120120
opacity: 0;
121121
}
122122
}
123+
124+
/* 404 */
125+
.hit-the-floor {
126+
font-size: 12em;
127+
font-weight: bold;
128+
font-family: Helvetica;
129+
text-shadow:
130+
0 1px 0 #ccc,
131+
0 2px 0 #c9c9c9,
132+
0 3px 0 #bbb,
133+
0 4px 0 #b9b9b9,
134+
0 5px 0 #aaa,
135+
0 6px 1px rgba(0, 0, 0, 0.1),
136+
0 0 5px rgba(0, 0, 0, 0.1),
137+
0 1px 3px rgba(0, 0, 0, 0.3),
138+
0 3px 5px rgba(0, 0, 0, 0.2),
139+
0 5px 10px rgba(0, 0, 0, 0.25),
140+
0 10px 10px rgba(0, 0, 0, 0.2),
141+
0 20px 20px rgba(0, 0, 0, 0.15);
142+
}
123143
}
124144

125145
.mask-both {

0 commit comments

Comments
 (0)