-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: Add breadcrumbs component (#3145)
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
|
||
import { Link } from "../link"; | ||
import styled from "../styled"; | ||
import { Typography } from "../typography"; | ||
|
||
import type { BreadcrumbEntry } from "./types"; | ||
|
||
const StyledTypography = styled(Typography)({ | ||
fontWeight: 500, | ||
}); | ||
|
||
const Breadcrumb = ({ label, url }: BreadcrumbEntry) => { | ||
return url ? ( | ||
<Link href={url} target="_self" whiteSpace="nowrap"> | ||
<StyledTypography variant="caption2" color="inherit"> | ||
{label} | ||
</StyledTypography> | ||
</Link> | ||
) : ( | ||
<StyledTypography variant="caption2">{label}</StyledTypography> | ||
); | ||
}; | ||
|
||
export default Breadcrumb; |
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,31 @@ | ||
import React from "react"; | ||
import { Breadcrumbs as MuiBreadcrumbs, Theme } from "@mui/material"; | ||
import { alpha } from "@mui/system"; | ||
|
||
import styled from "../styled"; | ||
|
||
import Breadcrumb from "./breadcrumb"; | ||
import type { BreadcrumbEntry } from "./types"; | ||
|
||
interface BreadcrumbsProps { | ||
entries: BreadcrumbEntry[]; | ||
} | ||
|
||
const StyledBreadcrumbs = styled(MuiBreadcrumbs)(({ theme }: { theme: Theme }) => ({ | ||
margin: theme.spacing(theme.clutch.spacing.sm, theme.clutch.spacing.none), | ||
"& .MuiBreadcrumbs-separator": { | ||
color: alpha(theme.colors.neutral[900], 0.6), | ||
}, | ||
})); | ||
|
||
const Breadcrumbs = ({ entries }: BreadcrumbsProps) => ( | ||
<StyledBreadcrumbs> | ||
{entries.map((entry: BreadcrumbEntry) => ( | ||
<Breadcrumb key={entry.label} {...entry} /> | ||
))} | ||
</StyledBreadcrumbs> | ||
); | ||
|
||
export * from "./types"; | ||
|
||
export default Breadcrumbs; |
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,4 @@ | ||
export interface BreadcrumbEntry { | ||
label: string; | ||
url?: string; | ||
} |
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