Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mcoker
Copy link
Contributor

@mcoker mcoker commented Dec 16, 2024

closes #7257
closes #7151
closes #7559

Links:

This PR adds:

Settings button and menu toggle

Adds .pf-v6-c-button.pf-m-settings and .pf-v6-c-menu-toggle.pf-m-settings. Nothing tricky, the button/menu-toggle icon element rotates on hover. Takes the regular cog icon.

Hamburger button

This adds .pf-v6-c-button.pf-m-hamburger that requires a specific svg as its icon. For the button variation, there is also .pf-m-collapse and .pf-m-expand that put it in the "collapse" and "expand" states. "collapse" means clicking on it will collapse something (when the hamburger arrow points to the left), "expand" is the opposite. Thinking about that a little, this works for the hamburger, but if it's for a drawer that opens and closes from the right side of the screen, expand and collapse would point in opposite directions. @andrew-ronaldson wdyt? We don't name things "left/right" for RTL reasons, and we use "start/end" instead most of the time, but I don't know if that's appropriate here. Any ideas?

The video below is the animation wired up in a react workspace to show the interaction. Sorry you can't see my mouse.

burger.mp4

The only wrinkle I see is at the 20s mark, when you shrink your screen from desktop to mobile, there is a small delay for the nav to collapse. Here's why that's what's happening. * I noticed another issue - if you're at a mobile viewport and reload the page, you see the hamburger menu blip with an arrow very quickly. I believe it's the same issue - we add .pf-m-expanded to the sidebar by default, then remove it when we detect you're on a mobile viewport.

  • The react component adds .pf-m-expanded to the sidebar when it's expanded on mobile and desktop even though that class only works on mobile (desktop is expanded by default without .pf-m-expanded). So if you load the page on desktop, you're starting out with the sidebar expanded on mobile per the markup.
  • When you resize the window, react monitors the window size and removes .pf-m-expanded once you hit the mobile breakpoint, but only after you stop resizing the window. So you're technically in the mobile breakpoint with the sidebar expanded (because of .pf-m-expanded) until you stop resizing the window, then the class is removed.

I'm not saying we need to fix this now, but as a bug fix, I wonder if we could:

  • Remove .pf-m-expanded from the sidebar by default.
  • When you click on the hamburger, we use isMobile to determine if we need to add .pf-m-expanded or not (only add it if you're on mobile).
  • The blip on refresh on mobile should be fixed if we just remove .pf-m-expanded as a default style.

The react changes I made to enable this are simple, just add the react variation and use it in <PageToggleButton>:

diff --git a/packages/react-core/src/components/Page/PageToggleButton.tsx b/packages/react-core/src/components/Page/PageToggleButton.tsx
index d26ea303b7..6585ea590d 100644
--- a/packages/react-core/src/components/Page/PageToggleButton.tsx
+++ b/packages/react-core/src/components/Page/PageToggleButton.tsx
@@ -35,10 +35,15 @@ export const PageToggleButton: React.FunctionComponent<PageToggleButtonProps> =
           aria-label="Side navigation toggle"
           aria-expanded={sidebarOpen ? 'true' : 'false'}
           variant={ButtonVariant.plain}
+          className="pf-m-hamburger"
+          icon={<svg viewBox="0 0 10 10" className="pf-v6-c-button--hamburger-icon pf-v6-svg" width="1em" height="1em">
+              <path className="pf-v6-c-button--hamburger-icon--top" d="M1,1 L9,1"></path>
+              <path className="pf-v6-c-button--hamburger-icon--middle" d="M1,5 L9,5"></path>
+              <path className="pf-v6-c-button--hamburger-icon--arrow" d="M1,5 L1,5 L1,5"></path>
+              <path className="pf-v6-c-button--hamburger-icon--bottom" d="M9,9 L1,9"></path>
+            </svg>}
           {...props}
-        >
-          {children}
-        </Button>
+        />
       );
     }}
   </PageContextConsumer>

@patternfly-build
Copy link
Collaborator

patternfly-build commented Dec 16, 2024

@mcoker mcoker marked this pull request as ready for review December 16, 2024 21:15
Copy link
Collaborator

@andrew-ronaldson andrew-ronaldson left a comment

Choose a reason for hiding this comment

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

You're a man in motion. All you need is a pair of wings. You'll be where the eagle's flying higher and higher...

TLDR Approved. ✅
I have been adding more examples for future work on my codepen. The last two are more inline with the Red hat icon that we'll introduce some day but we can tackle that closer to release

Copy link
Collaborator

@andrew-ronaldson andrew-ronaldson left a comment

Choose a reason for hiding this comment

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

Updates are looking good!

@mcoker
Copy link
Contributor Author

mcoker commented May 15, 2025

Remaining tasks:

  • move gear to button component
  • move hamburger to button component

@mcoker
Copy link
Contributor Author

mcoker commented May 29, 2025

Remaining tasks:

  • Settings animation should also work in menu toggle. Current thinking is just to duplicate it in the menu toggle. If there is a way to get it to work in button and menu toggle without code duplication, that would be nice - but at this point, not worth putting too much time into as the code is pretty simple/small.
  • Update the hamburger pointy directions to:
  • On desktop
    • No direction by default (regular 3 bars)
    • Show "collapse" arrows on hover/focus
  • On mobile
    • Show "collapse" arrows when expanded
    • Show "expand" arrows on hover/focus when collapsed

Copy link
Collaborator

@andrew-ronaldson andrew-ronaldson left a comment

Choose a reason for hiding this comment

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

cooooooooooooooool. thanks!

@mcoker
Copy link
Contributor Author

mcoker commented Jun 4, 2025

@andrew-ronaldson for the "settings" menu toggle, should the icon rotate on hover/focus when in the expanded state? Or should it only rotate if it isn't open? I suppose the same question for the button's "clicked" state. Currently it rotates for all states (except disabled) - https://patternfly-pr-7260.surge.sh/components/menus/menu-toggle/html/settings/

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Bonus favorite button fix 😻

@mcoker
Copy link
Contributor Author

mcoker commented Jun 4, 2025

Bonus favorite button fix 😻

@srambach doh! I forgot to remove that 😅 Just replaced the hardcoded version/component name in the css vars with the scss var - 4b5e9b1

Copy link

@lboehling lboehling left a comment

Choose a reason for hiding this comment

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

looks amazing! 🤩

@mcoker mcoker merged commit 900afb2 into patternfly:main Jun 4, 2025
4 checks passed
@mcoker mcoker deleted the issue-7257 branch June 4, 2025 17:08
@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.3.0-prerelease.26 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants