Skip to content

Commit de0c2b4

Browse files
authored
fix(TOC): fixes toc showing incorrectly at exactly 1450px (#4802)
Tweaked spacing/breakpoints and added better flex layout.
1 parent 22a2dc5 commit de0c2b4

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

packages/documentation-framework/components/tableOfContents/tableOfContents.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
margin-block-end: var(--pf-t--global--spacer--md);
99
margin-inline-start: calc(var(--pf-v6-c-page__main-section--PaddingInlineStart) * -1);
1010
margin-inline-end: calc(var(--pf-v6-c-page__main-section--PaddingInlineEnd) * -2);
11-
padding-block-start: var(--pf-t--global--spacer--md);
12-
padding-block-end: var(--pf-t--global--spacer--md);
11+
padding-block-start: var(--pf-t--global--spacer--sm);
12+
padding-block-end: var(--pf-t--global--spacer--sm);
1313
padding-inline-start: var(--pf-t--global--spacer--md);
1414
padding-inline-end: 0;
1515
box-shadow: var(--pf-t--global--box-shadow--lg--bottom);
@@ -24,7 +24,7 @@
2424
}
2525

2626
/* Mobile jumplinks */
27-
@media (max-width: 1450px) {
27+
@media (max-width: 1449px) {
2828
.ws-toc.pf-m-expanded .pf-v6-c-jump-links__main {
2929
max-height: 65vh;
3030
overflow-y:auto;
@@ -46,19 +46,20 @@
4646
display: none;
4747
}
4848

49-
@media (min-width: 1451px) {
49+
@media (min-width: 1450px) {
5050
.ws-toc {
51-
width: 260px;
51+
min-width: 270px;
52+
max-width: 320px;
5253
max-height: calc(100vh - 76px);
5354
overflow-y: auto;
5455
/* Hide TOC scrollbar IE, Edge & Firefox */
5556
-ms-overflow-style: none;
5657
scrollbar-width: none;
57-
order: 1;
58-
padding: 0 var(--pf-t--global--spacer--lg) var(--pf-t--global--spacer--lg) var(--pf-t--global--spacer--2xl);
59-
flex-grow: 1;
58+
padding: 0 0 0 var(--pf-t--global--spacer--2xl);
6059
background: none;
6160
margin: 0;
61+
order: 1;
62+
flex: 1 1 320px;
6263
}
6364

6465
.ws-toc,
@@ -72,7 +73,7 @@
7273
text-align: left;
7374
}
7475

75-
@media (min-width: 1451px) {
76+
@media (min-width: 1450px) {
7677
.ws-toc .pf-v6-c-jump-links__main {
7778
margin-bottom: var(--jump-links-main-margin-bottom);
7879
}

packages/documentation-framework/components/tableOfContents/tableOfContents.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ export const TableOfContents = ({ items }) => {
1818
const { innerWidth } = window;
1919
innerWidth !== width && setWidth(innerWidth);
2020
};
21+
22+
const getOffset = () => {
23+
if (width >= 1450) {
24+
return 88 + stickyNavHeight;
25+
} else if (width >= 768) {
26+
return 142 + stickyNavHeight;
27+
} else {
28+
return 190 + stickyNavHeight;
29+
}
30+
};
31+
2132
let jumpLinksItems = [];
2233
let wasSublistRendered = false;
2334

@@ -96,7 +107,7 @@ export const TableOfContents = ({ items }) => {
96107
style={{ top: stickyNavHeight,
97108
'--jump-links-main-margin-bottom': `${stickyNavHeight}px`
98109
}}
99-
offset={width > 1450 ? 108 + stickyNavHeight : 148 + stickyNavHeight}
110+
offset={getOffset()}
100111
expandable={{ default: 'expandable', '2xl': 'nonExpandable' }}
101112
>
102113
{renderJumpLinksItems()}

packages/documentation-framework/templates/mdx.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ p.pf-v6-c-content--p.ws-p {
2525
}
2626

2727
.ws-example-page-wrapper {
28-
max-width: min(100%, 825px);
28+
min-width: 825px;
29+
max-width: 1200px;
30+
flex-grow: 1;
2931
}

packages/documentation-framework/templates/mdx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
108108
);
109109
// Create dynamic component for @reach/router
110110
const ChildComponent = () => (
111-
<div className={source !== 'landing-pages' ? 'pf-v6-l-flex' : ''}>
111+
<div className={source !== 'landing-pages' ? 'pf-v6-l-flex pf-v6-m-column pf-m-nowrap-on-2xl' : ''}>
112112
{toc.length > 1 && <TableOfContents items={toc} />}
113113
<Stack hasGutter className={(source !== 'landing-pages' && 'ws-example-page-wrapper')}>
114114
{InlineAlerts}

0 commit comments

Comments
 (0)