Skip to content

Commit d9d87dd

Browse files
committed
fix toc
1 parent 3a64ead commit d9d87dd

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

.storybook/components/TableOfContent.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
import { useEffect } from 'react';
1+
import { useCallback, useEffect } from 'react';
22
import * as tocbot from 'tocbot';
33
import classes from './ToC.module.css';
44

55
export function TableOfContent({
66
headingSelector = 'h2:not(.noAnchor), h3:not(.noAnchor), h4:not(.noAnchor)',
77
onlyDisplaySideNav = false,
8+
tocOverflowHeight = 1080,
89
}: {
910
headingSelector?: string;
1011
onlyDisplaySideNav?: boolean;
12+
tocOverflowHeight?: number;
1113
}) {
14+
const refCallback = useCallback(
15+
(node: HTMLDivElement) => {
16+
if (node) {
17+
if (
18+
window.matchMedia('(min-width:1330px)').matches &&
19+
window.matchMedia(`(min-height:${tocOverflowHeight}px)`).matches
20+
) {
21+
node.style.overflowY = 'hidden';
22+
} else {
23+
node.style.overflowY = undefined;
24+
}
25+
}
26+
},
27+
[tocOverflowHeight],
28+
);
29+
1230
useEffect(() => {
1331
tocbot.init({
1432
tocSelector: '.js-toc',
@@ -25,13 +43,12 @@ export function TableOfContent({
2543
tocbot.destroy();
2644
};
2745
}, [headingSelector]);
28-
2946
return (
3047
<>
3148
<h3 className={`${classes.header} noAnchor`} data-show-small={!onlyDisplaySideNav}>
3249
Contents
3350
</h3>
34-
<div className={classes.fixedContainer} data-show-small={!onlyDisplaySideNav}>
51+
<div ref={refCallback} className={classes.fixedContainer} data-show-small={!onlyDisplaySideNav}>
3552
<div className={`js-toc ${classes.toc}`} id="toc-container" />
3653
</div>
3754
</>

.storybook/components/ToC.module.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
.toc :global(.toc-link) {
2222
font-family: var(--sapFontFamily) !important;
2323
font-size: var(--sapFontSize) !important;
24-
-webkit-font-smoothing: auto;
2524
line-height: normal;
2625
}
2726

@@ -75,13 +74,14 @@
7574
.fixedContainer {
7675
width: 200px;
7776
position: fixed;
78-
top: 75px;
77+
top: 38px;
7978
right: 6px;
8079
overflow-x: hidden;
8180
overflow-y: auto;
8281
}
8382

8483
.toc :global(.toc-list) {
84+
margin-block-start: 0;
8585
padding-inline-start: 1rem;
8686
}
8787

@@ -93,13 +93,13 @@
9393
width: 4px;
9494
}
9595

96-
.toc :global(.toc-list-item) {
97-
/*overflow: hidden;*/
98-
/*text-overflow: ellipsis;*/
99-
/*white-space: nowrap;*/
100-
}
101-
10296
.toc :global(.is-active-link)::before {
10397
background-color: #0a6ed1;
10498
}
10599
}
100+
101+
@media (min-width: 1650px) {
102+
.fixedContainer {
103+
width: 250px;
104+
}
105+
}

.storybook/preview-head.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@
3939
margin-bottom: 0;
4040
}
4141

42+
@media (min-width: 1330px) {
43+
.sbdocs-content {
44+
padding-inline-end: 200px;
45+
}
46+
}
4247
.sbdocs-content {
43-
max-width: 1100px !important;
48+
max-width: 1300px !important;
4449
}
4550

4651
.responsiveGridLayoutItem {

docs/MigrationGuide.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ or the [changelog](?path=/docs/change-log--page)._
1515
> This migration guide only covers breaking changes when updating from v1 to v2.
1616
> For migration guides for older releases, please refer to our [Migration Guide Archive](https://github.com/SAP/ui5-webcomponents-react/blob/main/docs/MigrationGuide.archive.md).
1717
18-
<TableOfContent headingSelector="h2, h3" />
18+
<TableOfContent headingSelector="h2, h3" tocOverflowHeight={1250} />
1919

2020
## UI5 Web Components Migration Guide
2121

0 commit comments

Comments
 (0)