From 84264047155dae095d3ba0b38468a7a43f3a0cf0 Mon Sep 17 00:00:00 2001 From: LakeVostok Date: Wed, 24 Jan 2024 21:51:28 +0300 Subject: [PATCH] chore(Link)!: the "href" property is required --- package.json | 8 +-- src/components/Breadcrumbs/Breadcrumbs.scss | 9 +++- src/components/Breadcrumbs/Breadcrumbs.tsx | 15 ++++-- .../Breadcrumbs/BreadcrumbsButton.tsx | 13 +++++ .../Breadcrumbs/BreadcrumbsItem.tsx | 33 ++++++++---- .../Breadcrumbs/BreadcrumbsMore.tsx | 11 ++-- src/components/Link/Link.tsx | 48 +++++------------ src/components/Link/README.md | 53 +++++++++---------- .../Link/__stories__/Link.new.stories.tsx | 4 +- .../Link/__stories__/Link.stories.tsx | 3 +- .../Link/__stories__/LinkShowcase.tsx | 15 ++---- src/components/Link/__tests__/Link.test.tsx | 9 ---- .../Popover/__stories__/Popover.stories.tsx | 4 -- .../Popover/__tests__/Popover.test.tsx | 13 +---- .../Popover/components/Links/Links.tsx | 2 +- 15 files changed, 107 insertions(+), 133 deletions(-) create mode 100644 src/components/Breadcrumbs/BreadcrumbsButton.tsx diff --git a/package.json b/package.json index b774007bec..3bc8070938 100644 --- a/package.json +++ b/package.json @@ -76,10 +76,10 @@ "build-storybook": "sb build -c .storybook -o storybook-static", "lint:js": "eslint --ext .js,.jsx,.ts,.tsx .", "lint:js:fix": "npm run lint:js -- --fix", - "lint:styles": "stylelint '{styles,src}/**/*.scss'", - "lint:styles:fix": "npm run lint:styles -- --fix", - "lint:prettier": "prettier --check '**/*.md'", - "lint:prettier:fix": "prettier --write '**/*.md'", + "lint:styles": "cross-env stylelint '{styles,src}/**/*.scss'", + "lint:styles:fix": "cross-env npm run lint:styles -- --fix", + "lint:prettier": "cross-env prettier --check '**/*.md'", + "lint:prettier:fix": "cross-env prettier --write '**/*.md'", "lint": "run-p lint:*", "typecheck": "tsc --noEmit", "prepublishOnly": "npm run build", diff --git a/src/components/Breadcrumbs/Breadcrumbs.scss b/src/components/Breadcrumbs/Breadcrumbs.scss index b4eeff13fe..0be639096f 100644 --- a/src/components/Breadcrumbs/Breadcrumbs.scss +++ b/src/components/Breadcrumbs/Breadcrumbs.scss @@ -1,4 +1,5 @@ @use '../variables'; +@use '../../../styles/mixins'; $block: '.#{variables.$ns}breadcrumbs'; @@ -11,7 +12,13 @@ $block: '.#{variables.$ns}breadcrumbs'; overflow: hidden; } - &__item { + &__switcher { + @include mixins.button-reset(); + color: var(--g-color-text-secondary); + } + + &__item, + &__switcher { flex-shrink: 1; padding: 4px 8px; display: inline-block; diff --git a/src/components/Breadcrumbs/Breadcrumbs.tsx b/src/components/Breadcrumbs/Breadcrumbs.tsx index 4ba7a894aa..4aeb2f3133 100644 --- a/src/components/Breadcrumbs/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs/Breadcrumbs.tsx @@ -12,13 +12,22 @@ import {BreadcrumbsSeparator} from './BreadcrumbsSeparator'; import './Breadcrumbs.scss'; -export interface BreadcrumbsItem { +type BaseBreadcrumbsItem = { text: string; action: (event: React.MouseEvent | KeyboardEvent) => void; - href?: string; items?: BreadcrumbsItem[]; title?: string; -} +}; + +type LinkBreadcrumbsItem = { + href: string; +} & BaseBreadcrumbsItem; + +type ButtonBreadcrumbsItem = { + href?: undefined; +} & BaseBreadcrumbsItem; + +export type BreadcrumbsItem = LinkBreadcrumbsItem | ButtonBreadcrumbsItem; export interface BreadcrumbsProps extends QAProps { items: T[]; diff --git a/src/components/Breadcrumbs/BreadcrumbsButton.tsx b/src/components/Breadcrumbs/BreadcrumbsButton.tsx new file mode 100644 index 0000000000..62ed662f8d --- /dev/null +++ b/src/components/Breadcrumbs/BreadcrumbsButton.tsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import {block} from '../utils/cn'; + +const b = block('breadcrumbs'); + +export function BreadcrumbsButton(props: { + title: string; + onClick: React.MouseEventHandler; + children: React.ReactNode; +}) { + return