forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add a NestedList example (mui#7995)
* Adding NestedList example * disabling flow for NestedList
- Loading branch information
1 parent
fad1a78
commit b7604e9
Showing
4 changed files
with
86 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import ListSubheader from 'material-ui/List/ListSubheader'; | ||
import List, { ListItem, ListItemIcon, ListItemText } from 'material-ui/List'; | ||
import Collapse from 'material-ui/transitions/Collapse'; | ||
import InboxIcon from 'material-ui-icons/MoveToInbox'; | ||
import DraftsIcon from 'material-ui-icons/Drafts'; | ||
import SendIcon from 'material-ui-icons/Send'; | ||
import ExpandLess from 'material-ui-icons/ExpandLess'; | ||
import ExpandMore from 'material-ui-icons/ExpandMore'; | ||
import StarBorder from 'material-ui-icons/StarBorder'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
width: '100%', | ||
maxWidth: 360, | ||
background: theme.palette.background.paper, | ||
}, | ||
nested: { | ||
paddingLeft: theme.spacing.unit * 4, | ||
}, | ||
}); | ||
|
||
class NestedList extends React.Component { | ||
state = { open: true }; | ||
|
||
handleClick = () => { | ||
this.setState({ open: !this.state.open }); | ||
}; | ||
|
||
render() { | ||
const classes = this.props.classes; | ||
return ( | ||
<List className={classes.root} subheader={<ListSubheader>Nested List Items</ListSubheader>}> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<SendIcon /> | ||
</ListItemIcon> | ||
<ListItemText inset primary="Sent mail" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<DraftsIcon /> | ||
</ListItemIcon> | ||
<ListItemText inset primary="Drafts" /> | ||
</ListItem> | ||
<ListItem button onClick={this.handleClick}> | ||
<ListItemIcon> | ||
<InboxIcon /> | ||
</ListItemIcon> | ||
<ListItemText inset primary="Inbox" /> | ||
{this.state.open ? <ExpandMore /> : <ExpandLess />} | ||
</ListItem> | ||
<Collapse in={this.state.open} transitionDuration="auto" unmountOnExit> | ||
<ListItem button className={classes.nested}> | ||
<ListItemIcon> | ||
<StarBorder /> | ||
</ListItemIcon> | ||
<ListItemText inset primary="Starred" /> | ||
</ListItem> | ||
</Collapse> | ||
</List> | ||
); | ||
} | ||
} | ||
|
||
NestedList.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(NestedList); |
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