This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Added breadcrumb for contents (fixes #6)
- Loading branch information
1 parent
038548a
commit db877a8
Showing
15 changed files
with
379 additions
and
250 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,53 @@ | ||
import React from "react"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import PropTypes from "prop-types"; | ||
import Typography from "@material-ui/core/Typography"; | ||
import NavigateNextIcon from "@material-ui/icons/NavigateNextRounded"; | ||
import Breadcrumbs from "@material-ui/core/Breadcrumbs"; | ||
import Paper from "@material-ui/core/Paper"; | ||
import { makeSearchTitle } from "../../helpers/searchHelpers"; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
marginTop: theme.spacing(1), | ||
marginBottom: theme.spacing(1), | ||
padding: theme.spacing(2), | ||
display: "flex", | ||
background: theme.palette.background.default | ||
} | ||
})); | ||
|
||
export default function ContentBreadcrumb(props) { | ||
const classes = useStyles(); | ||
const { pathname } = props; | ||
const pathPartitions = makeSearchTitle(pathname).split(">"); | ||
const isLastPath = (str, index) => | ||
str && index === pathPartitions.length - 1; | ||
return ( | ||
<Paper className={classes.root}> | ||
<Breadcrumbs | ||
separator={<NavigateNextIcon fontSize="small" />} | ||
aria-label="breadcrumb" | ||
> | ||
{pathPartitions.map((p, index) => { | ||
if (isLastPath(p, index)) { | ||
return ( | ||
<Typography variant="button" key={p} color="secondary"> | ||
{p.trim()} | ||
</Typography> | ||
); | ||
} | ||
return ( | ||
<Typography variant="button" key={p}> | ||
{p.trim()} | ||
</Typography> | ||
); | ||
})} | ||
</Breadcrumbs> | ||
</Paper> | ||
); | ||
} | ||
|
||
ContentBreadcrumb.propTypes = { | ||
pathname: PropTypes.string.isRequired | ||
}; |
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,55 @@ | ||
import React from "react"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import Link from "@material-ui/core/Link/index"; | ||
import constants from "../../helpers/constants"; | ||
import CarbonMainIcon from "../SvgIcons/CarbonMainIcon"; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
toolbarContainer: { | ||
display: "flex" | ||
}, | ||
toolbar: { | ||
...theme.mixins.toolbar, | ||
paddingLeft: theme.spacing(5), | ||
display: "flex", | ||
flexGrow: 1, | ||
flexDirection: "column", | ||
alignItems: "flex-start", | ||
justifyContent: "center" | ||
}, | ||
title: { | ||
color: theme.palette.text.primary, | ||
display: "flex", | ||
marginBottom: theme.spacing(0.5), | ||
"&:hover": { | ||
color: theme.palette.primary.main | ||
} | ||
}, | ||
titleIcon: { | ||
margin: 0, | ||
border: 0, | ||
marginTop: theme.spacing(1 / 1.5), | ||
marginRight: theme.spacing(1 / 1.5), | ||
display: "flex", | ||
height: 32, | ||
width: 32 | ||
} | ||
})); | ||
|
||
export default function ToolbarIcon() { | ||
const classes = useStyles(); | ||
return ( | ||
<div className={classes.toolbarContainer}> | ||
<div className={classes.toolbar}> | ||
<Link | ||
className={classes.title} | ||
href={constants.HEADER_ROOT_LINK} | ||
variant="h4" | ||
> | ||
<CarbonMainIcon className={classes.titleIcon} /> | ||
{constants.HEADER_MAIN_TITLE} | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.