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

refactor(v2): increase content area if blog sidebar is off #5171

Merged
merged 3 commits into from
Jul 20, 2021

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Jul 14, 2021

Motivation

Originally from #5150

If blogSidebarCount field is 0 in blog config, then sidebar will not appear on blog pages. In this case it is reasonable to increase the content area by 2 column.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Preview

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Jul 14, 2021
@lex111 lex111 requested a review from slorber as a code owner July 14, 2021 22:46
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 14, 2021
@netlify
Copy link

netlify bot commented Jul 14, 2021

✔️ [V2]

🔨 Explore the source changes: 0101585

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60f666f6984db7000792905e

😎 Browse the preview: https://deploy-preview-5171--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Jul 14, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 74
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5171--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Jul 14, 2021

Size Change: -165 B (0%)

Total Size: 850 kB

Filename Size Change
website/build/assets/css/styles.********.css 89.1 kB +48 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 62.3 kB -30 B (0%)
website/build/blog/index.html 26.3 kB -30 B (0%)
website/build/docs-tests/index.html 20.3 kB -30 B (0%)
website/build/docs-tests/standalone/index.html 18.8 kB -30 B (0%)
website/build/docs/index.html 40.2 kB -33 B (0%)
website/build/docs/installation/index.html 47.8 kB -33 B (0%)
website/build/index.html 27.3 kB -30 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 58.8 kB 0 B
website/build/assets/js/main.********.js 459 kB +3 B (0%)

compressed-size-action

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Thanks, extracting BlogLayout looks like a nice idea!
Added a few comments

})}>
{children}
</main>
{toc && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion we should always render the TOC layout container (col--2) even if the toc is absent (blog post list) or the toc is empty (blog post with no headings)

This permits to avoid having the blog layout being offset as we navigate from the blog list of a blog post. It was the case before.

Eventually we could add a blog plugin option to disable the toc globally, similarly to the sidebar, in which case we could make the blog post content larger. If options.blogSidebarCount === 0 && !options.toc => col--12? (or maybe col--10 col--offset-1 as 12 might be too big?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This permits to avoid having the blog layout being offset as we navigate from the blog list of a blog post. It was the case before.

However, then we would lose the correct central positioning, it is OK?

12 might be too big?

That's a lot, so I wouldn't use more col-9 for content area.

Copy link
Collaborator

@slorber slorber Jul 19, 2021

Choose a reason for hiding this comment

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

However, then we would lose the correct central positioning, it is OK?

To me, what matters most is that the real blog post content is centered, not really having perfect centering of the group "optional sidebar + content + optional toc".

In this screenshot, the group is centered:

image

In this one, the content is centered. Not perfectly though (it's not a big deal imho), but it looks better to me

image

and will permit to have a consistent layout on all the blog pages, and no layout shift when navigating to a blog post item:

image

<main
className={clsx('col', {
'col--7': hasSidebar,
'col--9': !hasSidebar,
Copy link
Collaborator

@slorber slorber Jul 16, 2021

Choose a reason for hiding this comment

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

sidebar is 3 cols so why not go from 7 to 9 ?

Now without sidebar cols = 11, not 12

If we don't want the content to be 10 (too big?) and keep 9.
I suggest to use hasSidebar ? "col--9 col--offset-1" : "col--7"=> the main content will be better centered

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, we used col--7 for content area (main element), so in case of no sidebar exist, increase it to col--9, which is the most appropriate maximum for comfortable reading.

We don't need to use col--offset-1 because we already center all columns via justify-content: center

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree that we'd rather limit the max width

We don't need to use col--offset-1 because we already center all columns via justify-content: center

It's not exactly the same.
Using justify-content: center means the 11 cols will be centered, so there's 1/2 col spacing on both sides but as there's no sidebar, the main content is a bit too much on the left (personal opinion).

Using col--offset-1 is more akin to using justify-content: flex-end, and the main content could become a bit more centered (but this can only be applied to larger desktop IMHO, it would look weird on medium width). What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really like this pseudo-centering aligning, but have changed back to this behavior as you proposed.

@slorber slorber merged commit 12cea5e into master Jul 20, 2021
@slorber
Copy link
Collaborator

slorber commented Jul 20, 2021

thanks 👍

@slorber slorber deleted the lex111/blog-layout branch August 17, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants