@purpurds/breadcrumbs 5.31.0 → 5.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +1 -1
- package/dist/breadcrumbs.cjs.js +3 -3
- package/dist/breadcrumbs.cjs.js.map +1 -1
- package/dist/breadcrumbs.d.ts +3 -2
- package/dist/breadcrumbs.d.ts.map +1 -1
- package/dist/breadcrumbs.es.js +78 -68
- package/dist/breadcrumbs.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/breadcrumbs.module.scss +2 -2
- package/src/breadcrumbs.stories.tsx +3 -8
- package/src/breadcrumbs.test.tsx +4 -4
- package/src/breadcrumbs.tsx +9 -2
- package/src/types.ts +5 -0
package/dist/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._purpur-
|
|
1
|
+
._purpur-breadcrumbs_1xh80_1{font-family:var(--purpur-typography-family-default)}._purpur-breadcrumbs_1xh80_1 a,._purpur-breadcrumbs_1xh80_1 li:only-child:not(:has(a)){display:inline-flex;gap:var(--purpur-spacing-50);font-size:var(--purpur-typography-scale-75);text-underline-offset:3px;text-decoration-skip-ink:none;padding:14px 2px;letter-spacing:.3px}._purpur-breadcrumbs_1xh80_1 a:hover,._purpur-breadcrumbs_1xh80_1 a:active,._purpur-breadcrumbs_1xh80_1 li:only-child:not(:has(a)):hover,._purpur-breadcrumbs_1xh80_1 li:only-child:not(:has(a)):active{text-decoration-thickness:2px;text-underline-offset:2px}._purpur-breadcrumbs--default_1xh80_20,._purpur-breadcrumbs--default_1xh80_20 a{color:var(--purpur-color-text-interactive-primary)}._purpur-breadcrumbs--default_1xh80_20 a:hover{color:var(--purpur-color-text-interactive-primary-hover);background:var(--purpur-color-background-interactive-transparent-hover)}._purpur-breadcrumbs--default_1xh80_20 a:active{color:var(--purpur-color-text-interactive-primary-active);background:var(--purpur-color-background-interactive-transparent-active)}._purpur-breadcrumbs--negative_1xh80_34,._purpur-breadcrumbs--negative_1xh80_34 a{color:var(--purpur-color-text-interactive-primary-negative)}._purpur-breadcrumbs--negative_1xh80_34 a:hover{color:var(--purpur-color-text-interactive-primary-negative-hover);background:var(--purpur-color-background-interactive-transparent-negative-hover)}._purpur-breadcrumbs--negative_1xh80_34 a:active{color:var(--purpur-color-text-interactive-primary-negative-active);background:var(--purpur-color-background-interactive-transparent-negative-active)}._purpur-breadcrumbs__list_1xh80_48{display:flex;flex-direction:row;align-items:center;gap:var(--purpur-spacing-50);margin:0;padding:0;list-style:none}._purpur-breadcrumbs__home_1xh80_57{display:none}@media screen and (min-width: 600px){._purpur-breadcrumbs__home_1xh80_57{display:inline-flex;align-items:center}}._purpur-breadcrumb-item_1xh80_67{white-space:nowrap;display:flex;align-items:center}._purpur-breadcrumb-item--current_1xh80_72{overflow:hidden}._purpur-breadcrumb-item--current_1xh80_72 a{display:block;text-overflow:ellipsis;overflow:hidden;color:var(--purpur-color-text-default);text-decoration:none;font-weight:var(--purpur-typography-weight-medium)}._purpur-breadcrumb-item--current_1xh80_72 a:hover{background:none}._purpur-breadcrumb-item_1xh80_67:not(:nth-last-child(2)):not(:last-child){display:none}@media screen and (min-width: 600px){._purpur-breadcrumb-item_1xh80_67:not(:nth-last-child(2)):not(:last-child){display:flex}}._purpur-breadcrumb-item--negative_1xh80_94._purpur-breadcrumb-item--current_1xh80_72 a{color:var(--purpur-color-text-default-negative)}._purpur-breadcrumb-item_1xh80_67:not(:last-child):after{font-size:var(--purpur-typography-scale-75);margin-left:var(--purpur-spacing-50);content:"/"/""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,CAAC;CACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/breadcrumbs",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.33.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/breadcrumbs.cjs.js",
|
|
6
6
|
"types": "./dist/breadcrumbs.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"source": "src/breadcrumbs.tsx",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"classnames": "~2.5.0",
|
|
18
|
-
"@purpurds/tokens": "5.
|
|
19
|
-
"@purpurds/icon": "5.
|
|
18
|
+
"@purpurds/tokens": "5.33.0",
|
|
19
|
+
"@purpurds/icon": "5.33.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
.purpur-breadcrumbs {
|
|
4
4
|
font-family: var(--purpur-typography-family-default);
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
|
|
8
8
|
a,
|
|
9
9
|
li:only-child:not(:has(a)) {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
flex-direction: row;
|
|
64
64
|
align-items: center;
|
|
65
65
|
gap: var(--purpur-spacing-50);
|
|
66
|
-
|
|
66
|
+
margin: 0;
|
|
67
67
|
padding: 0;
|
|
68
68
|
|
|
69
69
|
list-style: none;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, useEffect, useState } from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
3
|
|
|
4
4
|
import "@purpurds/icon/styles";
|
|
5
|
-
import { Breadcrumbs, BreadcrumbsItem,
|
|
5
|
+
import { Breadcrumbs, BreadcrumbsItem, BreadcrumbsProps } from "./breadcrumbs";
|
|
6
6
|
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Components/Breadcrumbs",
|
|
@@ -57,11 +57,6 @@ type LinkProps = {
|
|
|
57
57
|
children: ReactNode;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
type RendererProps = {
|
|
61
|
-
children: ReactElement<BreadcrumbsItemProps>;
|
|
62
|
-
negative: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
60
|
const MetaData = () => {
|
|
66
61
|
const [code, setCode] = useState("");
|
|
67
62
|
|
|
@@ -108,7 +103,7 @@ const Link = ({ href, children }: LinkProps) => <a href={href}>{children}</a>;
|
|
|
108
103
|
|
|
109
104
|
const Renderer =
|
|
110
105
|
(showMeta = false) =>
|
|
111
|
-
({ children, negative, ...args }:
|
|
106
|
+
({ children, negative, ...args }: BreadcrumbsProps) =>
|
|
112
107
|
(
|
|
113
108
|
<>
|
|
114
109
|
<div
|
package/src/breadcrumbs.test.tsx
CHANGED
|
@@ -11,7 +11,7 @@ afterEach(cleanup);
|
|
|
11
11
|
describe("Breadcrumbs", () => {
|
|
12
12
|
it("renders a breadcrumb item", () => {
|
|
13
13
|
render(
|
|
14
|
-
<Breadcrumbs
|
|
14
|
+
<Breadcrumbs>
|
|
15
15
|
<Breadcrumbs.Item href="/link" data-testid="item">
|
|
16
16
|
Products
|
|
17
17
|
</Breadcrumbs.Item>
|
|
@@ -22,7 +22,7 @@ describe("Breadcrumbs", () => {
|
|
|
22
22
|
|
|
23
23
|
it("renders custom link", () => {
|
|
24
24
|
render(
|
|
25
|
-
<Breadcrumbs
|
|
25
|
+
<Breadcrumbs>
|
|
26
26
|
<Breadcrumbs.Item href="/link">Products</Breadcrumbs.Item>
|
|
27
27
|
<Breadcrumbs.Item data-testid="custom">
|
|
28
28
|
<a href="/">Custom link</a>
|
|
@@ -34,7 +34,7 @@ describe("Breadcrumbs", () => {
|
|
|
34
34
|
|
|
35
35
|
it("marks the last breadcrumb item as aria-current=page", () => {
|
|
36
36
|
render(
|
|
37
|
-
<Breadcrumbs
|
|
37
|
+
<Breadcrumbs>
|
|
38
38
|
<Breadcrumbs.Item href="/link">Products</Breadcrumbs.Item>
|
|
39
39
|
<Breadcrumbs.Item href="/link/sub" data-testid="last">
|
|
40
40
|
Sub
|
|
@@ -55,5 +55,5 @@ describe("Breadcrumbs", () => {
|
|
|
55
55
|
);
|
|
56
56
|
const parsedMeta = JSON.parse(screen.getByTestId("breadcrumbs-meta").innerHTML);
|
|
57
57
|
expect(parsedMeta["itemListElement"].length).toEqual(2);
|
|
58
|
-
})
|
|
58
|
+
});
|
|
59
59
|
});
|
package/src/breadcrumbs.tsx
CHANGED
|
@@ -4,8 +4,9 @@ import c from "classnames";
|
|
|
4
4
|
|
|
5
5
|
import styles from "./breadcrumbs.module.scss";
|
|
6
6
|
import { MetaListItem, metaListItem, metaSchema } from "./meta";
|
|
7
|
+
import { DataAttributes } from "./types.ts";
|
|
7
8
|
|
|
8
|
-
export type BreadcrumbsProps = {
|
|
9
|
+
export type BreadcrumbsProps = DataAttributes & {
|
|
9
10
|
["data-testid"]?: string;
|
|
10
11
|
ariaLabel?: string;
|
|
11
12
|
children: ReactElement<BreadcrumbsItemProps> | Array<ReactElement<BreadcrumbsItemProps>>;
|
|
@@ -53,6 +54,7 @@ const Breadcrumbs = ({
|
|
|
53
54
|
negative = false,
|
|
54
55
|
highlightLast = true,
|
|
55
56
|
hideHomeIcon,
|
|
57
|
+
...props
|
|
56
58
|
}: BreadcrumbsProps) => {
|
|
57
59
|
const classes = c([
|
|
58
60
|
className,
|
|
@@ -110,7 +112,12 @@ const Breadcrumbs = ({
|
|
|
110
112
|
const schema = metaListItems.length === maxIndex ? metaSchema(metaListItems) : null;
|
|
111
113
|
|
|
112
114
|
return (
|
|
113
|
-
<nav
|
|
115
|
+
<nav
|
|
116
|
+
data-testid={dataTestId}
|
|
117
|
+
aria-label={ariaLabel || "Breadcrumb"}
|
|
118
|
+
className={classes}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
114
121
|
<ol className={styles[`${rootClassName}__list`]}>{items}</ol>
|
|
115
122
|
{meta && schema ? (
|
|
116
123
|
<script
|