Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Menu): Menu width and Submenu indicator fix #1831

Merged
merged 29 commits into from
Sep 6, 2019

Conversation

bcalvery
Copy link
Contributor

@bcalvery bcalvery commented Aug 20, 2019

Objective: Improve width behavior and update indicator icon to chevron type.

Before:
image
image

After:
image
image

@codecov
Copy link

codecov bot commented Aug 20, 2019

Codecov Report

Merging #1831 into master will decrease coverage by 0.03%.
The diff coverage is 46.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1831      +/-   ##
==========================================
- Coverage    69.9%   69.87%   -0.04%     
==========================================
  Files         888      890       +2     
  Lines        7775     7783       +8     
  Branches     2244     2275      +31     
==========================================
+ Hits         5435     5438       +3     
- Misses       2330     2335       +5     
  Partials       10       10
Impacted Files Coverage Δ
.../src/themes/teams/components/Menu/menuVariables.ts 33.33% <ø> (ø) ⬆️
packages/react/src/themes/teams/index.tsx 90.9% <ø> (ø) ⬆️
...react/src/themes/base/components/Icon/iconNames.ts 75% <ø> (ø) ⬆️
...act/src/themes/teams/components/Menu/menuStyles.ts 0% <0%> (ø) ⬆️
...src/themes/teams/components/Menu/menuItemStyles.ts 6.81% <0%> (-0.27%) ⬇️
...ms/components/Icon/svg/icons/chevronDownMedium.tsx 100% <100%> (ø)
...s/components/Icon/svg/icons/chevronRightMedium.tsx 100% <100%> (ø)
packages/react/src/components/Menu/MenuItem.tsx 48.48% <100%> (+0.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea1f208...e37ac34. Read the comment docs.

add examples to test width
@lucivpav
Copy link
Contributor

I think that when using the RTL mode, the submenu arrow should point to the opposite direction. Also, the expanded submenu should go to the opposite side in RTL mode.
image

@codepretty
Copy link
Collaborator

Should icons in the menu cause items without icons to shift right in order to align?

In teams theme, I don't think it should shift menu items without icons. I don't think it is a common case but the few examples I found do not shift.

image

image

{menu &&
Icon.create(indicatorWithDefaults, {
defaultProps: {
name: vertical ? 'stardust-arrow-end' : 'stardust-arrow-down',
name: vertical ? 'chevron-right' : 'chevron-down',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the stardust prefix for icons is used to indicate when a different icons is used per theme. So I think you might want to update or add a reference.

https://github.com/stardust-ui/react/blob/master/packages/react/src/themes/teams/index.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how I would I go about changing modifying 'stardust-arrow-down' and 'stardust-arrow-end' just in the context of Menu.
image
Would change it for every case of 'stardust-arrow-down and -right' which isn't what I want - I don't think it is at least.
Doing this would mean new assets are needed for the default Stardust theme right?
image

@@ -255,8 +256,8 @@ class MenuItem extends AutoControlledComponent<WithAsProp<MenuItemProps>, MenuIt
<>
<Ref innerRef={this.menuRef}>
<Popper
align={vertical ? 'top' : 'start'}
position={vertical ? 'after' : 'below'}
align={vertical ? 'top' : rtl ? 'end' : 'start'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Stardust noobie question here for @codepretty, @levithomason , etc.: would this be better done within Popper? Making Popper itself respect RTL settings would eliminate this work on the consumer's end, which may otherwise be forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. Popper seems to be a bit more generic - it depends on the element using it to feed it position information, and the positioning of Menu is affected by RTL possibly differently than other items using Popper. @levithomason ?
https://github.com/stardust-ui/react/blob/master/packages/react/src/lib/positioner/Popper.tsx

Copy link
Contributor

Choose a reason for hiding this comment

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

But Popper should respect rtl, this works perfectly if you use the Popup component for example:
image

Let me dive into this tomorrow and see what's happening

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mnajdova Menu is using "Popper" not "Popup" - maybe that is part of the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am trying to swap in Popup for Popper in MenuItem, and it just is not working:
image

Popper has a targetRef property, while Popup seems to have a target property which is passed to Popper in Popup), but target of Popup doesn't want to accept {this.itemRef}.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@bcalvery, i think you have a good solution. i think it probably makes sense to keep this rtl logic where you have it unless we know how popper will be used in all cases, it might not make sense to prematurely move this logic to popper.

@@ -11,6 +11,8 @@ export const icons: ThemeIcons = {
'stardust-arrow-down': fontIcon('25BE'),
'stardust-arrow-end': fontIcon('25B8'),
'stardust-arrow-up': fontIcon('25B4'),
'stardust-menu-arrow-down': fontIcon('25BE'),
'stardust-menu-arrow-end': fontIcon('25B8'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's nice to scope these icons per component, so people would ideally configure via the theme which icons should appear on which components. 👍

CHANGELOG.md Outdated Show resolved Hide resolved
content: ({ props: p }): ICSSInJSStyle => {
const widthAdjust = (p.icon ? 26 : 0) + (p.menu ? 16 : 0)
return {
whiteSpace: 'normal',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the default value is already normal.. is this white-space property overriding something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The root element has whiteSpace: 'nowrap' and that seems to affect all children, but the text within the "content" should wrap if necessary, so this returns it to 'normal'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants