|
| 1 | +import React from "react"; |
| 2 | +import { useRecoilState } from "recoil"; |
| 3 | +import { useHistory } from "react-router-dom"; |
| 4 | +import RightIcon from "@material-ui/icons/ChevronRight"; |
| 5 | +import { breadCrumbItems } from "app/state/recoil/atoms"; |
| 6 | + |
| 7 | +export default function BreadCrumbs() { |
| 8 | + const [breadCrumbList, setBreadCrumbList] = useRecoilState(breadCrumbItems); |
| 9 | + const history = useHistory(); |
| 10 | + return ( |
| 11 | + <div |
| 12 | + css={` |
| 13 | + display: flex; |
| 14 | + gap: 12px; |
| 15 | + align-items: center; |
| 16 | + justify-content: flex-start; |
| 17 | + padding-top: 12px; |
| 18 | + padding-bottom: 12px; |
| 19 | + font-family: "GothamNarrow-Book", "Helvetica Neue", sans-serif; |
| 20 | + overflow-x: scroll; |
| 21 | + &::-webkit-scrollbar { |
| 22 | + width: 0.1em; |
| 23 | + } |
| 24 | + &::-webkit-scrollbar-track { |
| 25 | + box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.3); |
| 26 | + } |
| 27 | + &::-webkit-scrollbar-thumb { |
| 28 | + background-color: white; |
| 29 | + border-radius: 0px; |
| 30 | + border: 1px solid white; |
| 31 | + } |
| 32 | + width: 100vw; |
| 33 | + /* padding-left: 16px; |
| 34 | + padding-right: 16px; */ |
| 35 | + @media (min-width: 1280px) { |
| 36 | + max-width: 1280px; |
| 37 | + } |
| 38 | + @media (min-width: 600px) { |
| 39 | + padding-left: 24px; |
| 40 | + padding-right: 24px; |
| 41 | + } |
| 42 | + `} |
| 43 | + > |
| 44 | + {breadCrumbList.map((item, index) => ( |
| 45 | + <div |
| 46 | + css={` |
| 47 | + display: flex; |
| 48 | + gap: 12px; |
| 49 | + align-items: center; |
| 50 | + `} |
| 51 | + > |
| 52 | + <button |
| 53 | + css={` |
| 54 | + background: ${index === breadCrumbList.length - 1 |
| 55 | + ? "#495057" |
| 56 | + : "#868e96"}; |
| 57 | + height: 32px; |
| 58 | + border-radius: 20px; |
| 59 | + font-size: 14px; |
| 60 | + font-weight: 700; |
| 61 | + color: #fff; |
| 62 | + text-align: center; |
| 63 | + border: none; |
| 64 | + outline: none; |
| 65 | + width: max-content; |
| 66 | + padding: 0 2rem; |
| 67 | + cursor: pointer; |
| 68 | + :hover, |
| 69 | + :active, |
| 70 | + :focus { |
| 71 | + background: #495057; |
| 72 | + } |
| 73 | + `} |
| 74 | + type="button" |
| 75 | + onClick={() => { |
| 76 | + history.push(item.path); |
| 77 | + setBreadCrumbList([...breadCrumbList.slice(0, index + 1)]); |
| 78 | + }} |
| 79 | + > |
| 80 | + <b>{item.name}</b> |
| 81 | + </button> |
| 82 | + {index === breadCrumbList.length - 1 ? null : ( |
| 83 | + <div |
| 84 | + css={` |
| 85 | + color: #495057; |
| 86 | + display: flex; |
| 87 | + align-items: center; |
| 88 | + `} |
| 89 | + > |
| 90 | + <RightIcon color="inherit" /> |
| 91 | + </div> |
| 92 | + )} |
| 93 | + </div> |
| 94 | + ))} |
| 95 | + </div> |
| 96 | + ); |
| 97 | +} |
0 commit comments