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

feat(MenuItem|AccordionTitle): add ability for removing and customizing the (active|submenu) indicator #721

Merged
merged 19 commits into from
Jan 21, 2019

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Jan 14, 2019

This PR aims to fix #687 (allowing the user to remove the submenu indicator), as well is is adding props for customizing the indicator, by providing an icon shorthand. I have few proposal for the API, and would like to hear your opinion on them.

  1. Add explicit props for all things
  • hideSubmenuIndicator: boolean - indicartes whether the submenu indicators should be shown
  • submenuIndicatorVertical: ShorthandValue - shorthand for icon for the submenu indicators in the vertical menus
  • submenuIndicatorHorizontal: ShorthandValue - shorthand for icon for the submenu indicators in the horizontal menus

Pros: this API provides you to define all indicators in the root menu, and all these will be propagated to all submenus (vertical and horizontal)
Cons: too many properties added for just one slot

  1. Add single property
  • submenuIndicator: boolean | ShorthandValue - this is a single prop that defined whether the submenu indicator shuold be shown (true or false), but also allows the user to specify shorthand for the icon in it.

Props: we are adding just one prop for the submenu indicator, so the user doesn't have to think which one he should apply.
Cons: with this approach, we cannot specify on the root menu what should the submenu indicators in all menus be, as the vertical and horizontal menus are most likely to be different icons. This means, every menu shuold define the submenu indicators in it's first children MenuItems.

3. Add single property and transform the icon - this is currently implemented

  • submenuIndicator: boolean | ShorthandValue - this is a single prop that defined whether the submenu indicator shuold be shown (true or false), but also allows the user to specify shorthand for the icon in it. For the vertical menus, we can transform this icon 90 degrees.

Props: we are adding just one prop for the submenu indicator, so the user doesn't have to think which one he should apply. Allows the user to specify the submenu indicator on the root menu
Cons: not sure whether this would be expected behavior for the client.

TODO:

  • update changelog
  • add Indicator examples

manajdov added 2 commits January 14, 2019 18:05
… for the vertical and horizontal menus

-TODO rethink the names used
@mnajdova mnajdova changed the title feat(Menu): added prop for hiding the submenu indicator, as well as shorthands for it (vertical and horizontal) feat(Menu): added hideSubmenuIndicator prop, submenuIndicator[Vertical|Horizontal] shorthand for icon Jan 14, 2019
@mnajdova mnajdova changed the title feat(Menu): added hideSubmenuIndicator prop, submenuIndicator[Vertical|Horizontal] shorthand for icon feat(Menu): add ability for removing and customizing the submenu indicator Jan 15, 2019
manajdov added 2 commits January 15, 2019 12:37
-supporting rtl for the icons
-added submenu and active indicators in the Menu and AccordionTitle components
@sophieH29
Copy link
Contributor

sophieH29 commented Jan 15, 2019

Thought that came into my mind, users might want to have different icons for open/close state. Do we consider to support it too?

image

Anyway, I would vote for option 2

@mnajdova
Copy link
Contributor Author

@sophieH29 thanks for your thoughts. This is currently possible, by adding styles for the MenuItem, not sure if we want to blow up the API, by adding additional things at this moment. If this comes as a requirement in the future, sure we can extend the API. However at this moment, I would restrain from adding more props. Do you have strong opinion that we want to support this at this moment?

@mnajdova mnajdova changed the title feat(Menu): add ability for removing and customizing the submenu indicator feat(MenuItem|AccordionTitle): add ability for removing and customizing the (active|submenu) indicator Jan 16, 2019
vertical,
submenuIndicator,
} = this.props
const submenuIndicatorWithDefault = submenuIndicator === undefined ? true : submenuIndicator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot specify the default value of the submenuIndicator in the defaultProp, as it is itemShorthand and conflicts with the children. If anybody has other idea, please let me know.

@sophieH29
Copy link
Contributor

@sophieH29 thanks for your thoughts. This is currently possible, by adding styles for the MenuItem, not sure if we want to blow up the API, by adding additional things at this moment. If this comes as a requirement in the future, sure we can extend the API. However at this moment, I would restrain from adding more props. Do you have strong opinion that we want to support this at this moment?

Don't have a strong opinion that we need to support it right now, rather out of curiosity and something that we can keep in mind.

@codepretty
Copy link
Collaborator

My vote is for the 3rd option, it seems the most minimal to get the job done.


export interface IndicatorProps extends UIComponentProps, ColorComponentProps {
/** The indicator can be direction in different directions. */
direction?: 'forward' | 'back' | 'top' | 'bottom'
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, it seems a bit confusable, what is 'bottom' and what is 'back'. I guess it's left but seems not very intuitive.
Maybe just 'right', 'left', 'top', 'bottom' - simple and straightforward

Copy link
Member

Choose a reason for hiding this comment

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

right and left are not RTL safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would like to avoid the right and left, as in rtl it won't make sense to use them.. I am open to other suggestion. This one were gathered from the browser arrows for navigation (back and forward). Maybe start and end? What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we use 'right' and 'left' for the Popup too.
I don't think start end is better as it more describes a position in regards to something. If no other ideas then let's leave 'back' and 'forward'. If treat it as video player buttons it makes more sense 😄

Copy link
Member

Choose a reason for hiding this comment

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

I vote for start and end as these are the direction names we use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miroslavstastny agree, let's strive for consistency, although it seems really strange for me to have the '<' indicator a start, and '>' as end.. We can change it later anyway...

-refactored icon styles to be more readable
@alinais
Copy link
Contributor

alinais commented Jan 17, 2019

@sophieH29, @mnajdova I don't think it is in the scope of this fix to allow other icon variants for the submenu. Let's create a separate feature and address it separately.

@mnajdova
Copy link
Contributor Author

@sophieH29, @mnajdova I don't think it is in the scope of this fix to allow other icon variants for the submenu. Let's create a separate feature and address it separately.

@alinais I agree is not the scope of this fix, but I would rather create another issue and address it as part of this PR, as otherwise we will add just one prop for removing the indicator and then we will introduce breaking changes for refactoring it to this implementation..

manajdov added 5 commits January 17, 2019 15:38
-moved the rotate icon prop from default to override props in the Indicator component
# Conflicts:
#	src/components/Menu/MenuItem.tsx
#	src/themes/teams/components/Menu/menuItemStyles.ts
-remove helper methods for getting the mapping arrow in rtl
@@ -37,6 +37,9 @@ export interface IconProps extends UIComponentProps, ColorComponentProps {
/** Name of the icon. */
name?: string

/** An icon can be rotated by the degree specified as number. */
rotate?: number
Copy link
Member

Choose a reason for hiding this comment

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

String looks like a valid value, too:

<Indicator rotate='90' />

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 rotate property of the icon can be used for calculation as well, take a look in the Indicator component (the overrideProps function for the Icon). In that case we will need to cast this to number if it was provided as string. Do we really want this?

@alinais alinais added this to mnajdova in Core Team Jan 21, 2019
@mnajdova mnajdova merged commit 519fda8 into master Jan 21, 2019
@alinais alinais deleted the feat/menu-item-hide-submenu-indicator branch January 21, 2019 15:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Core Team
  
mnajdova
Development

Successfully merging this pull request may close these issues.

Ability to remove arrow from submenu
6 participants