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: align mobile sidebar close button to right side #174

Merged
merged 1 commit into from
Sep 1, 2021

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Sep 1, 2021

image

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2021
@github-actions
Copy link

github-actions bot commented Sep 1, 2021

Dist CSS Diff

diff --git a/packages/core/dist/css/default/default.css b/packages/core/dist-branch/css/default/default.css
index a41c985..42a1145 100644
--- a/packages/core/dist/css/default/default.css
+++ b/packages/core/dist-branch/css/default/default.css
@@ -341,7 +341,7 @@
   --ifm-navbar-search-input-color: var(--ifm-color-emphasis-800);
   --ifm-navbar-search-input-placeholder-color: var(--ifm-color-emphasis-500);
   --ifm-navbar-search-input-icon: url('data:image/svg+xml;utf8,<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="16px" width="16px"><path d="M6.02945,10.20327a4.17382,4.17382,0,1,1,4.17382-4.17382A4.15609,4.15609,0,0,1,6.02945,10.20327Zm9.69195,4.2199L10.8989,9.59979A5.88021,5.88021,0,0,0,12.058,6.02856,6.00467,6.00467,0,1,0,9.59979,10.8989l4.82338,4.82338a.89729.89729,0,0,0,1.29912,0,.89749.89749,0,0,0-.00087-1.29909Z" /></svg>');
-  --ifm-navbar-sidebar-width: 80vw;
+  --ifm-navbar-sidebar-width: 83vw;
   --ifm-pagination-border-radius: calc(
     var(--ifm-global-radius) * var(--ifm-pagination-size-multiplier)
   );
@@ -2706,7 +2706,8 @@ html[data-theme='dark'],
     }
 
 .navbar-sidebar__close {
-      margin: 0 0.8rem 0 0.3rem;
+      display: flex;
+      margin-left: auto;
     }
 
 /**

@github-actions
Copy link

github-actions bot commented Sep 1, 2021

Size Change: +84 B (0%)

Total Size: 565 kB

Filename Size Change
./packages/core/dist/css/default-dark/default-dark-rtl.css 82.2 kB +14 B (0%)
./packages/core/dist/css/default-dark/default-dark-rtl.min.css 57.5 kB +8 B (0%)
./packages/core/dist/css/default-dark/default-dark.css 82.1 kB +13 B (0%)
./packages/core/dist/css/default-dark/default-dark.min.css 57.5 kB +7 B (0%)
./packages/core/dist/css/default/default-rtl.css 80.6 kB +14 B (0%)
./packages/core/dist/css/default/default-rtl.min.css 56.4 kB +8 B (0%)
./packages/core/dist/css/default/default.css 80.5 kB +13 B (0%)
./packages/core/dist/css/default/default.min.css 56.3 kB +7 B (0%)
ℹ️ View Unchanged
Filename Size
./packages/core/dist/js/alerts.js 409 B
./packages/core/dist/js/alerts.min.js 409 B
./packages/core/dist/js/button-groups.js 267 B
./packages/core/dist/js/button-groups.min.js 267 B
./packages/core/dist/js/dropdowns.js 1.01 kB
./packages/core/dist/js/dropdowns.min.js 1.01 kB
./packages/core/dist/js/menu.js 1.94 kB
./packages/core/dist/js/menu.min.js 1.94 kB
./packages/core/dist/js/navbar.js 1.08 kB
./packages/core/dist/js/navbar.min.js 1.08 kB
./packages/core/dist/js/pills.js 270 B
./packages/core/dist/js/pills.min.js 270 B
./packages/core/dist/js/radio-behavior.js 705 B
./packages/core/dist/js/radio-behavior.min.js 705 B
./packages/core/dist/js/tabs.js 267 B
./packages/core/dist/js/tabs.min.js 267 B

compressed-size-action

@netlify
Copy link

netlify bot commented Sep 1, 2021

✔️ Deploy Preview for infima ready!

🔨 Explore the source changes: fbf1726

🔍 Inspect the deploy log: https://app.netlify.com/sites/infima/deploys/612f638b91341e0007472aee

😎 Browse the preview: https://deploy-preview-174--infima.netlify.app/demo

@@ -284,7 +284,8 @@ html[data-theme='dark'],
}

&__close {
margin: 0 0.8rem 0 0.3rem;
display: flex;
margin-left: auto;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As brand and close are already in a flex row, I'm not too fan of using margin-left: auto.

Also why use display: flex here?

As we eventually plan to allow configuring the icon position later, it may be a good idea to account for that today in Infima, as it could later lead to an Infima breaking change?

What about this instead:

  &__brand {
    fiex: 1;
    margin-right: 1rem; // can now be removed? brand with no icon should take all navbar space
  }

  &__right {
    flex: 0;
    margin-left: 1rem;
  }
  &__left {
    flex: 0;
    margin-right: 1rem;
  }

It would be more future proof to add icons on both sides (including multiple icons)


In my opinion, we could even add this to Infima after it's already been in use in Docusaurus for a while, battle-tested and it's considered stable enough. This way we ensure there are limited breaking changes in Infima. It doesn't mean there won't be breaking changes in Docusaurus, but Docusaurus classes are not officially documented and harder to target with custom CSS)

@lex111
Copy link
Contributor Author

lex111 commented Sep 1, 2021 via email

@slorber
Copy link
Collaborator

slorber commented Sep 1, 2021

margin-left: auto is just quick way to move flex item to the right
side. I could have used flex: 1; justify-content: flex-end instead
but does it really matter?

I don't think it's a good practice to mix CSS layout systems when you can stick to one.
The end result may be similar but the implementation would look cleaner (similarly, I wouldn't use float: right).

display: flex is needed to vertical center "x" icon correctly
(missed it in the first PR).

The flex row already align row items to the center.
The alignment problem is due to the button not being a perfect square (it's 20x23 currently)

To fix it properly, you either have to:

  • Define explicit width + height in the button and let the svg use 100% of it.
  • Use line-height: 0; so that button is not larger than the svg, leading to an unexpected expanded clickable area surface

I wouldn't separate current layout on right and left columns now,

Agree, let's do that later


Actually, I noticed other issues that are a bit annoying and only happen at certain viewport widths:

image

As I'd like to fix this asap for the RN website, I'll take over this PR and finish it

Edit: for weird reasons I can't reproduce this bug very consistently, might be a local chrome devtools issue 🤷 (editing meta viewport seems to re-render fine)

@slorber
Copy link
Collaborator

slorber commented Sep 1, 2021

Ok, so I'm going to merge this as-is because unfortunately to do what I want would require a deeper refactoring. flex: 1 can't be applied to the site title because the class is applied directly to the link (and not a layout container) so it would create a link larger than the text with an invisible click area. Also it would move the theme switch (that we only have on Docusaurus site).

@lex111
Copy link
Contributor Author

lex111 commented Sep 1, 2021

Alright, thanks.
Agreed, exactly, resetting of line-height would be better solution. Let's to do this during another refactoring.

@lex111 lex111 deleted the lex111/right-close-mnavbar branch September 1, 2021 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants