Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
innovatixhub authored Nov 26, 2024
1 parent c30fb97 commit 773f764
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/componants/shared/minicomponents/pagehistory/PagesHistory.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import s from "./PagesHistory.module.scss";

const PagesHistory = ({ history, historyPaths }) => {
const previousPages = history.slice(0, history.length - 1);
const currentPage = history[history.length - 1];
const navigateTo = useNavigate();
const { t } = useTranslation();

function navigateToPage(pageIndex) {
const clickedParam = historyPaths?.[pageIndex];

if (clickedParam) {
navigateTo(clickedParam.path);
return;
}

navigateTo(`${history[pageIndex].toLowerCase()}`);
}

return (
<div className={s.pageHistory}>
{previousPages.map((page, i) => {
const pageName = page === "/" ? t("nav.home") : page;

return (
<div className={s.page} key={i}>
<a href="#" onClick={() => navigateToPage(i)}>
{pageName}
</a>
<span>/</span>
</div>
);
})}

<span className={s.currentPage}>{currentPage}</span>
</div>
);
};
export default PagesHistory;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.pageHistory {
display: flex;
align-items: center;
flex-wrap: wrap;
row-gap: 10px;
}

.page {
font-size: .875rem;
color: var(--dark-gray);
}

.page>a {
outline: none;
user-select: none;
color: var(--dark-gray);
transition: color .1s;

&:hover {
color: var(--black);
}

&:focus-visible {
color: var(--orange-degree2);
text-decoration: underline;
}
}

.page>span {
margin: 0 8px;
user-select: none;
}

.currentPage {
font-size: .875rem;
color: var(--black);
}

0 comments on commit 773f764

Please sign in to comment.