-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add simple list typescript demo (#14485)
Testing #11731
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { createStyles, Theme, withStyles, WithStyles } from '@material-ui/core/styles'; | ||
import List from '@material-ui/core/List'; | ||
import ListItem, { ListItemProps } from '@material-ui/core/ListItem'; | ||
import ListItemIcon from '@material-ui/core/ListItemIcon'; | ||
import ListItemText from '@material-ui/core/ListItemText'; | ||
import Divider from '@material-ui/core/Divider'; | ||
import InboxIcon from '@material-ui/icons/Inbox'; | ||
import DraftsIcon from '@material-ui/icons/Drafts'; | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
width: '100%', | ||
maxWidth: 360, | ||
backgroundColor: theme.palette.background.paper, | ||
}, | ||
}); | ||
|
||
function ListItemLink(props: ListItemProps<'a', { button?: true }>) { | ||
return <ListItem button component="a" {...props} />; | ||
} | ||
|
||
export interface SimpleListProps extends WithStyles<typeof styles> {} | ||
|
||
function SimpleList(props: SimpleListProps) { | ||
const { classes } = props; | ||
return ( | ||
<div className={classes.root}> | ||
<List component="nav"> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<InboxIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Inbox" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<DraftsIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Drafts" /> | ||
</ListItem> | ||
</List> | ||
<Divider /> | ||
<List component="nav"> | ||
<ListItem button> | ||
<ListItemText primary="Trash" /> | ||
</ListItem> | ||
<ListItemLink href="#simple-list"> | ||
<ListItemText primary="Spam" /> | ||
</ListItemLink> | ||
</List> | ||
</div> | ||
); | ||
} | ||
|
||
SimpleList.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
} as any; | ||
|
||
export default withStyles(styles)(SimpleList); |
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