Skip to content

Commit 90c848e

Browse files
disabled breadcrumb (#640)
1 parent 5200d56 commit 90c848e

File tree

3 files changed

+70
-39
lines changed

3 files changed

+70
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nordcloud/gnui",
33
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
4-
"version": "8.16.0",
4+
"version": "8.16.1",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/components/breadcrumbs/Breadcrumbs.stories.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ import { Breadcrumbs } from ".";
1616

1717
## BreadcrumbsList properties
1818

19-
| properties | required | type | description |
20-
| ---------: | :------: | :----- | :---------- |
21-
| label | true | string | |
22-
| uri | true | string | |
19+
| properties | required | type | description |
20+
| ---------: | :------: | :------ | :---------- |
21+
| label | true | string | |
22+
| uri | true | string | |
23+
| isDisabled | false | boolean | |
2324

2425
<Canvas>
2526
<Story name="default">
2627
<Breadcrumbs
2728
list={[
2829
{ label: "Home", uri: `#` },
2930
{ label: "Hosts", uri: `#` },
31+
{ label: "Disabled", uri: `#`, isDisabled: true },
32+
{ label: "Hosts 2", uri: `#` },
3033
{ label: "Host Details", uri: `#` },
3134
]}
3235
/>
Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,65 @@
11
import * as React from "react";
2-
import styled from "styled-components";
2+
import styled, { css } from "styled-components";
33
import theme from "../../theme";
44

55
export type BreadcrumbsList = {
66
label: string;
77
uri: string;
8+
isDisabled?: boolean;
89
};
910

1011
export type BreadcrumbsListProps = {
1112
list: BreadcrumbsList[];
12-
Component?: React.FC<{ to: string }>;
13+
Component?: React.FC<{ to: string; isDisabled?: boolean }>;
1314
};
1415

16+
export function Breadcrumbs({ list, Component }: BreadcrumbsListProps) {
17+
return (
18+
<StyledBreadcrumbs>
19+
<ul>
20+
{list.map((breadcrumb) => (
21+
<li key={breadcrumb.label}>
22+
{Component ? (
23+
<Component
24+
isDisabled={breadcrumb.isDisabled}
25+
css={aStyles}
26+
to={breadcrumb.uri}
27+
>
28+
{breadcrumb.label}
29+
</Component>
30+
) : (
31+
<StyledLink
32+
isDisabled={breadcrumb.isDisabled}
33+
href={breadcrumb.uri}
34+
>
35+
{breadcrumb.label}
36+
</StyledLink>
37+
)}
38+
</li>
39+
))}
40+
</ul>
41+
</StyledBreadcrumbs>
42+
);
43+
}
44+
45+
const aStyles = css`
46+
line-height: 1.125rem;
47+
font-size: ${theme.fontSizes.sm};
48+
font-weight: ${theme.fontWeights.regular};
49+
font-family: ${theme.fonts.body};
50+
text-decoration: none;
51+
transition: ${theme.transition};
52+
color: ${theme.color.interactive.link};
53+
&:hover,
54+
&:focus,
55+
&:active {
56+
opacity: ${theme.opacity};
57+
}
58+
&:hover {
59+
text-decoration: underline;
60+
}
61+
`;
62+
1563
const StyledBreadcrumbs = styled.nav`
1664
ul {
1765
padding: 0;
@@ -24,21 +72,7 @@ const StyledBreadcrumbs = styled.nav`
2472
text-transform: ${theme.typography.titleCase};
2573
2674
a {
27-
line-height: 1.125rem;
28-
font-size: ${theme.fontSizes.sm};
29-
font-weight: ${theme.fontWeights.regular};
30-
font-family: ${theme.fonts.body};
31-
color: ${theme.color.interactive.link};
32-
text-decoration: none;
33-
transition: ${theme.transition};
34-
&:hover,
35-
&:focus,
36-
&:active {
37-
opacity: ${theme.opacity};
38-
}
39-
&:hover {
40-
text-decoration: underline;
41-
}
75+
${aStyles}
4276
}
4377
4478
&:after {
@@ -62,20 +96,14 @@ const StyledBreadcrumbs = styled.nav`
6296
}
6397
`;
6498

65-
export function Breadcrumbs({ list, Component }: BreadcrumbsListProps) {
66-
return (
67-
<StyledBreadcrumbs>
68-
<ul>
69-
{list.map((br) => (
70-
<li key={br.label}>
71-
{Component ? (
72-
<Component to={br.uri || ""}>{br.label}</Component>
73-
) : (
74-
<a href={br.uri || ""}>{br.label}</a>
75-
)}
76-
</li>
77-
))}
78-
</ul>
79-
</StyledBreadcrumbs>
80-
);
81-
}
99+
const disabledLinkStyles = css`
100+
pointer-events: none;
101+
color: ${theme.color.text.text02};
102+
`;
103+
104+
const StyledLink = styled.a<{ isDisabled?: boolean }>`
105+
&& {
106+
${aStyles}
107+
${(props) => (props.isDisabled ? disabledLinkStyles : {})}
108+
}
109+
`;

0 commit comments

Comments
 (0)