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: switch to Flexbox in announcement bar #5430

Merged
merged 4 commits into from
Aug 30, 2021
Merged

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Aug 27, 2021

Motivation

  • Less code/complexity
  • Better centered vertical alignment
Before After
before after

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 Aug 27, 2021
@lex111 lex111 requested a review from slorber as a code owner August 27, 2021 09:19
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 27, 2021
@netlify
Copy link

netlify bot commented Aug 27, 2021

✔️ [V2]

🔨 Explore the source changes: 8fa7bbd

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

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

@github-actions
Copy link

github-actions bot commented Aug 27, 2021

⚡️ Lighthouse report for the changes in this PR:

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

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

@github-actions
Copy link

github-actions bot commented Aug 27, 2021

Size Change: -72 B (0%)

Total Size: 820 kB

Filename Size Change
website/build/assets/css/styles.********.css 94.9 kB -77 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 36.5 kB 0 B
website/build/assets/js/main.********.js 411 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus/index.html 66.6 kB +1 B (0%)
website/build/blog/index.html 37.5 kB +1 B (0%)
website/build/docs/index.html 44 kB 0 B
website/build/docs/installation/index.html 52 kB 0 B
website/build/index.html 30.2 kB +1 B (0%)
website/build/tests/docs/index.html 24.6 kB +1 B (0%)
website/build/tests/docs/standalone/index.html 22.3 kB +1 B (0%)

compressed-size-action

--docusaurus-announcement-bar-height: 30px;
}

/* Adjust line-height for proper vertical centering on desktop */
Copy link
Collaborator

Choose a reason for hiding this comment

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

not a fan of using line-height for vertical centering

If user use --docusaurus-announcement-bar-height: 50px; it should remain centered. That's not the case in prod+PR.

I suggest using flex + alignItems/justifyContent center in the navbar content too

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, the close button may not need to use relative positioning.

It is probably possible to render a flex row [placeholder,content,closeButton] using flex: 0 0 50px for elements on the side (both optional elements), and flex-grow: 1 on the center .

Just an idea, probably not really useful to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't really understand your idea, what kind of placeholder you have in mind? But I fixed vertical alignment, and also applied built-in close class from Infima to close button, it seems to look better, wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The placeholder could be an empty div of the same width as the close button that would just push the main content to the center.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That looks nice overall but the content is not perfectly centered. It's not very visible, but if you increase the close button % width to something more significant, the centering issue is more visible, and this becomes more important to add a placeholder container on the other side.

image

Also, what about not using % for close button width?
At least for very small viewports, 4% is too small and doesn't really make sense to me, and the close button can touch the edges of the screen.

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would look better if the placeholder used flex-basis: 10px for small widths?
Centering is less important for mobile devices where we want to use more space

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 think it would look better if the placeholder used flex-basis: 10px for small widths?

It doesn't look good, maybe just don't use the placeholder column on mobiles?

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't look good, maybe just don't use the placeholder column on mobiles?

This is not the result I get 🤪 Only the placeholder should have flex-basis 10 for small screens/mobile, not the close button

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe just don't use the placeholder column on mobiles?

I'm fine with removing it too, as long as there's some padding that prevents the main content from touching the edge of the screen (which would be the same as applying that padding by setting a width to this placeholder)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done it.

@slorber
Copy link
Collaborator

slorber commented Aug 30, 2021

👍

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