-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Breadcrumbs] Add new component #14084
Merged
oliviertassinari
merged 19 commits into
mui:master
from
oliviertassinari:mbrookes-lab-breadcrumbs
Feb 1, 2019
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bdc3a93
WIP Breadcrumbs
mbrookes 07437b7
refactor
oliviertassinari ab61b05
Simplify component prop rendering
mbrookes b18b9fd
Simplify Breadcrumbs, fix prop comment order
mbrookes 4ac2eb5
Update for @eps1lon's review
mbrookes a3ffd1b
Standardise classNames
mbrookes ba79302
prettier
mbrookes 687b84a
yarn docs:api
mbrookes 25ffff5
Move BreadcrumbSeparator component to its own file
mbrookes 6ee0612
Further simplification
mbrookes b7e209b
Mark BreadcrumbCollapsed as internal
mbrookes a9c57a6
Fix Olivier's feeback, fix other issues
mbrookes e294a4d
Stub out the tests, add tests for Breadcrumb
mbrookes f60fa26
Alternative version
oliviertassinari 3d58b03
matt review
oliviertassinari 7cff225
matt & seb reviews
oliviertassinari cc89470
matt & seb reviews
oliviertassinari b1927e3
seb review
oliviertassinari e3d87d5
Alternative n°1
oliviertassinari 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
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,62 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/lab/Breadcrumbs'; | ||
import Breadcrumb from '@material-ui/lab/Breadcrumb'; | ||
import Link from '@material-ui/core/Link'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
justifyContent: 'center', | ||
flexWrap: 'wrap', | ||
}, | ||
paper: { | ||
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`, | ||
}, | ||
}); | ||
|
||
function handleClick(event) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CollapsedBreadcrumbs(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<Paper className={classes.paper}> | ||
<Breadcrumbs maxItems={2} arial-label="Breadcrumb navigation"> | ||
<Breadcrumb> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Home | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Catalog | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
Accessories | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="#" onClick={handleClick}> | ||
New Collection | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb color="textPrimary">Belts</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
CollapsedBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(CollapsedBreadcrumbs); |
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,88 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/lab/Breadcrumbs'; | ||
import Breadcrumb from '@material-ui/lab/Breadcrumb'; | ||
import Link from '@material-ui/core/Link'; | ||
import NavigateNextIcon from '@material-ui/icons/NavigateNext'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
justifyContent: 'center', | ||
flexWrap: 'wrap', | ||
}, | ||
paper: { | ||
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`, | ||
}, | ||
}); | ||
|
||
function handleClick(event) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CustomSeparator(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Paper className={classes.paper}> | ||
<Breadcrumbs separator="›" arial-label="Breadcrumb navigation"> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/lab/about/" onClick={handleClick}> | ||
Lab | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb color="textPrimary">Breadcrumb</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
<br /> | ||
<Paper className={classes.paper}> | ||
<Breadcrumbs separator="-" arial-label="Breadcrumb navigation"> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/lab/about/" onClick={handleClick}> | ||
Lab | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb color="textPrimary">Breadcrumb</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
<br /> | ||
<Paper className={classes.paper}> | ||
<Breadcrumbs | ||
separator={<NavigateNextIcon fontSize="small" />} | ||
arial-label="Breadcrumb navigation" | ||
> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/" onClick={handleClick}> | ||
Material-UI | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/lab/about/" onClick={handleClick}> | ||
Lab | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb color="textPrimary">Breadcrumb</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
</div> | ||
); | ||
} | ||
|
||
CustomSeparator.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(CustomSeparator); |
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,91 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import { emphasize } from '@material-ui/core/styles/colorManipulator'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/lab/Breadcrumbs'; | ||
import Breadcrumb from '@material-ui/lab/Breadcrumb'; | ||
import Chip from '@material-ui/core/Chip'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import HomeIcon from '@material-ui/icons/Home'; | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
padding: theme.spacing.unit, | ||
}, | ||
chip: { | ||
backgroundColor: theme.palette.grey[100], | ||
height: 24, | ||
color: theme.palette.grey[800], | ||
fontWeight: theme.typography.fontWeightRegular, | ||
'&:hover, &:focus': { | ||
backgroundColor: theme.palette.grey[300], | ||
}, | ||
'&:active': { | ||
boxShadow: theme.shadows[1], | ||
backgroundColor: emphasize(theme.palette.grey[300], 0.12), | ||
}, | ||
}, | ||
avatar: { | ||
background: 'none', | ||
marginRight: -theme.spacing.unit * 1.5, | ||
}, | ||
}); | ||
|
||
function handleClick(event) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function CustomBreadcrumb(props) { | ||
const { classes, ...rest } = props; | ||
return <Chip className={classes.chip} {...rest} />; | ||
} | ||
|
||
CustomBreadcrumb.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
const StyledBreadcrumb = withStyles(styles)(CustomBreadcrumb); | ||
|
||
function CustomizedBreadcrumbs(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<Paper className={classes.root}> | ||
<Breadcrumbs arial-label="Breadcrumb navigation"> | ||
<Breadcrumb> | ||
<StyledBreadcrumb | ||
component="a" | ||
href="#" | ||
label="Home" | ||
avatar={ | ||
<Avatar className={classes.avatar}> | ||
<HomeIcon /> | ||
</Avatar> | ||
} | ||
onClick={handleClick} | ||
/> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<StyledBreadcrumb component="a" href="#" label="Catalog" onClick={handleClick} /> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<StyledBreadcrumb | ||
label="Accessories" | ||
deleteIcon={<ExpandMoreIcon />} | ||
onClick={handleClick} | ||
onDelete={handleClick} | ||
/> | ||
</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
CustomizedBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(CustomizedBreadcrumbs); |
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,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Breadcrumbs from '@material-ui/lab/Breadcrumbs'; | ||
import Breadcrumb from '@material-ui/lab/Breadcrumb'; | ||
import Link from '@material-ui/core/Link'; | ||
import HomeIcon from '@material-ui/icons/Home'; | ||
import WhatshotIcon from '@material-ui/icons/Whatshot'; | ||
import GrainIcon from '@material-ui/icons/Grain'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`, | ||
}, | ||
link: { | ||
display: 'flex', | ||
}, | ||
icon: { | ||
marginRight: theme.spacing.unit / 2, | ||
width: 20, | ||
height: 20, | ||
}, | ||
}); | ||
|
||
function handleClick(event) { | ||
event.preventDefault(); | ||
alert('You clicked a breadcrumb.'); // eslint-disable-line no-alert | ||
} | ||
|
||
function IconBreadcrumbs(props) { | ||
const { classes } = props; | ||
return ( | ||
<Paper className={classes.root}> | ||
<Breadcrumbs arial-label="Breadcrumb navigation"> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/" onClick={handleClick} className={classes.link}> | ||
<HomeIcon className={classes.icon} /> | ||
Material-UI | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb> | ||
<Link color="inherit" href="/lab/about/" onClick={handleClick} className={classes.link}> | ||
<WhatshotIcon className={classes.icon} /> | ||
Lab | ||
</Link> | ||
</Breadcrumb> | ||
<Breadcrumb color="textPrimary" className={classes.link}> | ||
<GrainIcon className={classes.icon} /> | ||
Breadcrumb | ||
</Breadcrumb> | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
IconBreadcrumbs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(IconBreadcrumbs); |
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.
Do we need both
onClick
and ‘href
here?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.
Yes, otherwise the page scroll to the top.
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.
Ah, okay. I didn't spot the
event.preventDefault();
(was on mobile without reading glasses! :).This isn't how we've shown
href
in other demos. I think it's confusing, as it isn't how it would typically be used in production.