forked from airbytehq/airbyte
-
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.
🪟🔧 Reactor Breadcrumbs component to use anchors (airbytehq#18764)
* refactor breadcrumbs to use actual links * PR comments on styles
- Loading branch information
Showing
5 changed files
with
53 additions
and
54 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
airbyte-webapp/src/components/ui/Breadcrumbs/Breadcrumbs.module.scss
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,18 @@ | ||
@use "scss/colors"; | ||
|
||
.container { | ||
font-weight: normal; | ||
cursor: default; | ||
} | ||
|
||
.item { | ||
display: inline-block; | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
.unlinked { | ||
font-weight: bold; | ||
} |
54 changes: 20 additions & 34 deletions
54
airbyte-webapp/src/components/ui/Breadcrumbs/Breadcrumbs.tsx
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 |
---|---|---|
@@ -1,49 +1,35 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
const BreadcrumbsContainer = styled.div` | ||
font-weight: normal; | ||
cursor: default; | ||
`; | ||
import { Link } from "components"; | ||
|
||
const LastBreadcrumbsItem = styled.span` | ||
font-weight: bold; | ||
`; | ||
|
||
const BreadcrumbsItem = styled.div` | ||
display: inline-block; | ||
cursor: pointer; | ||
color: ${({ theme }) => theme.primaryColor}; | ||
&:hover { | ||
opacity: 0.8; | ||
} | ||
`; | ||
import styles from "./Breadcrumbs.module.scss"; | ||
|
||
export interface BreadcrumbsDataItem { | ||
name: string | React.ReactNode; | ||
onClick?: () => void; | ||
label: string; | ||
to?: string; | ||
} | ||
|
||
interface BreadcrumbsProps { | ||
data: BreadcrumbsDataItem[]; | ||
} | ||
|
||
export const Breadcrumbs: React.FC<BreadcrumbsProps> = ({ data }) => { | ||
const lastIndex = data.length - 1; | ||
|
||
return ( | ||
<BreadcrumbsContainer> | ||
{data.map((item, key) => | ||
key === lastIndex ? ( | ||
<LastBreadcrumbsItem key={`breadcrumbs-item-${key}`}>{item.name}</LastBreadcrumbsItem> | ||
) : ( | ||
<span key={`breadcrumbs-item-${key}`}> | ||
<BreadcrumbsItem onClick={item.onClick}>{item.name}</BreadcrumbsItem> | ||
<span> / </span> | ||
</span> | ||
) | ||
)} | ||
</BreadcrumbsContainer> | ||
<div className={styles.container}> | ||
{data.map((item, index) => ( | ||
<span key={index}> | ||
{item.to ? ( | ||
<Link to={item.to} $clear className={styles.item}> | ||
{item.label} | ||
</Link> | ||
) : ( | ||
<span className={styles.unlinked} key={index}> | ||
{item.label} | ||
</span> | ||
)} | ||
{index !== data.length - 1 && <span> / </span>} | ||
</span> | ||
))} | ||
</div> | ||
); | ||
}; |
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