-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: menu types and added 'button' prop for menu theme #6241
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
Conversation
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.
Trying to pass certain props through menu.button
, like justify
isn't working well because of how child is defined (line 306)
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.
Looks good!
@@ -336,6 +337,7 @@ const Menu = forwardRef((props, ref) => { | |||
justify={item.justify} | |||
kind={!child ? 'option' : undefined} | |||
hoverIndicator={!child ? undefined : 'background'} | |||
{...theme.menu.item} |
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.
This looks like the theme would override justify={item.justify}
above. I'mm wondering if we should more generally merge properties, via something like:
const defaultItemProps = { align: 'start' };
...
<Button {{ ...defaultItemProps, ...theme.menu.item, ...item }} \>
Does that make any sense, or am I missing something?
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.
Agreed. I changed the order of the assignment, let me know if that works.
What does this PR do?
Suggests a clean way for generic styles on Menu's item-buttons via theme. Applying the styles (on both default + mirror rendering) helps declutter lots of inline styles per Menu item.
Improve types of Menu (item type, theme.menu.drop type, etc), the existing Stroybook Menu 'Themed' example is throwing an error due to the

onClick
of the Menu item:Extending Menu 'Themed' story with the new prop
Where should the reviewer start?
Menu.js
What testing has been done on this PR?
storybook - check the enhanced story
How should this be manually tested?
storybook
Do Jest tests follow these best practices?
N/A
screen
is used for querying.userEvent
is used in place offireEvent
.asFragment()
is used for snapshot testing.Any background context you want to provide?
The new prop will help clean up a lot of inline styles within Menu items.
What are the relevant issues?
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Yes.
Should this PR be mentioned in the release notes?
Yes, will be helpful for Menu users and TS users.
Is this change backward compatible or is it a breaking change?
backward compatible