This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Add possibility to render submenu in MenuItem #126
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d7d9916
Add possibility to render submenus for menu
bdfaa0b
Made minor improvements
e1bae9b
Made minor improvements
0181016
Update index.tsx
sophieH29 167c06a
Merge master into branch
aafac50
Merge branch 'master' into feat/menu-with-submenu
sophieH29 1701079
Minor improbements
1c6ec90
Merge branch 'master' into feat/menu-with-submenu
sophieH29 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
38 changes: 38 additions & 0 deletions
38
docs/src/examples/components/Menu/Types/MenuExampleWithSubmenu.shorthand.tsx
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,38 @@ | ||
import React from 'react' | ||
import { Menu } from '@stardust-ui/react' | ||
|
||
const menuWidthVariable = { | ||
menuItemWidth: 100, | ||
} | ||
|
||
const fileSubmenu = { | ||
items: [ | ||
{ key: 'new', content: 'New' }, | ||
{ key: 'open', content: 'Open' }, | ||
{ key: 'edit', content: 'Edit' }, | ||
], | ||
} | ||
const editSubmenu = { | ||
items: [ | ||
{ key: 'undo', content: 'Undo' }, | ||
{ key: 'redo', content: 'Redo' }, | ||
{ key: 'cut', content: 'Cut' }, | ||
{ key: 'copy', content: 'Copy' }, | ||
], | ||
} | ||
const formatSubmenu = { | ||
items: [{ key: 'font', content: 'Font' }, { key: 'text', content: 'Text' }], | ||
} | ||
|
||
const items = [ | ||
{ key: 'file', content: <span>File ▾</span>, submenu: fileSubmenu }, | ||
{ key: 'edit', content: <span>Edit ▾</span>, submenu: editSubmenu }, | ||
{ key: 'format', content: <span>Format ▾</span>, submenu: formatSubmenu }, | ||
{ key: 'help', content: 'Help' }, | ||
] | ||
|
||
const MenuExampleWithSubmenu = () => ( | ||
<Menu defaultActiveIndex={0} items={items} variables={menuWidthVariable} /> | ||
) | ||
|
||
export default MenuExampleWithSubmenu |
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 |
---|---|---|
|
@@ -116,6 +116,7 @@ const menuItemStyles = { | |
: { marginLeft: iconsMenuItemSpacing }), | ||
}, | ||
}), | ||
...(!vertical && variables.menuItemWidth && { width: pxToRem(variables.menuItemWidth) }), | ||
...(pills && { | ||
...(vertical ? { margin: `0 0 ${pxToRem(5)} 0` } : { margin: `0 ${pxToRem(8)} 0 0` }), | ||
borderRadius: pxToRem(5), | ||
|
@@ -238,6 +239,11 @@ const menuItemStyles = { | |
}), | ||
} | ||
}, | ||
submenu: { | ||
position: 'absolute', | ||
borderTopLeftRadius: 0, | ||
borderTopRightRadius: 0, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally support @notandrew comment, the type should affect the submenu as well. |
||
} | ||
|
||
export default menuItemStyles |
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.
Please try to add some height on the element as the content is not visible (try to wrap the Menu in some wrapper with some bigger height).

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.
Also, I would expect to be able to expand only one submenu at a time. I don't think the scenario above (having three different dropdowns should work (try closing the submenu if there is click outside of it).