Skip to content

Conversation

ShimiSun
Copy link
Collaborator

@ShimiSun ShimiSun commented Jul 20, 2022

What does this PR do?

  1. 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.

  2. 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:
    image

  3. 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.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • 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

@ShimiSun ShimiSun requested a review from ericsoderberghp July 20, 2022 17:28
@ShimiSun ShimiSun changed the title fix: menu types and added buttonProps for menu theme fix: menu types and added 'button' prop for menu theme Jul 20, 2022
@ShimiSun ShimiSun requested a review from jcfilben July 20, 2022 20:49
@ShimiSun ShimiSun requested a review from jcfilben July 21, 2022 02:47
Copy link
Collaborator

@jcfilben jcfilben left a 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)

Copy link
Collaborator

@jcfilben jcfilben left a 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}
Copy link
Contributor

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?

Copy link
Collaborator Author

@ShimiSun ShimiSun Aug 22, 2022

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.

@ericsoderberghp ericsoderberghp merged commit bd64433 into master Aug 24, 2022
@ericsoderberghp ericsoderberghp deleted the fix/menu-types branch August 24, 2022 06:50
@ericsoderberghp ericsoderberghp removed their assignment Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants