-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[List] Making list meet Material Guidelines #6316
Closed
Closed
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4be924d
Single line list item adjustments to meet Mterial Guidelines
kybarg ed0e996
Fixed lint
kybarg 40b90a0
More fancy demo jagged edges
kybarg e8277e2
Simplified demo styles
kybarg a852b81
Responsive demo
kybarg 2eed341
Better single-line list demo
kybarg 510f6f2
Fixed sibgle-line list dense text size
kybarg 8a3da54
Moved "dense" param to context
kybarg 21f4cd6
Use CSS inheritance instead instead of class name
kybarg 7328c84
Using `some` to detec child type
kybarg 26428d4
Fixed avatar detection
kybarg 06846b5
Dense property fix
kybarg 2af14ec
Demo fixes
kybarg aee5667
Merge branch 'callemall/next' into next-list-guidelines
kybarg 6b137ae
Merge branch 'callemall/next' into next-list-guidelines
kybarg 33d1f41
Merge branch 'callemall/next' into next-list-guidelines
kybarg c7c3f1d
Fixes
kybarg 824709c
Svg background in example
kybarg 87e4f6d
Revert "Svg background in example"
kybarg ba004b1
Two-lines list example
kybarg 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,222 @@ | ||
// @flow weak | ||
|
||
import React, { Component } from 'react'; | ||
import { createStyleSheet } from 'jss-theme-reactor'; | ||
import customPropTypes from 'material-ui/utils/customPropTypes'; | ||
import { | ||
List, | ||
ListItem, | ||
ListItemAvatar, | ||
ListItemIcon, | ||
ListItemSecondaryAction, | ||
ListItemText, | ||
} from 'material-ui/List'; | ||
import Avatar from 'material-ui/Avatar'; | ||
import FolderIcon from 'material-ui/svg-icons/folder'; | ||
import IconButton from 'material-ui/IconButton'; | ||
import { LabelCheckbox } from 'material-ui/Checkbox'; | ||
import Layout from 'material-ui/Layout'; | ||
import Text from 'material-ui/Text'; | ||
import TriangleImageLight from 'docs/site/assets/images/bg-triangle-light.svg'; | ||
import TriangleImageDark from 'docs/site/assets/images/bg-triangle-dark.svg'; | ||
|
||
const styleSheet = createStyleSheet('SingleLineList', (theme) => ({ | ||
root: { | ||
flexGrow: 1, | ||
maxWidth: 752, | ||
}, | ||
container: { | ||
width: '100%', | ||
}, | ||
demoContainer: { | ||
margin: '0 auto', | ||
maxWidth: 360, | ||
}, | ||
demo: { | ||
background: theme.palette.background.paper, | ||
border: `solid ${theme.palette.text.divider}`, | ||
borderWidth: '1px 1px 0', | ||
marginBottom: 16, | ||
maxHeight: 160, | ||
overflow: 'hidden', | ||
position: 'relative', | ||
width: '100%', | ||
zIndex: 1, | ||
'&:before': { | ||
backgroundImage: `url(${theme.palette.type === 'light' ? | ||
TriangleImageLight : TriangleImageDark})`, | ||
backgroundSize: '18px 10px', | ||
backgroundPosition: '-1px 0', | ||
bottom: 0, | ||
content: '""', | ||
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. Good, doing the other way around crash on IE11 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. @oliviertassinari So |
||
display: 'block', | ||
height: 10, | ||
position: 'absolute', | ||
width: '100%', | ||
zIndex: theme.zIndex.tooltip, | ||
}, | ||
}, | ||
title: { | ||
margin: `${theme.spacing.unit * 4}px 0 ${theme.spacing.unit * 2}px`, | ||
}, | ||
})); | ||
|
||
class SingleLineList extends Component { | ||
static contextTypes = { | ||
styleManager: customPropTypes.muiRequired, | ||
}; | ||
|
||
state = { | ||
dense: false, | ||
}; | ||
|
||
render() { | ||
const classes = this.context.styleManager.render(styleSheet); | ||
const { dense } = this.state; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<LabelCheckbox | ||
checked={dense} | ||
onChange={(event, checked) => this.setState({ dense: checked })} | ||
label="Enable dense preview" | ||
value="dense" | ||
/> | ||
<Layout container className={classes.container}> | ||
<Layout item xs={12} md={6}> | ||
<div className={classes.demoContainer}> | ||
<Text type="title" className={classes.title}>Text only</Text> | ||
<div className={classes.demo}> | ||
<List dense={dense}> | ||
<ListItem button> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
</List> | ||
</div> | ||
<Text type="body1" secondary>Single-line list</Text> | ||
</div> | ||
</Layout> | ||
<Layout item xs={12} md={6}> | ||
<div className={classes.demoContainer}> | ||
<Text type="title" className={classes.title}>Icon with text</Text> | ||
<div className={classes.demo}> | ||
<List dense={dense}> | ||
<ListItem button> | ||
<ListItemIcon><FolderIcon /></ListItemIcon> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon><FolderIcon /></ListItemIcon> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon><FolderIcon /></ListItemIcon> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemIcon><FolderIcon /></ListItemIcon> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
</List> | ||
</div> | ||
<Text type="body1" secondary>Single-line list with icon</Text> | ||
</div> | ||
</Layout> | ||
</Layout> | ||
<Layout container className={classes.container}> | ||
<Layout item xs={12} md={6}> | ||
<div className={classes.demoContainer}> | ||
<Text type="title" className={classes.title}>Avatar with text</Text> | ||
<div className={classes.demo} style={{ maxHeight: 184 }}> | ||
<List dense={dense}> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
</ListItem> | ||
</List> | ||
</div> | ||
<Text type="body1" secondary>Single-line item with avatar</Text> | ||
</div> | ||
</Layout> | ||
<Layout item xs={12} md={6}> | ||
<div className={classes.demoContainer}> | ||
<Text type="title" className={classes.title}>Avatar with text and icon</Text> | ||
<div className={classes.demo} style={{ maxHeight: 184 }}> | ||
<List dense={dense}> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
<ListItemSecondaryAction> | ||
<IconButton>comment</IconButton> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
<ListItemSecondaryAction> | ||
<IconButton>comment</IconButton> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
<ListItemSecondaryAction> | ||
<IconButton>comment</IconButton> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
<ListItem button> | ||
<ListItemAvatar> | ||
<Avatar><FolderIcon /></Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary="Single-line item" /> | ||
<ListItemSecondaryAction> | ||
<IconButton>comment</IconButton> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
</List> | ||
</div> | ||
<Text type="body1" secondary>Single-line item with avatar and icon</Text> | ||
</div> | ||
</Layout> | ||
</Layout> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default SingleLineList; |
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.
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.
Oh noooo, the demo is no longer working in isolation. It's going to be a pain for user starting from the demos.
@mbrookes What do you suggest?
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.
@oliviertassinari Either the
<svg>
could be defined inline rather than being imported, or the file be treated as animg
, so will fail gracefully if the example code is copied without thesvg
file.@kybarg Could the CSS
fill
&stroke
attributes perhaps be used so as to not need two separatesvg
s?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.
You see me coming but simplicity might be just as good: removing that fancy effect.
I hope we will find a better solution.
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.
Nooooo!! 🤣 🤣 🤣