-
Notifications
You must be signed in to change notification settings - Fork 55
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: add new mobile menu #151
Conversation
Size Change: -208 B (0%) Total Size: 539 kB
ℹ️ View Unchanged
|
✔️ Deploy Preview for infima ready! 🔨 Explore the source changes: 652d0aa 🔍 Inspect the deploy log: https://app.netlify.com/sites/infima/deploys/60e86d1666ec6a0007a29111 😎 Browse the preview: https://deploy-preview-151--infima.netlify.app |
My position about Docusaurus<->Infima is that both are quite coupled and I don't think many users will use Infima outside Docusaurus users anyway. I was in favor of moving it to the Docusaurus repo and making it an implementation detail of the classic theme, not necessarily recommend the usage of it for users, so that they could easily switch from one theme to another without re-implementing their pages. You and @yangshun didn't really agree with this idea and wanted to keep it as a separate repo/project, so I don't have a strong opinion about which CSS rule should be in Infima or Docusaurus 😅 if it was me I'd just put everything in the Docusaurus repo and even rename Infima as Now about the JS question, not 100% sure but it actually looks unused on Docusaurus, so it basically only has value for the demo page and the users of Infima outside Docusaurus. Not sure it's something we should invest in, as Docusaurus is unlikely to benefit from this. I still see value in using some vanilla JS in Docusaurus: it would permit to mark some JS items as critical, and make them interactive before React hydration. But it's an effort that is not started yet and I'm not even sure it's worth investing in this, as React selective hydration and server components might make this optimization less useful. |
If we don't implement the secondary menu in Infima, then it doesn't make sense to include some styles for that, right? For example, the code below is essentially needed for the secondary menu to work. And if this menu is not implemented in Infima itself, then there's not much point in related styles in the final bundle. infima/packages/core/styles/components/navbar.pcss Lines 266 to 270 in 0d50f44
Therefore, will implement secondary menu on Infima's demo page to follow the previously chosen approach. It also helps to keep secondary menu styles in one place (Infima), and in Docusaurus code we don't need to write any extra code for that. WDYT? |
In practice any CSS added to Infima is some additional dev friction for me so I'd rather have everything in Docusaurus. If you really want to have more CSS in Infima, it's up to you and @yangshun, and I'll follow what you decide but it's not the choice I would make. |
I just like the consistency, so I think it makes sense to stick with the previous approach. |
…111/remove-res-menu
Dist CSS Diffdiff --git a/packages/core/dist/css/default/default.css b/packages/core/dist-branch/css/default/default.css
index 7d4c397..a7341bc 100644
--- a/packages/core/dist/css/default/default.css
+++ b/packages/core/dist-branch/css/default/default.css
@@ -2392,33 +2392,6 @@ hr:after {
background: var(--ifm-menu-color-background-active);
}
-.menu--responsive .menu__button {
- bottom: 2rem;
- display: none;
- position: fixed;
- right: 1rem;
- z-index: var(--ifm-z-index-fixed);
- }
-
-.menu--show {
- background: var(--ifm-background-surface-color);
- bottom: 0;
- left: 0;
- -ms-scroll-chaining: none;
- overscroll-behavior: contain;
- padding: 1rem;
- position: fixed;
- right: 0;
- top: 0;
- z-index: var(--ifm-z-index-overlay);
- }
-
-.menu--show .menu__list {
- display: inherit;
- opacity: 1;
- transition: opacity var(--ifm-transition-fast) linear;
- }
-
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
@@ -2657,14 +2630,38 @@ html[data-theme='dark'],
.navbar-sidebar__items {
display: flex;
height: calc(100% - var(--ifm-navbar-height));
+ transform: translateZ(0);
+ transition: transform var(--ifm-transition-fast) ease-in-out;
+ }
+
+.navbar-sidebar__items--show-secondary {
+ transform: translate3d(
+ calc((var(--ifm-navbar-sidebar-width)) * -1),
+ 0,
+ 0
+ );
+ }
+
+.navbar-sidebar__item {
+ flex-shrink: 0;
+ padding: 0.5rem;
+ width: calc(var(--ifm-navbar-sidebar-width));
}
-.navbar-sidebar__items > div {
- flex-shrink: 0;
- padding: 0.5rem;
- width: calc(var(--ifm-navbar-sidebar-width));
+.navbar-sidebar__item--secondary {
+ padding-top: 0;
}
+.navbar-sidebar__back {
+ background: var(--ifm-menu-color-background-active);
+ font-size: 15px;
+ font-weight: var(--ifm-button-font-weight);
+ margin: 0 0 0.7rem -0.5rem;
+ padding: 0.6rem 1.5rem;
+ text-align: left;
+ width: calc(100% + 1rem);
+ }
+
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
@@ -2971,14 +2968,6 @@ html[data-theme='dark'] {
padding-right: 0
}
-.menu--responsive .menu__button {
- display: inherit
- }
- .menu--responsive:not(.menu--show) .menu__list {
- display: none;
- opacity: 0;
- }
-
.navbar > .container,
.navbar > .container-fluid {
padding: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks fine to me.
Just afraid it would add dev friction it we later need to do additional changes.
For example I think we could later replace the back arrow with a proper svg or something, and this would probably require changing Infima again. I'm not too fan of these back-and-forth due to having 2 repos instead of 1.
If you think we should merge it, feel free to do so and cleanup on Docusaurus side
Do you mean that we will need to make changes to appropriate React component in Docusaurus? Yes, of course, will prepare PR for this.
This can be done without changing Infima code, here we just provide basic styles to make two menus work. |
I mean that having to release Infima and then Docusaurus adds DX friction. If we were able to modify Infima + Docusaurus and see the live result of those changes in a single atomic PR, that would be much more convenient to review and ensure that the Infima side + Docusaurus side are both compatible with each other. A scenario that happens from time to time is that you change Infima, release it, then try to integrate the changes on Docusaurus, figure out Infima changes were not good enough, have to release Infima again with new changes to only then have everything working in Docusaurus. |
Since we are introducing new mobile UX in facebook/docusaurus#4273, we can already remove styles for old-responsive sidebar menu.
@slorber it's just not clear to me -- do we need to implement secondary menu functionality in Infima itself as before in
menu.js
file?