-
Notifications
You must be signed in to change notification settings - Fork 53
feat(MenuItem|AccordionTitle): add ability for removing and customizing the (active|submenu) indicator #721
Conversation
… for the vertical and horizontal menus -TODO rethink the names used
-supporting rtl for the icons -added submenu and active indicators in the Menu and AccordionTitle components
@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? |
src/components/Menu/MenuItem.tsx
Outdated
vertical, | ||
submenuIndicator, | ||
} = this.props | ||
const submenuIndicatorWithDefault = submenuIndicator === undefined ? true : submenuIndicator |
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.
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.
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. |
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' |
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.
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
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.
right
and left
are not RTL safe.
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.
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?
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.
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 😄
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.
I vote for start
and end
as these are the direction names we use.
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.
@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
-added examples
@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.. |
-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
docs/src/examples/components/Indicator/Types/IndicatorExampleDirection.shorthand.tsx
Outdated
Show resolved
Hide resolved
@@ -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 |
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.
String looks like a valid value, too:
<Indicator rotate='90' />
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.
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?
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.
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
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
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: