Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 83e498f

Browse files
authoredFeb 25, 2025··
fix: scroll position of header (#600)
1 parent 2d28203 commit 83e498f

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed
 

‎src/components/Navigation/RightNav.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ interface RightNavProps {
3333
filePath: string;
3434
buildType?: BuildType;
3535
pageUrl?: string;
36+
bannerVisible?: boolean;
3637
}
3738

3839
export default function RightNav(props: RightNavProps) {
39-
const { toc = [], pathConfig, filePath, buildType, pageUrl } = props;
40+
const {
41+
toc = [],
42+
pathConfig,
43+
filePath,
44+
buildType,
45+
pageUrl,
46+
bannerVisible,
47+
} = props;
4048

4149
const theme = useTheme();
4250
const { language, t } = useI18next();
@@ -67,9 +75,11 @@ export default function RightNav(props: RightNavProps) {
6775
<Box
6876
sx={{
6977
position: "sticky",
70-
top: "5rem",
78+
top: bannerVisible ? "7.5rem" : "5rem",
7179
height: "100%",
72-
maxHeight: "calc(100vh - 5rem)",
80+
maxHeight: bannerVisible
81+
? "calc(100vh - 7.5rem)"
82+
: "calc(100vh - 5rem)",
7383
overflowY: "auto",
7484
padding: "36px 16px",
7585
display: "flex",

‎src/styles/typographyDefine.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,12 @@ h5,
7474
h6 {
7575
scroll-margin-top: 5rem;
7676
}
77+
78+
.doc-feature-banner h1,
79+
.doc-feature-banner h2,
80+
.doc-feature-banner h3,
81+
.doc-feature-banner h4,
82+
.doc-feature-banner h5,
83+
.doc-feature-banner h6 {
84+
scroll-margin-top: 7.5rem;
85+
}

‎src/templates/DocTemplate.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export default function DocTemplate({
147147
/>
148148
<Box
149149
sx={{ marginTop: bannerVisible ? "7.5rem" : "5rem", display: "flex" }}
150-
className={clsx("PingCAP-Doc")}
150+
className={clsx("PingCAP-Doc", {
151+
"doc-feature-banner": bannerVisible,
152+
})}
151153
>
152154
<Box sx={{ display: "flex", width: "100%" }}>
153155
{!frontmatter?.hide_leftNav && (
@@ -248,6 +250,7 @@ export default function DocTemplate({
248250
filePath={filePath}
249251
buildType={buildType}
250252
pageUrl={pageUrl}
253+
bannerVisible={bannerVisible}
251254
/>
252255
</Box>
253256
<Box

0 commit comments

Comments
 (0)
Please sign in to comment.