From 90c848edfcc46f668768c4db5252520884625c82 Mon Sep 17 00:00:00 2001 From: ignasveleckisnc <88425985+ignasveleckisnc@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:46:46 +0300 Subject: [PATCH] disabled breadcrumb (#640) --- package.json | 2 +- .../breadcrumbs/Breadcrumbs.stories.mdx | 11 ++- src/components/breadcrumbs/Breadcrumbs.tsx | 96 ++++++++++++------- 3 files changed, 70 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 2e11b815..30252a79 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@nordcloud/gnui", "description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products", - "version": "8.16.0", + "version": "8.16.1", "license": "MIT", "repository": { "type": "git", diff --git a/src/components/breadcrumbs/Breadcrumbs.stories.mdx b/src/components/breadcrumbs/Breadcrumbs.stories.mdx index 270a6d1e..43d2a53b 100644 --- a/src/components/breadcrumbs/Breadcrumbs.stories.mdx +++ b/src/components/breadcrumbs/Breadcrumbs.stories.mdx @@ -16,10 +16,11 @@ import { Breadcrumbs } from "."; ## BreadcrumbsList properties -| properties | required | type | description | -| ---------: | :------: | :----- | :---------- | -| label | true | string | | -| uri | true | string | | +| properties | required | type | description | +| ---------: | :------: | :------ | :---------- | +| label | true | string | | +| uri | true | string | | +| isDisabled | false | boolean | | @@ -27,6 +28,8 @@ import { Breadcrumbs } from "."; list={[ { label: "Home", uri: `#` }, { label: "Hosts", uri: `#` }, + { label: "Disabled", uri: `#`, isDisabled: true }, + { label: "Hosts 2", uri: `#` }, { label: "Host Details", uri: `#` }, ]} /> diff --git a/src/components/breadcrumbs/Breadcrumbs.tsx b/src/components/breadcrumbs/Breadcrumbs.tsx index 948cdddb..8920ded3 100644 --- a/src/components/breadcrumbs/Breadcrumbs.tsx +++ b/src/components/breadcrumbs/Breadcrumbs.tsx @@ -1,17 +1,65 @@ import * as React from "react"; -import styled from "styled-components"; +import styled, { css } from "styled-components"; import theme from "../../theme"; export type BreadcrumbsList = { label: string; uri: string; + isDisabled?: boolean; }; export type BreadcrumbsListProps = { list: BreadcrumbsList[]; - Component?: React.FC<{ to: string }>; + Component?: React.FC<{ to: string; isDisabled?: boolean }>; }; +export function Breadcrumbs({ list, Component }: BreadcrumbsListProps) { + return ( + +
    + {list.map((breadcrumb) => ( +
  • + {Component ? ( + + {breadcrumb.label} + + ) : ( + + {breadcrumb.label} + + )} +
  • + ))} +
+
+ ); +} + +const aStyles = css` + line-height: 1.125rem; + font-size: ${theme.fontSizes.sm}; + font-weight: ${theme.fontWeights.regular}; + font-family: ${theme.fonts.body}; + text-decoration: none; + transition: ${theme.transition}; + color: ${theme.color.interactive.link}; + &:hover, + &:focus, + &:active { + opacity: ${theme.opacity}; + } + &:hover { + text-decoration: underline; + } +`; + const StyledBreadcrumbs = styled.nav` ul { padding: 0; @@ -24,21 +72,7 @@ const StyledBreadcrumbs = styled.nav` text-transform: ${theme.typography.titleCase}; a { - line-height: 1.125rem; - font-size: ${theme.fontSizes.sm}; - font-weight: ${theme.fontWeights.regular}; - font-family: ${theme.fonts.body}; - color: ${theme.color.interactive.link}; - text-decoration: none; - transition: ${theme.transition}; - &:hover, - &:focus, - &:active { - opacity: ${theme.opacity}; - } - &:hover { - text-decoration: underline; - } + ${aStyles} } &:after { @@ -62,20 +96,14 @@ const StyledBreadcrumbs = styled.nav` } `; -export function Breadcrumbs({ list, Component }: BreadcrumbsListProps) { - return ( - -
    - {list.map((br) => ( -
  • - {Component ? ( - {br.label} - ) : ( - {br.label} - )} -
  • - ))} -
-
- ); -} +const disabledLinkStyles = css` + pointer-events: none; + color: ${theme.color.text.text02}; +`; + +const StyledLink = styled.a<{ isDisabled?: boolean }>` + && { + ${aStyles} + ${(props) => (props.isDisabled ? disabledLinkStyles : {})} + } +`;