Skip to content

Commit 38e34dc

Browse files
authored
Optimise page outline (#3813)
1 parent 04a4175 commit 38e34dc

File tree

3 files changed

+16
-63
lines changed

3 files changed

+16
-63
lines changed

packages/gitbook/src/components/PageAside/AsideSectionHighlight.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/gitbook/src/components/PageAside/PageAside.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ async function PageAsideSections(props: { document: JSONDocument; context: GitBo
169169

170170
const sections = await getDocumentSections(context, document);
171171

172-
return sections.length > 1 ? <ScrollSectionsList sections={sections} /> : null;
172+
return sections.length > 1 ? (
173+
<div className="overflow-y-auto">
174+
<ScrollSectionsList sections={sections} />
175+
</div>
176+
) : null;
173177
}
174178

175179
function PageAsideActions(props: {

packages/gitbook/src/components/PageAside/ScrollSectionsList.tsx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { tcls } from '@/lib/tailwind';
77

88
import { useBodyLoaded } from '@/components/primitives';
99
import { HEADER_HEIGHT_DESKTOP } from '../layout';
10-
import { AsideSectionHighlight } from './AsideSectionHighlight';
1110

1211
/**
1312
* The threshold at which we consider a section as intersecting the viewport.
@@ -44,7 +43,7 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
4443

4544
return (
4645
<ul
47-
className="relative flex flex-col overflow-y-auto border-tint-subtle sidebar-list-line:border-l pb-5 xl:max-2xl:page-api-block:mt-0 xl:max-2xl:page-api-block:p-2"
46+
className="relative flex flex-col border-tint-subtle sidebar-list-line:border-l pb-5 xl:max-2xl:page-api-block:mt-0 xl:max-2xl:page-api-block:p-2"
4847
ref={scrollContainerRef}
4948
>
5049
{sections.map((section) => (
@@ -62,22 +61,6 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
6261
)}
6362
ref={activeId === section.id ? activeItemRef : null}
6463
>
65-
{activeId === section.id && (
66-
<AsideSectionHighlight
67-
className={tcls(
68-
'sidebar-list-default:hidden',
69-
section?.depth > 1
70-
? [
71-
'sidebar-list-default:rounded-l-none',
72-
'sidebar-list-line:rounded-l-none',
73-
]
74-
: [
75-
'sidebar-list-default:ml-3',
76-
'contrast-more:sidebar-list-default:ml-0',
77-
]
78-
)}
79-
/>
80-
)}
8164
<a
8265
href={`#${section.id}`}
8366
className={tcls(
@@ -104,6 +87,10 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
10487
'contrast-more:hover:ring-inset',
10588
'contrast-more:hover:ring-current',
10689

90+
'sidebar-list-line:border-l-2',
91+
'border-transparent',
92+
'sidebar-list-line:-left-px',
93+
10794
section.depth > 1 && [
10895
'subitem',
10996
'sidebar-list-line:pl-6',
@@ -120,17 +107,20 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
120107
'hover:text-primary',
121108
'contrast-more:text-primary',
122109
'contrast-more:hover:text-primary-strong',
123-
'sidebar-list-line:ml-px',
124-
125110
'hover:bg-primary-hover',
111+
126112
'theme-muted:hover:bg-primary-active',
127113
'[html.sidebar-filled.theme-bold.tint_&]:hover:bg-primary-active',
128114
'theme-gradient:hover:bg-primary-active',
129-
130115
'tint:font-semibold',
131116
'contrast-more:font-semibold',
132117

118+
'sidebar-list-line:border-primary-9',
133119
'sidebar-list-default:border-tint',
120+
121+
'sidebar-list-pill:bg-primary',
122+
'[html.theme-muted.sidebar-list-pill_&]:bg-primary-hover',
123+
'[html.theme-gradient.sidebar-list-pill_&]:bg-primary-active',
134124
]
135125
)}
136126
>

0 commit comments

Comments
 (0)