Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change MiniToc position in DOM #248

Merged
merged 9 commits into from
Jul 26, 2024
3 changes: 3 additions & 0 deletions src/components/DocLayout/DocLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

&__left,
&__right {
order: 3;
Copy link
Contributor

@martyanovandrey martyanovandrey Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is adding "order" property necessary ? Changing order in html is not enough?

Copy link
Contributor Author

@Pavel-Tyan Pavel-Tyan Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing order in html affects on focus order. But it also affects on Minitoc position in UI. Minitoc should be in the right side of layout and main content should be in the middle (Toc -> Main content -> MiniToc). Without "order" property MiniToc will be in the middle of layout and main content will be in the right side (Toc -> MiniToc -> Main content).

flex: 0 0 auto;
box-sizing: content-box;
}
Expand All @@ -28,6 +29,7 @@
}

&__left {
order: 1;
width: 276px;

&_full-screen {
Expand All @@ -36,6 +38,7 @@
}

&__center {
order: 2;
flex: 1 1 auto;
position: relative;
min-width: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/DocLayout/DocLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export class DocLayout extends React.Component<DocLayoutProps> {
{left}
</div>
)}
{fullScreen || hideRight ? null : <div className={b('right', modes)}>{right}</div>}
<div className={b('center', modes)}>
{center}
<div className={b('desktop-only')}>{footer}</div>
</div>
{fullScreen || hideRight ? null : <div className={b('right', modes)}>{right}</div>}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/MiniToc/MiniToc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
font-weight: 500;
color: var(--g-color-text-primary);
margin-bottom: 12px;
margin-top: 0;
}

&__sections {
Expand Down
6 changes: 3 additions & 3 deletions src/components/MiniToc/MiniToc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const MiniToc = memo<MinitocProps>(({headings, router, headerHeight, onItemClick
}

return (
<div className={b()}>
<div className={b('title')}>{t<string>('title')}:</div>
<nav className={b()} aria-label={t('article-navigation')}>
<h2 className={b('title')}>{t<string>('title')}:</h2>
<Scrollspy
className={b('sections')}
currentClassName={b('section', {active: true})}
Expand All @@ -67,7 +67,7 @@ const MiniToc = memo<MinitocProps>(({headings, router, headerHeight, onItemClick
</li>
))}
</Scrollspy>
</div>
</nav>
);
});

Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"mini-toc": {
"title": "In this article",
"article-navigation": "Article navigation",
"description": "Current article contents"
},
"toc-nav-panel": {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"mini-toc": {
"title": "В этой статье",
"article-navigation": "Навигация по статье",
"description": "Содержание текущей статьи"
},
"toc-nav-panel": {
Expand Down
Loading