8000 feat(menu-toggle): remove extra div, reorder examples by srambach · Pull Request #6321 · patternfly/patternfly · GitHub
[go: up one dir, main page]

Skip to content

feat(menu-toggle): remove extra div, reorder examples#6321

Merged
mcoker merged 3 commits intopatternfly:v6from
srambach:6318-menu-toggle-followup
Feb 20, 2024
Merged

feat(menu-toggle): remove extra div, reorder examples#6321
mcoker merged 3 commits intopatternfly:v6from
srambach:6318-menu-toggle-followup

Conversation

@srambach
Copy link
Member

Fixes #6318

Removes the extra div around some examples.
Reorders within example sets so that the toggles are always collapsed, expanded, disabled
Styles disabled plain version to match the disabled plain button.

@patternfly-build
Copy link
Collaborator
patternfly-build commented Feb 14, 2024

@srambach srambach linked an issue Feb 15, 2024 that may be closed by this pull request
Copy link
Contributor
@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM! Just one nit. Also we'll need to poke around for plain menu toggles and make sure they have the icon wrapper. If we use the suggested code in my nit comment, that will let us include/exclude the icon wrapper behind the scenes without needing to go through the code and include/exclude the nested {{> menu-toggle-icon ...}} child that's in the PR now.

@@ -161,15 +161,15 @@ import './MenuToggle.css'
### Plain
```hbs
{{#> menu-toggle menu-toggle--IsPlain=true menu-toggle--attribute='aria-label="Actions"'}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tried it, but the hbs looks like it might be wired up so you can write it this way?

Suggested change
{{#> menu-toggle menu-toggle--IsPlain=true menu-toggle--attribute='aria-label="Actions"'}}
{{> menu-toggle menu-toggle--IsPlain=true menu-toggle--attribute='aria-label="Actions"' menu-toggle--icon="ellipsis-v"}}

Copy link
Member Author

Choose a reason for hiding this comment

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

@mcoker the additional changes you made for this in the examples/demos all look good.

@mcoker
Copy link
Contributor
mcoker commented Feb 20, 2024

@thatblindgeye @tlabaj this PR updates the plain menu toggle to include the the icon wrapper pf-v5-c-menu-toggle__icon. That lets us assign icon styling to that class that's consistent between plain and non-plain menu toggles, compared to what we do now which is style that class in non-plain menu toggles and style the whole menu toggle with icon styles for plain toggles. One issue with the way we do it now is that not all plain toggles contain just an icon - the breadcumb dropdown, for example, is a plain toggle with a badge.

With this update, looking at the update we'll need to make to the menu toggle component in react, I'm guessing that might mean that an icon is always passed as the icon prop, instead of passed as children for plain toggles? Do you see any issues with that change? FWIW, I'd like to make the same update to button - we'll add a wrapper for button text, and text will always go in the text container, and an icon will always go in the icon container, for all button variants.

@thatblindgeye
Copy link
Contributor

Just wanted to show a screenshot from React after adding the icon wrapper around the plain toggle's svg icon and updating the styles to remove the margin and line-height from that wrapper:

Plain Menu toggle with icon wrapper around icon

Just to check that it looks as expected in React.

As for any necessary updates in React, it may depend how much we want to restrict passing anything as children to MenuToggle. Right now a user could pass whatever: "Toggle text", <div class="fancy">ToggleText</div>, <SomeIcon />, etc.

So we could update prop descriptions and examples to convey that we recommend passing all icons to the icon prop and only text content (whether it be wrapped in some other element or not) as children, but that wouldn't really stop consumers from still passing icons as children. Which maybe that's on the consumer to update to get the intended styling; we can provide a codemod to at least warn consumers about this sort of update so they're aware.

Alternatively we could restrict the type that can be passed to children to just a string or creating a new "text" prop to replace children, neither of which sound all to intuitive or great.

Here's what it may look like passing the icon to the icon prop isntead of children; note that I had to manually delete the __controls content and place the pf-m-plain class in dev tools due to how we're rendering the MenuToggle (doing everything in the example code results in nothing being rendered for a plain toggle since its expecting children to render).

Plain menu toggle with icon passed to icon prop

Depending where we land on this, I can use the open React issue for Penta MenuToggle updates to add this wrapper and make any other necessary updates if we want.

@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.0.0-alpha.87 🎉

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

Development

Successfully merging this pull request may close these issues.

Menu toggle follow up for alpha

4 participants

0