feat(Menu): adding kind prop for the items and MenuDivider component#682
feat(Menu): adding kind prop for the items and MenuDivider component#682
Conversation
-added kind prop for the items inside the menu
| display: 'flex', | ||
| }), | ||
|
|
||
| ...itemSeparator({ props, variables: v, theme }), |
There was a problem hiding this comment.
I am not sure that we want to remove separators in Teams theme menu
There was a problem hiding this comment.
I had the same doubt, but wasn't sure how can I show the separator. Will add example with some other menu type that does not have separator by default then... Thanks for the suggestion.
There was a problem hiding this comment.
Addressed the comment, added example for some other variants, take a look in the description of the PR.
-reverted removed item separator from teams theme
| const items = [ | ||
| { key: 'editorials', content: 'Editorials' }, | ||
| { key: 'review', content: 'Reviews' }, | ||
| { key: 'separator', kind: 'MenuSeparator' }, |
There was a problem hiding this comment.
As I remember we decided to use lowercase without prefixes in the kind prop, i.e. separator.
And technically, it's a divider
| : { | ||
| borderLeft: `1px solid ${p.primary ? v.primaryBorderColor : v.borderColor}`, | ||
| }), | ||
| } |
There was a problem hiding this comment.
const borderColor = p.primary ? v.primaryBorderColor : v.borderColor
const borderType = p.vertical ? 'borderTop' : 'borderLeft'
return {
[borderType]: `1px solid ${borderColor}`
}We can change naming, but this looks to me more readable and compact :)
-fixed types of the kind prop -improved styles
-added service for getting the kind prop -removed kind prop from MenuItem and MenuDivider
|
I've added some typings for the kind prop, some custom propTypes, and in the factories the kind prop is removed from the props when creating the component (thanks @layershifter for the suggestions). Please take a look again! |
src/components/Menu/Menu.tsx
Outdated
| import { ReactProps, ShorthandCollection } from '../../../types/utils' | ||
| import MenuDivider from './MenuDivider' | ||
|
|
||
| export type MenuItemKindOptions = 'divider' | 'item' |
There was a problem hiding this comment.
| export type MenuItemKindOptions = 'divider' | 'item' | |
| export type MenuItemKinds = 'divider' | 'item' |
MenuItemKinds may be? Or even MenuShorthandKinds because they are related to shorthand items, not to MenuItem
There was a problem hiding this comment.
MenuShorthandKinds it is :)
| <Menu defaultActiveIndex={0} items={items} vertical pointing="start" /> | ||
| ) | ||
|
|
||
| export default MenuExampleKind |
There was a problem hiding this comment.
| export default MenuExampleKind | |
| export default MenuExampleDivider |
As I understand this example should show us the usage of MenuDivider, SUI uses Content section of docs to show elements usage: https://semantic-ui.com/collections/menu.html#header
-renamed Usage examples to Content examples
# Conflicts: # CHANGELOG.md
This PR adds the kind prop in the items prop in the Menu, for creating different components inside the menu (MenuItem, MenuDivider- component added as part of this PR). The PR is introduced in order to fix #667
For future work, we may leverage this kind property for extracting the MenuItem with submenus as different component, a MenuHeader component etc.
Example:
Vertical pointing menu:
With separator between the last two elements: