From a367f605b842ad0a71a63025da15ac62ed0364a5 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 21 Dec 2021 14:29:19 +0100 Subject: chore: add a breadcrumb component --- src/components/Breadcrumb/Breadcrumb.module.scss | 21 ++++++++++ src/components/Breadcrumb/Breadcrumb.tsx | 53 ++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/components/Breadcrumb/Breadcrumb.module.scss create mode 100644 src/components/Breadcrumb/Breadcrumb.tsx (limited to 'src/components/Breadcrumb') diff --git a/src/components/Breadcrumb/Breadcrumb.module.scss b/src/components/Breadcrumb/Breadcrumb.module.scss new file mode 100644 index 0000000..bfba21f --- /dev/null +++ b/src/components/Breadcrumb/Breadcrumb.module.scss @@ -0,0 +1,21 @@ +@use "@styles/abstracts/placeholders"; + +.list { + @extend %reset-ordered-list; + + display: flex; + flex-flow: row wrap; + align-items: center; + gap: var(--spacing-2xs); + margin: 0 0 var(--spacing-md) 0; + font-size: var(--font-size-sm); +} + +.item { + &:not(:last-of-type) { + &::after { + content: ">"; + margin-left: var(--spacing-2xs); + } + } +} diff --git a/src/components/Breadcrumb/Breadcrumb.tsx b/src/components/Breadcrumb/Breadcrumb.tsx new file mode 100644 index 0000000..e090a4f --- /dev/null +++ b/src/components/Breadcrumb/Breadcrumb.tsx @@ -0,0 +1,53 @@ +import { t } from '@lingui/macro'; +import Link from 'next/link'; +import { useRouter } from 'next/router'; +import styles from './Breadcrumb.module.scss'; + +const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { + const router = useRouter(); + + const isHome = router.pathname === '/'; + const isBlog = router.pathname === '/blog'; + const isArticle = router.pathname.includes('/article/'); + const isThematic = router.pathname.includes('/thematique/'); + const isSubject = router.pathname.includes('/sujet/'); + + const getItems = () => { + return ( + <> +
  • + + {t`Home`} + +
  • + {isBlog &&
  • {t`Blog`}
  • } + {(isArticle || isThematic || isSubject) && ( + <> +
  • + + {t`Blog`} + +
  • +
  • {pageTitle}
  • + + )} + {!isBlog && !isArticle && !isThematic && !isSubject && ( +
  • {pageTitle}
  • + )} + + ); + }; + + return ( + <> + {!isHome && ( + + )} + + ); +}; + +export default Breadcrumb; -- cgit v1.2.3