Breadcrumbs.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. style={{
  13. color: "#fff",
  14. textDecoration: "none",
  15. fontSize: "11px"
  16. }}
  17. to={`/${link}`}> {i.toUpperCase()}
  18. </Link>
  19. });
  20. arr.unshift(<Link style={{
  21. color: "#fff",
  22. textDecoration: "none",
  23. fontSize: "11px"
  24. }} to="/"> HOME </Link>)
  25. return (
  26. <article
  27. style={{
  28. background: `url(${background}) center/contain repeat`,
  29. padding: "40px 0",
  30. height: "210px",
  31. display: "flex",
  32. flexDirection: "column",
  33. justifyContent: "center",
  34. alignItems: "center",
  35. position: "relative"
  36. }}
  37. >
  38. <Typography
  39. fontWeight={300}
  40. color="#fff"
  41. variant={matches ? "h4" : "h3"}
  42. >
  43. {title || links[links.length-1].toUpperCase()}
  44. </Typography>
  45. <Stack
  46. spacing={2}
  47. position="absolute"
  48. bottom="40px"
  49. >
  50. <Breadcrumbs color="#fff" separator="›" aria-label="breadcrumb">
  51. {arr}
  52. </Breadcrumbs>
  53. </Stack>
  54. </article>
  55. );
  56. }
  57. export default Breadcrumb;