-
Notifications
You must be signed in to change notification settings - Fork 77
fix: CORUI-6264: One component per file Menu #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2da826e
Rename file
cjskillingstad 645d8d0
Rename temp
cjskillingstad 7132953
Merge temp branch
cjskillingstad 1c4b546
Restore original
cjskillingstad b1e1c19
Rename file
cjskillingstad 837ddc6
Rename temp
cjskillingstad b3f8a5e
Merge temp branch
cjskillingstad 624f5e9
Restore original
cjskillingstad 5cf9a27
Rename file
cjskillingstad 114c1fe
Rename temp
cjskillingstad 7a830e0
Merge temp branch
cjskillingstad f5d1880
Restore original
cjskillingstad ca213e8
Separate components
cjskillingstad 8127fcc
Move Menu subcomponents
cjskillingstad f7957e9
Update snapshot with correct on click function
cjskillingstad b7ed6cd
Merge branch 'master' into fix/one_comp_menu
cjskillingstad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import classnames from 'classnames'; | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
|
|
||
| const MenuGroup = ({ title, children, className, titleProps, ...props }) => { | ||
| const menuGroupClasses = classnames( | ||
| 'fd-menu__group', | ||
| className | ||
| ); | ||
|
|
||
| return ( | ||
| <div {...props} className={menuGroupClasses}> | ||
| <h1 {...titleProps} className='fd-menu__title'>{title}</h1> | ||
| {children} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| MenuGroup.displayName = 'MenuGroup'; | ||
|
|
||
| MenuGroup.propTypes = { | ||
| title: PropTypes.string.isRequired, | ||
| className: PropTypes.string, | ||
| titleProps: PropTypes.object | ||
| }; | ||
|
|
||
| export default MenuGroup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import classnames from 'classnames'; | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
|
|
||
| const MenuItem = ({ url, isLink, separator, addon, children, onclick, className, addonProps, urlProps, ...props }) => { | ||
| const menuItemLinkClasses = classnames( | ||
| 'fd-menu__item', | ||
| { | ||
| 'fd-menu__link': isLink | ||
| } | ||
| ); | ||
|
|
||
| const renderLink = () => { | ||
| if (url) { | ||
| return ( | ||
| <a {...urlProps} | ||
| className={menuItemLinkClasses} | ||
| href={url} | ||
| onClick={onclick}> | ||
| {children} | ||
| </a> | ||
| ); | ||
| } else if (children && React.isValidElement(children)) { | ||
| const childrenClassnames = classnames( | ||
| menuItemLinkClasses, | ||
| children.props.className | ||
| ); | ||
|
|
||
| return React.cloneElement(children, { | ||
| 'className': childrenClassnames, | ||
| ...urlProps | ||
| }); | ||
| } else if (children) { | ||
| return (<a {...urlProps} | ||
| className='fd-menu__item' | ||
| onClick={onclick}>{children}</a>); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| <li {...props} className={className}> | ||
| {addon && | ||
| <div {...addonProps} className='fd-menu__addon-before'>{<span className={'sap-icon--' + addon} />}</div> | ||
| } | ||
| {renderLink()} | ||
| </li> | ||
| {separator && <hr />} | ||
| </React.Fragment> | ||
| ); | ||
| }; | ||
|
|
||
| MenuItem.displayName = 'MenuItem'; | ||
|
|
||
| MenuItem.propTypes = { | ||
| addon: PropTypes.string, | ||
| addonProps: PropTypes.object, | ||
| className: PropTypes.string, | ||
| isLink: PropTypes.bool, | ||
| separator: PropTypes.bool, | ||
| url: PropTypes.string, | ||
| urlProps: PropTypes.object | ||
| }; | ||
|
|
||
| MenuItem.propDescriptions = { | ||
| addon: 'Name of the SAP icon to be applied as an add-on before.', | ||
| addonProps: 'Additional props to be spread to the add-on section.', | ||
| children: 'component - can be used to pass React Router <Link> or any other component which emits an <a>.', | ||
| isLink: 'Set to **true** to style as a link.', | ||
| separator: 'Set to **true** to add a horizontal line (separator).', | ||
| url: 'Enables use of `<a>` element. Value to be applied to the anchor\'s `href` attribute. Should use either `link` or `url`, but not both.', | ||
| urlProps: 'Additional props to be spread to the Menu Item links (when using `url`).' | ||
| }; | ||
|
|
||
| export default MenuItem; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import classnames from 'classnames'; | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
|
|
||
| const MenuList = ({ children, className, ...props }) => { | ||
| const menuListClasses = classnames( | ||
| 'fd-menu__list', | ||
| className | ||
| ); | ||
|
|
||
| return <ul {...props} className={menuListClasses}>{children}</ul>; | ||
| }; | ||
|
|
||
| MenuList.displayName = 'MenuList'; | ||
|
|
||
| MenuList.propTypes = { | ||
| children: PropTypes.node, | ||
| className: PropTypes.string | ||
| }; | ||
|
|
||
| export default MenuList; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would have expected to see all these as static references on
Menuand then onlyMenuwould be exported. Something like: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 agree, should've caught that. Moved to subcomponents in 8127fcc