-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into feature/OP-185/documentation
- Loading branch information
Showing
22 changed files
with
930 additions
and
96 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.breadcrumbsContainer { | ||
margin-block-start: 96px; | ||
padding-block-start: 14px; | ||
padding-block-end: 14px; | ||
} | ||
|
||
.breadcrumbs { | ||
background-color: var(--utrecht-breadcrumb-nav-background-color); | ||
border-radius: var(--utrecht-breadcrumb-nav-border-radius); | ||
} | ||
|
||
.breadcrumbNavLink:hover { | ||
--utrecht-link-hover-color: var( | ||
--utrecht-breadcrumb-link-hover-color | ||
) !important; | ||
} | ||
|
||
.breadcrumbDisabled { | ||
color: var(--utrecht-link-placeholder-color, #eff4f6) !important; | ||
} | ||
|
||
.breadcrumbDisabled:hover { | ||
color: var(--utrecht-link-placeholder-color, #eff4f6) !important; | ||
user-select: none !important; | ||
} | ||
|
||
.breadcrumbs > ol { | ||
align-items: baseline; | ||
} | ||
|
||
@media only screen and (min-width: 992px) { | ||
.breadcrumbsContainer { | ||
margin-block-start: 14px; | ||
padding-block-start: 14px; | ||
padding-block-end: 14px; | ||
} | ||
} |
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,86 @@ | ||
import * as React from "react"; | ||
import * as styles from "./Breadcrumbs.module.css"; | ||
import _ from "lodash"; | ||
import { Container } from "@conduction/components"; | ||
import { BreadcrumbNav, BreadcrumbNavLink, BreadcrumbNavSeparator, Icon } from "@utrecht/component-library-react"; | ||
import { useGatsbyContext } from "../../context/gatsby"; | ||
import { navigate } from "gatsby"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faChevronRight } from "@fortawesome/free-solid-svg-icons"; | ||
import { useTranslation } from "react-i18next"; | ||
import { isHomepage } from "../../services/isHomepage"; | ||
|
||
export const Breadcrumbs: React.FC = () => { | ||
const { t } = useTranslation(); | ||
|
||
const { gatsbyContext } = useGatsbyContext(); | ||
|
||
const pageSlugLabel = () => { | ||
const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 3 : 2; | ||
|
||
const stringLabel = location.pathname.split("/")[splitNumber]; | ||
return stringLabel?.replaceAll("_", " "); | ||
}; | ||
|
||
const detailPageSlugLabel = () => { | ||
const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 4 : 3; | ||
|
||
const stringLabel = location.pathname.split("/")[splitNumber]; | ||
return stringLabel?.replaceAll("_", " "); | ||
}; | ||
|
||
const translatedCrumbs = gatsbyContext.pageContext.breadcrumb.crumbs.map((crumb: any) => { | ||
if (crumb.pathname === "/pages/[pageSlug]") { | ||
return { ...crumb, crumbLabel: t(pageSlugLabel()), pathname: `/pages/${t(pageSlugLabel())}` }; | ||
} | ||
if (crumb.pathname === "/pages/[pageSlug]/[detailPageSlug]") { | ||
return { | ||
...crumb, | ||
crumbLabel: t(detailPageSlugLabel()), | ||
pathname: `/pages/${t(pageSlugLabel())}/${t(detailPageSlugLabel())}`, | ||
}; | ||
} else return { ...crumb, crumbLabel: t(_.upperFirst(crumb.crumbLabel)) }; | ||
}); | ||
|
||
const handleBreadcrumbClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, pathname: string) => { | ||
e.preventDefault(); | ||
|
||
navigate(pathname); | ||
}; | ||
|
||
if (!isHomepage(gatsbyContext.location.pathname)) | ||
return ( | ||
<Container layoutClassName={styles.breadcrumbsContainer}> | ||
<BreadcrumbNav className={styles.breadcrumbs} label={t("Breadcrumbs")}> | ||
{translatedCrumbs.map((crumb: any, idx: number) => { | ||
if (gatsbyContext.pageContext.breadcrumb.crumbs.length !== idx + 1) { | ||
return ( | ||
<React.Fragment key={idx}> | ||
<BreadcrumbNavLink | ||
className={styles.breadcrumbNavLink} | ||
onClick={(e: any) => handleBreadcrumbClick(e, crumb.pathname)} | ||
href="" | ||
> | ||
{crumb.crumbLabel} | ||
</BreadcrumbNavLink> | ||
|
||
<BreadcrumbNavSeparator> | ||
<Icon> | ||
<FontAwesomeIcon icon={faChevronRight} /> | ||
</Icon> | ||
</BreadcrumbNavSeparator> | ||
</React.Fragment> | ||
); | ||
} | ||
return ( | ||
<BreadcrumbNavLink key={idx} className={styles.breadcrumbDisabled} current disabled href=""> | ||
{crumb.crumbLabel} | ||
</BreadcrumbNavLink> | ||
); | ||
})} | ||
</BreadcrumbNav> | ||
</Container> | ||
); | ||
|
||
return <></>; | ||
}; |
Oops, something went wrong.