-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Popover][Menu][MenuItem] Port components
- Loading branch information
1 parent
faa79b9
commit 9a9ea7e
Showing
43 changed files
with
1,999 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[ignore] | ||
|
||
.*/node_modules/fbjs/* | ||
./scripts/* | ||
./test/e2e/* | ||
|
||
[libs] | ||
flow/interfaces | ||
|
This file contains 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 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,23 @@ | ||
Menu | ||
==== | ||
|
||
|
||
|
||
Props | ||
----- | ||
|
||
|
||
| Name | Type | Default | Description | | ||
|:-----|:-----|:-----|:-----| | ||
| anchorEl | object | | This is the DOM element that will be used to set the position of the menu. | | ||
| children | node | | Menu contents, should be menu items | | ||
| className | string | | The CSS class name of the list element. | | ||
| onEnter | function | | Callback fired before the Menu is entering | | ||
| onEntering | function | | Callback fired when the Menu is entering | | ||
| onEntered | function | | Callback fired when the Menu has entered | | ||
| onExit | function | | Callback fired before the Menu is exiting | | ||
| onExiting | function | | Callback fired when the Menu is exiting | | ||
| onExited | function | | Callback fired when the Menu has exited | | ||
| onRequestClose | function | | Callback function fired when the menu is requested to be closed.<br><br>**Signature:**<br>`function(event: event) => void`<br>*event:* The event that triggered the close request | | ||
| open | bool | | If true, the menu is visible. | | ||
| transitionDuration | union | 'auto' | The length of the transition in `ms`, or 'auto' | |
This file contains 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,14 @@ | ||
MenuItem | ||
======== | ||
|
||
|
||
|
||
Props | ||
----- | ||
|
||
|
||
| Name | Type | Default | Description | | ||
|:-----|:-----|:-----|:-----| | ||
| children | node | | Menu item contents | | ||
| className | string | | The CSS class name of the root element. | | ||
| selected | bool | | Use to apply selected styling | |
This file contains 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 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 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 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,84 @@ | ||
// @flow weak | ||
|
||
import React, { Component, PropTypes } from 'react'; | ||
import { createStyleSheet } from 'stylishly'; | ||
import { List, ListItem, ListItemText } from 'material-ui/List'; | ||
import { Menu, MenuItem } from 'material-ui/Menu'; | ||
|
||
const styleSheet = createStyleSheet('SimpleListMenu', (theme) => { | ||
return { | ||
root: { | ||
width: '100%', | ||
maxWidth: '360px', | ||
background: theme.palette.background.paper, | ||
}, | ||
}; | ||
}); | ||
|
||
const options = [ | ||
'Show all notification content', | ||
'Hide sensitive notification content', | ||
'Hide all notification content', | ||
]; | ||
|
||
export default class SimpleListMenu extends Component { | ||
static contextTypes = { | ||
styleManager: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
anchorEl: undefined, | ||
open: false, | ||
selectedIndex: 1, | ||
}; | ||
|
||
button = undefined; | ||
|
||
handleClickListItem = (event) => this.setState({ open: true, anchorEl: event.currentTarget }); | ||
|
||
handleMenuItemClick = (event, index) => this.setState({ selectedIndex: index, open: false }); | ||
|
||
handleRequestClose = () => this.setState({ open: false }); | ||
|
||
render() { | ||
const classes = this.context.styleManager.render(styleSheet); | ||
return ( | ||
<div className={classes.root}> | ||
<List> | ||
<ListItem | ||
button | ||
aria-haspopup="true" | ||
aria-controls="lock-menu" | ||
aria-label="When device is locked" | ||
onClick={this.handleClickListItem} | ||
> | ||
<ListItemText | ||
primary="When device is locked" | ||
secondary={options[this.state.selectedIndex]} | ||
/> | ||
</ListItem> | ||
</List> | ||
<Menu | ||
id="lock-menu" | ||
anchorEl={this.state.anchorEl} | ||
className={classes.menu} | ||
open={this.state.open} | ||
onRequestClose={this.handleRequestClose} | ||
> | ||
{options.map((n, index) => { | ||
return ( | ||
<MenuItem | ||
key={index} | ||
selected={index === this.state.selectedIndex} | ||
onClick={(event) => this.handleMenuItemClick(event, index)} | ||
> | ||
{n} | ||
</MenuItem> | ||
); | ||
})} | ||
</Menu> | ||
</div> | ||
); | ||
} | ||
} | ||
|
This file contains 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,59 @@ | ||
// @flow weak | ||
|
||
import React, { Component, PropTypes } from 'react'; | ||
import { createStyleSheet } from 'stylishly'; | ||
import Button from 'material-ui/Button'; | ||
import { Menu, MenuItem } from 'material-ui/Menu'; | ||
|
||
const styleSheet = createStyleSheet('SimpleMenu', () => { | ||
return { | ||
menu: {}, | ||
content: { | ||
margin: 0, | ||
}, | ||
}; | ||
}); | ||
|
||
export default class SimpleMenu extends Component { | ||
static contextTypes = { | ||
styleManager: PropTypes.object.isRequired, | ||
}; | ||
|
||
state = { | ||
anchorEl: undefined, | ||
open: false, | ||
}; | ||
|
||
button = undefined; | ||
|
||
handleClick = (event) => this.setState({ open: true, anchorEl: event.currentTarget }); | ||
|
||
handleRequestClose = () => this.setState({ open: false }); | ||
|
||
render() { | ||
const classes = this.context.styleManager.render(styleSheet); | ||
return ( | ||
<div> | ||
<Button | ||
aria-owns="simple-menu" | ||
aria-haspopup="true" | ||
onClick={this.handleClick} | ||
> | ||
Open Menu | ||
</Button> | ||
<Menu | ||
id="simple-menu" | ||
anchorEl={this.state.anchorEl} | ||
className={classes.menu} | ||
open={this.state.open} | ||
onRequestClose={this.handleRequestClose} | ||
> | ||
<MenuItem onClick={this.handleRequestClose}>Profile</MenuItem> | ||
<MenuItem onClick={this.handleRequestClose}>My account</MenuItem> | ||
<MenuItem onClick={this.handleRequestClose}>Logout</MenuItem> | ||
</Menu> | ||
</div> | ||
); | ||
} | ||
} | ||
|
This file contains 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,29 @@ | ||
# Menus | ||
|
||
Menus display a list of choices on a transient sheet of material. | ||
|
||
Menus appear upon interaction with a button, action, or other control. They display a list of choices, with one choice per line. | ||
|
||
Menu items may be disabled if not applicable to a certain context. Contextual menus dynamically change their available menu items based on the current state of the app. | ||
|
||
Menus should not be used as a primary method for navigation within an app. | ||
|
||
## Simple menus | ||
|
||
Simple menus open over the anchor element by default (this option can be changed via props). When close to a screen edge, simple menus vertically realign to make all menu items are completely visible. | ||
|
||
Choosing an option should immediately ideally commit the option and close the menu. | ||
|
||
**Disambiguation**: In contrast to simple menus, simple dialogs can present additional detail related to the options available for a list item or provide navigational or orthogonal actions related to the primary task. Although they can display the same content, simple menus are preferred over simple dialogs because simple menus are less disruptive to the user’s current context. | ||
|
||
{{demo='menus/SimpleMenu.js'}} | ||
|
||
If used for item selection, when opened, simple menus attempt to vertically align the currently selected menu item with the anchor element. The currently selected menu item is set using the `selected` prop. | ||
|
||
{{demo='menus/SimpleListMenu.js'}} | ||
|
||
If text in a simple menu wraps to a second line, use a simple dialog instead. Simple dialogs can have rows with varying heights. | ||
|
||
## TextField select menus | ||
|
||
Coming soon... |
This file contains 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 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 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
Oops, something went wrong.