Breadcrumbs.jsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import * as React from 'react';
  2. import Breadcrumbs from '@mui/material/Breadcrumbs';
  3. import Link from "react-router-dom/es/Link";
  4. import Stack from '@mui/material/Stack';
  5. import {Typography, useMediaQuery} from "@mui/material";
  6. import background from "../img/breadcrumbs/bg-breadcrumbs.png";
  7. const Breadcrumb = ({links=['this page'], title}) => {
  8. const matches = useMediaQuery('(max-width:899px)');
  9. let arr = links.map(i => {
  10. let link = Array.from(i).map(j => j === ' ' ? '-' : j).join('').toLowerCase()
  11. return <Link
  12. key={i.toString()}
  13. style={{
  14. color: "#fff",
  15. textDecoration: "none",
  16. fontSize: "11px"
  17. }}
  18. to={`/${link}`}> {i.toUpperCase()}
  19. </Link>
  20. })
  21. arr.unshift(<Link style={{
  22. color: "#fff",
  23. textDecoration: "none",
  24. fontSize: "11px"
  25. }} to="/" key={'homeBreadcrumbs'}> HOME </Link>)
  26. return (
  27. <article
  28. style={{
  29. background: `url(${background}) center/contain repeat`,
  30. padding: "40px 0",
  31. height: "210px",
  32. display: "flex",
  33. flexDirection: "column",
  34. justifyContent: "center",
  35. alignItems: "center",
  36. position: "relative"
  37. }}
  38. >
  39. <Typography
  40. fontWeight={300}
  41. color="#fff"
  42. variant={matches ? "h4" : "h3"}
  43. >
  44. {title || links[links.length-1].toUpperCase()}
  45. </Typography>
  46. <Stack
  47. spacing={2}
  48. position="absolute"
  49. bottom="40px"
  50. >
  51. <Breadcrumbs color="#fff" separator="›" aria-label="breadcrumb">
  52. {arr}
  53. </Breadcrumbs>
  54. </Stack>
  55. </article>
  56. );
  57. }
  58. export default Breadcrumb;