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

fix(blog): move toc to left on large screens #9772

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions client/src/blog/post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,56 @@
grid-template-columns: minmax(auto, 1fr) minmax(0, 52rem) minmax(15rem, 1fr);
}

> .sidebar-container {
@media screen and (min-width: $screen-xxl) {
grid-template-areas:
"toc post place"
"toc newsletter place";
grid-template-columns: minmax(15rem, 1fr) minmax(0, 52rem) minmax(
15rem,
1fr
);
}

> .toc-container {
--offset: var(--top-nav-height);
display: none;

.toc-container {
position: unset;
top: auto;
}

@media screen and (min-width: $screen-lg) {
display: flex;
flex-direction: column;
grid-area: toc;

.toc > nav {
margin-top: 2rem;
}
}
@media screen and (min-width: $screen-xxl) {
display: contents;

.place.side,
.toc {
height: max-content;
mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 0) 0%,
rgb(0, 0, 0) 3rem calc(100% - 3rem),
rgba(0, 0, 0, 0) 100%
);
max-height: calc(100vh - var(--offset));
overflow: auto;
position: sticky;
top: var(--offset);
}

.place.side {
grid-area: place;
margin-top: 0;

> .pong-box {
margin-top: 2rem;
}
}
}
}

> .section-newsletter {
Expand Down
14 changes: 5 additions & 9 deletions client/src/blog/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,11 @@ export function BlogPost(props: HydrationData) {
<>
{doc && blogMeta && (
<main className="blog-post-container container">
<div className="sidebar-container">
<div className="toc-container">
<aside className="toc">
<nav>
{doc.toc && !!doc.toc.length && <TOC toc={doc.toc} />}
</nav>
</aside>
{PLACEMENT_ENABLED && !blogMeta?.sponsored && <SidePlacement />}
</div>
<div className="sidebar-container toc-container">
<aside className="toc">
<nav>{doc.toc && !!doc.toc.length && <TOC toc={doc.toc} />}</nav>
</aside>
{PLACEMENT_ENABLED && !blogMeta?.sponsored && <SidePlacement />}
</div>
<article
className="blog-post blog-container main-page-content"
Expand Down
5 changes: 3 additions & 2 deletions client/src/document/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ kbd {
}
}

&.toc-container,
.toc-container {
.place {
grid-area: toc;
Expand All @@ -801,7 +802,7 @@ kbd {
display: flex;
flex-direction: column;
gap: 0;
height: calc(100vh - var(--sticky-header-with-actions-height));
height: calc(100vh - var(--offset));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an unrelated fix?

mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 0) 0%,
Expand All @@ -810,7 +811,7 @@ kbd {
);
overflow: auto;
position: sticky;
top: var(--sticky-header-with-actions-height);
top: var(--offset);
Copy link
Contributor

Choose a reason for hiding this comment

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

dito


.place {
margin: 1rem 0;
Expand Down