Skip to content

Commit

Permalink
add icon to breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Jan 30, 2024
1 parent 78a6267 commit c5d55d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Blog/BreadcrumbsNav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Breadcrumbs, Typography } from '@mui/material'
import Link from 'next/link'
import css from './styles.module.css'
import { type UrlObject } from 'url'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'
import { type ReactNode } from 'react'

const TYPOGRAPHY_VARIANT = 'caption'
const TYPOGRAPHY_COLOR = 'text.primary'
Expand All @@ -11,7 +13,7 @@ type BreadcrumbsType = {
title: string
}

const createBreadcrumb = (key: string, text: string, linkProps: string | UrlObject) => (
const createBreadcrumb = (key: string, text: ReactNode, linkProps: string | UrlObject) => (
<Link key={key} href={linkProps}>
<Typography variant={TYPOGRAPHY_VARIANT} color={TYPOGRAPHY_COLOR}>
{text}
Expand All @@ -22,7 +24,14 @@ const createBreadcrumb = (key: string, text: string, linkProps: string | UrlObje
const BreadcrumbsNav = ({ category, title }: BreadcrumbsType) => {
const breadcrumbs = [
createBreadcrumb('1', 'Blog', { pathname: '/blog' }),
createBreadcrumb('2', `#${category}`, { pathname: '/blog', query: { category } }),
createBreadcrumb(
'2',
<div className={css.category}>
<CategoryIcon />
{category}
</div>,
{ pathname: '/blog', query: { category } },
),
<Typography key="3" variant={TYPOGRAPHY_VARIANT} color={TYPOGRAPHY_COLOR}>
{title}
</Typography>,
Expand Down
6 changes: 6 additions & 0 deletions src/components/Blog/BreadcrumbsNav/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
.breadcrumbs :global .MuiTypography-root {
line-height: inherit;
}

.category {
display: flex;
gap: 4px;
align-items: center;
}

0 comments on commit c5d55d5

Please sign in to comment.