@justeattakeaway/pie-breadcrumb 0.1.1 → 0.3.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/custom-elements.json +174 -11
- package/dist/index.d.ts +89 -3
- package/dist/index.js +176 -28
- package/dist/react.d.ts +89 -3
- package/dist/react.js +7 -7
- package/package.json +2 -2
- package/src/breadcrumb.scss +38 -11
- package/src/defs.ts +25 -5
- package/src/index.ts +175 -9
package/custom-elements.json
CHANGED
|
@@ -14,35 +14,35 @@
|
|
|
14
14
|
"declarations": [
|
|
15
15
|
{
|
|
16
16
|
"kind": "variable",
|
|
17
|
-
"name": "
|
|
17
|
+
"name": "variants",
|
|
18
18
|
"type": {
|
|
19
|
-
"text": "
|
|
19
|
+
"text": "['default', 'scrim']"
|
|
20
20
|
},
|
|
21
|
-
"default": "'
|
|
21
|
+
"default": "['default', 'scrim']"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"kind": "variable",
|
|
25
|
-
"name": "
|
|
25
|
+
"name": "defaultProps",
|
|
26
26
|
"type": {
|
|
27
|
-
"text": "
|
|
27
|
+
"text": "Pick<BreadcrumbProps, 'variant' | 'isCompact'>"
|
|
28
28
|
},
|
|
29
|
-
"default": "'
|
|
29
|
+
"default": "{\n variant: 'default',\n isCompact: false,\n}"
|
|
30
30
|
}
|
|
31
31
|
],
|
|
32
32
|
"exports": [
|
|
33
33
|
{
|
|
34
34
|
"kind": "js",
|
|
35
|
-
"name": "
|
|
35
|
+
"name": "variants",
|
|
36
36
|
"declaration": {
|
|
37
|
-
"name": "
|
|
37
|
+
"name": "variants",
|
|
38
38
|
"module": "src/defs.js"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"kind": "js",
|
|
43
|
-
"name": "
|
|
43
|
+
"name": "defaultProps",
|
|
44
44
|
"declaration": {
|
|
45
|
-
"name": "
|
|
45
|
+
"name": "defaultProps",
|
|
46
46
|
"module": "src/defs.js"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -56,7 +56,170 @@
|
|
|
56
56
|
"kind": "class",
|
|
57
57
|
"description": "",
|
|
58
58
|
"name": "PieBreadcrumb",
|
|
59
|
-
"members": [
|
|
59
|
+
"members": [
|
|
60
|
+
{
|
|
61
|
+
"kind": "field",
|
|
62
|
+
"name": "items",
|
|
63
|
+
"type": {
|
|
64
|
+
"text": "BreadcrumbProps['items']"
|
|
65
|
+
},
|
|
66
|
+
"privacy": "public",
|
|
67
|
+
"default": "[]",
|
|
68
|
+
"attribute": "items"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"kind": "field",
|
|
72
|
+
"name": "variant",
|
|
73
|
+
"privacy": "public",
|
|
74
|
+
"attribute": "variant"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"kind": "field",
|
|
78
|
+
"name": "isCompact",
|
|
79
|
+
"privacy": "public",
|
|
80
|
+
"attribute": "isCompact"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"kind": "method",
|
|
84
|
+
"name": "renderSeparator",
|
|
85
|
+
"privacy": "private",
|
|
86
|
+
"description": "Renders a separator icon between breadcrumb items.\nThe icon direction depends on the RTL (Right-to-Left) setting.",
|
|
87
|
+
"return": {
|
|
88
|
+
"type": {
|
|
89
|
+
"text": "TemplateResult"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"kind": "method",
|
|
95
|
+
"name": "renderNavigationLink",
|
|
96
|
+
"privacy": "private",
|
|
97
|
+
"parameters": [
|
|
98
|
+
{
|
|
99
|
+
"name": "item",
|
|
100
|
+
"type": {
|
|
101
|
+
"text": "BreadcrumbItem"
|
|
102
|
+
},
|
|
103
|
+
"description": "The breadcrumb item containing label and URL."
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"description": "Renders a navigation link for a breadcrumb item."
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "method",
|
|
110
|
+
"name": "renderLastItem",
|
|
111
|
+
"privacy": "private",
|
|
112
|
+
"parameters": [
|
|
113
|
+
{
|
|
114
|
+
"name": "item",
|
|
115
|
+
"type": {
|
|
116
|
+
"text": "BreadcrumbItem"
|
|
117
|
+
},
|
|
118
|
+
"description": "The breadcrumb item containing label and URL."
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"description": "Renders the last breadcrumb item.\nIt has 250px of max-width. If the label reaches this width the text truncates."
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"kind": "method",
|
|
125
|
+
"name": "renderItem",
|
|
126
|
+
"privacy": "private",
|
|
127
|
+
"parameters": [
|
|
128
|
+
{
|
|
129
|
+
"name": "item",
|
|
130
|
+
"type": {
|
|
131
|
+
"text": "BreadcrumbItem"
|
|
132
|
+
},
|
|
133
|
+
"description": "The breadcrumb item to render."
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "isLastItem",
|
|
137
|
+
"default": "false",
|
|
138
|
+
"description": "Indicates if the item is the last in the breadcrumb trail.",
|
|
139
|
+
"optional": true,
|
|
140
|
+
"type": {
|
|
141
|
+
"text": "boolean"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"description": "Renders an individual breadcrumb item.\n\nConditionally renders either a clickable link or plain text for the last item."
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"kind": "method",
|
|
149
|
+
"name": "renderDefaultBreadcrumb",
|
|
150
|
+
"privacy": "private",
|
|
151
|
+
"parameters": [
|
|
152
|
+
{
|
|
153
|
+
"name": "items",
|
|
154
|
+
"type": {
|
|
155
|
+
"text": "BreadcrumbProps['items']"
|
|
156
|
+
},
|
|
157
|
+
"description": "Breadcrumb items to render."
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"description": "Renders breadcrumb items using the default variant style."
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"kind": "method",
|
|
164
|
+
"name": "renderCompactBreadcrumbSeparator",
|
|
165
|
+
"privacy": "private",
|
|
166
|
+
"description": "Renders a separator icon specifically for the back variant.\nThe icon direction depends on the RTL (Right-to-Left) setting."
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"kind": "method",
|
|
170
|
+
"name": "renderCompactBreadcrumb",
|
|
171
|
+
"privacy": "private",
|
|
172
|
+
"parameters": [
|
|
173
|
+
{
|
|
174
|
+
"name": "items",
|
|
175
|
+
"type": {
|
|
176
|
+
"text": "BreadcrumbProps['items']"
|
|
177
|
+
},
|
|
178
|
+
"description": "Breadcrumb items to render."
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"description": "Renders breadcrumb items using the back variant style, displaying only the last item with a preceding separator."
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"kind": "method",
|
|
185
|
+
"name": "renderBreadcrumbItems",
|
|
186
|
+
"privacy": "private",
|
|
187
|
+
"parameters": [
|
|
188
|
+
{
|
|
189
|
+
"name": "items",
|
|
190
|
+
"type": {
|
|
191
|
+
"text": "BreadcrumbProps['items']"
|
|
192
|
+
},
|
|
193
|
+
"description": "Array of breadcrumb items to render."
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"name": "isCompact",
|
|
197
|
+
"type": {
|
|
198
|
+
"text": "BreadcrumbProps['isCompact']"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"description": "Renders a complete breadcrumb list.\nIterates over breadcrumb items to generate the breadcrumb trail."
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"attributes": [
|
|
206
|
+
{
|
|
207
|
+
"name": "items",
|
|
208
|
+
"type": {
|
|
209
|
+
"text": "BreadcrumbProps['items']"
|
|
210
|
+
},
|
|
211
|
+
"default": "[]",
|
|
212
|
+
"fieldName": "items"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "variant",
|
|
216
|
+
"fieldName": "variant"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "isCompact",
|
|
220
|
+
"fieldName": "isCompact"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
60
223
|
"mixins": [
|
|
61
224
|
{
|
|
62
225
|
"name": "RtlMixin",
|
package/dist/index.d.ts
CHANGED
|
@@ -4,21 +4,107 @@ import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElem
|
|
|
4
4
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
5
|
import type { TemplateResult } from 'lit-html';
|
|
6
6
|
|
|
7
|
+
export declare type BreadcrumbItem = {
|
|
8
|
+
label: string;
|
|
9
|
+
href: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export declare interface BreadcrumbProps {
|
|
13
|
+
items: BreadcrumbItem[];
|
|
14
|
+
/**
|
|
15
|
+
* Optional variant for styling the breadcrumb component.
|
|
16
|
+
*/
|
|
17
|
+
variant?: typeof variants[number];
|
|
18
|
+
/**
|
|
19
|
+
* Optional property for rendering a compact variation of the breadcrumb.
|
|
20
|
+
*/
|
|
21
|
+
isCompact?: boolean;
|
|
8
22
|
}
|
|
9
23
|
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
export declare const componentSelector = "pie-breadcrumb";
|
|
24
|
+
export declare const defaultProps: Pick<BreadcrumbProps, 'variant' | 'isCompact'>;
|
|
13
25
|
|
|
14
26
|
/**
|
|
15
27
|
* @tagname pie-breadcrumb
|
|
16
28
|
*/
|
|
17
29
|
export declare class PieBreadcrumb extends PieBreadcrumb_base implements BreadcrumbProps {
|
|
30
|
+
items: BreadcrumbProps['items'];
|
|
31
|
+
variant: "default" | "scrim" | undefined;
|
|
32
|
+
isCompact: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Renders a separator icon between breadcrumb items.
|
|
35
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
36
|
+
*
|
|
37
|
+
* @returns {TemplateResult} HTML template for the separator icon.
|
|
38
|
+
*
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private renderSeparator;
|
|
42
|
+
/**
|
|
43
|
+
* Renders a navigation link for a breadcrumb item.
|
|
44
|
+
*
|
|
45
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private renderNavigationLink;
|
|
50
|
+
/**
|
|
51
|
+
* Renders the last breadcrumb item.
|
|
52
|
+
* It has 250px of max-width. If the label reaches this width the text truncates.
|
|
53
|
+
*
|
|
54
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
private renderLastItem;
|
|
59
|
+
/**
|
|
60
|
+
* Renders an individual breadcrumb item.
|
|
61
|
+
|
|
62
|
+
* Conditionally renders either a clickable link or plain text for the last item.
|
|
63
|
+
*
|
|
64
|
+
* @param {BreadcrumbItem} item - The breadcrumb item to render.
|
|
65
|
+
* @param {boolean} [isLastItem=false] - Indicates if the item is the last in the breadcrumb trail.
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
private renderItem;
|
|
70
|
+
/**
|
|
71
|
+
* Renders breadcrumb items using the default variant style.
|
|
72
|
+
*
|
|
73
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
private renderDefaultBreadcrumb;
|
|
78
|
+
/**
|
|
79
|
+
* Renders a separator icon specifically for the back variant.
|
|
80
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private renderCompactBreadcrumbSeparator;
|
|
85
|
+
/**
|
|
86
|
+
* Renders breadcrumb items using the back variant style, displaying only the last item with a preceding separator.
|
|
87
|
+
*
|
|
88
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
private renderCompactBreadcrumb;
|
|
93
|
+
/**
|
|
94
|
+
* Renders a complete breadcrumb list.
|
|
95
|
+
* Iterates over breadcrumb items to generate the breadcrumb trail.
|
|
96
|
+
*
|
|
97
|
+
* @param {BreadcrumbProps['items']} items - Array of breadcrumb items to render.
|
|
98
|
+
*
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
private renderBreadcrumbItems;
|
|
18
102
|
render(): TemplateResult<1>;
|
|
19
103
|
static styles: CSSResult;
|
|
20
104
|
}
|
|
21
105
|
|
|
22
106
|
declare const PieBreadcrumb_base: GenericConstructor<RTLInterface> & typeof PieElement;
|
|
23
107
|
|
|
108
|
+
export declare const variants: readonly ["default", "scrim"];
|
|
109
|
+
|
|
24
110
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,189 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { LitElement as f, html as a, nothing as u, unsafeCSS as g } from "lit";
|
|
2
|
+
import { property as d } from "lit/decorators.js";
|
|
3
|
+
import { RtlMixin as $, validPropertyValues as y, defineCustomElement as C } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import { classMap as b } from "lit/directives/class-map.js";
|
|
5
|
+
import "@justeattakeaway/pie-link";
|
|
6
|
+
import "@justeattakeaway/pie-icons-webc/dist/IconChevronRight.js";
|
|
7
|
+
import "@justeattakeaway/pie-icons-webc/dist/IconChevronLeft.js";
|
|
8
|
+
var k = Object.defineProperty, x = (s, r, e, o) => {
|
|
9
|
+
for (var t = void 0, i = s.length - 1, c; i >= 0; i--)
|
|
10
|
+
(c = s[i]) && (t = c(r, e, t) || t);
|
|
11
|
+
return t && k(r, e, t), t;
|
|
9
12
|
};
|
|
10
|
-
class
|
|
13
|
+
class v extends f {
|
|
11
14
|
constructor() {
|
|
12
|
-
super(...arguments), this.v = "0.
|
|
15
|
+
super(...arguments), this.v = "0.3.0";
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
],
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
x([
|
|
19
|
+
d({ type: String, reflect: !0 })
|
|
20
|
+
], v.prototype, "v");
|
|
21
|
+
const S = "*,*:after,*:before{box-sizing:inherit}.c-breadcrumb{--breadcrumb-background-color: var(--dt-color-transparent);background-color:var(--breadcrumb-background-color);padding:var(--dt-spacing-a) var(--dt-spacing-d) var(--dt-spacing-a) var(--dt-spacing-d)}.c-breadcrumb-list{margin:0;padding:0;display:flex;flex-flow:row;gap:var(--dt-spacing-a)}.c-breadcrumb-list li{list-style-type:none;display:flex;align-items:center;white-space:nowrap}.c-breadcrumb--scrim{--breadcrumb-background-color: var(--dt-color-overlay);border-radius:var(--dt-radius-rounded-e)}.c-breadcrumb-list-last-item{overflow:hidden;text-overflow:ellipsis;max-width:250px;color:var(--dt-color-content-subdued)}.c-breadcrumb-list-last-item--scrim{color:var(--dt-color-content-link-light)}.c-breadcrumb-separator{color:var(--dt-color-content-subdued)}.c-breadcrumb-separator--scrim{color:var(--dt-color-content-link-light)}", w = ["default", "scrim"], l = {
|
|
22
|
+
variant: "default",
|
|
23
|
+
isCompact: !1
|
|
24
|
+
};
|
|
25
|
+
var B = Object.defineProperty, m = (s, r, e, o) => {
|
|
26
|
+
for (var t = void 0, i = s.length - 1, c; i >= 0; i--)
|
|
27
|
+
(c = s[i]) && (t = c(r, e, t) || t);
|
|
28
|
+
return t && B(r, e, t), t;
|
|
29
|
+
};
|
|
30
|
+
const h = "pie-breadcrumb", p = class p extends $(v) {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments), this.items = [], this.variant = l.variant, this.isCompact = l.isCompact;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders a separator icon between breadcrumb items.
|
|
36
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
37
|
+
*
|
|
38
|
+
* @returns {TemplateResult} HTML template for the separator icon.
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
renderSeparator() {
|
|
43
|
+
const r = this.variant === "scrim" ? "c-breadcrumb-separator--scrim" : "c-breadcrumb-separator";
|
|
44
|
+
return a`
|
|
45
|
+
<li
|
|
46
|
+
role="presentation"
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
class="${r}"
|
|
49
|
+
data-test-id="pie-breadcrumb-separator">
|
|
50
|
+
${this.isRTL ? a`<icon-chevron-left></icon-chevron-left>` : a`<icon-chevron-right></icon-chevron-right>`}
|
|
51
|
+
</li>
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Renders a navigation link for a breadcrumb item.
|
|
56
|
+
*
|
|
57
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
renderNavigationLink(r) {
|
|
62
|
+
const e = this.variant === "scrim" ? "inverse" : "default";
|
|
63
|
+
return a`
|
|
64
|
+
<pie-link variant="${e}" isStandalone underline="reversed" isBold href="${r.href}">
|
|
65
|
+
${r.label}
|
|
66
|
+
</pie-link>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Renders the last breadcrumb item.
|
|
71
|
+
* It has 250px of max-width. If the label reaches this width the text truncates.
|
|
72
|
+
*
|
|
73
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
renderLastItem(r) {
|
|
20
78
|
const e = {
|
|
21
|
-
|
|
79
|
+
"c-breadcrumb-list-last-item": !0,
|
|
80
|
+
"c-breadcrumb-list-last-item--scrim": this.variant === "scrim"
|
|
22
81
|
};
|
|
23
|
-
return
|
|
82
|
+
return a`<span class="${b(e)}">${r.label}</span>`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders an individual breadcrumb item.
|
|
86
|
+
|
|
87
|
+
* Conditionally renders either a clickable link or plain text for the last item.
|
|
88
|
+
*
|
|
89
|
+
* @param {BreadcrumbItem} item - The breadcrumb item to render.
|
|
90
|
+
* @param {boolean} [isLastItem=false] - Indicates if the item is the last in the breadcrumb trail.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
renderItem(r, e = !1) {
|
|
95
|
+
return a`
|
|
96
|
+
<li role="listitem" data-test-id="pie-breadcrumb-item">
|
|
97
|
+
${e ? this.renderLastItem(r) : this.renderNavigationLink(r)}
|
|
98
|
+
</li>
|
|
99
|
+
${e ? u : this.renderSeparator()}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Renders breadcrumb items using the default variant style.
|
|
104
|
+
*
|
|
105
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
106
|
+
*
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
renderDefaultBreadcrumb(r) {
|
|
110
|
+
const e = r.length - 1;
|
|
111
|
+
return a`${r.map((o, t) => this.renderItem(o, e <= t))}`;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Renders a separator icon specifically for the back variant.
|
|
115
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
renderCompactBreadcrumbSeparator() {
|
|
120
|
+
const r = this.variant === "scrim" ? "c-breadcrumb-separator--scrim" : "c-breadcrumb-separator";
|
|
121
|
+
return a`
|
|
122
|
+
<li role="presentation" aria-hidden="true" class="${r}" data-test-id="pie-breadcrumb-separator">
|
|
123
|
+
${this.isRTL ? a`<icon-chevron-right></icon-chevron-right>` : a`<icon-chevron-left></icon-chevron-left>`}
|
|
124
|
+
</li>
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Renders breadcrumb items using the back variant style, displaying only the last item with a preceding separator.
|
|
129
|
+
*
|
|
130
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
131
|
+
*
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
renderCompactBreadcrumb(r) {
|
|
135
|
+
const e = r[r.length - 1];
|
|
136
|
+
return a`
|
|
137
|
+
${this.renderCompactBreadcrumbSeparator()}
|
|
138
|
+
<li role="listitem" data-test-id="pie-breadcrumb-item">
|
|
139
|
+
${this.renderNavigationLink(e)}
|
|
140
|
+
</li>
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Renders a complete breadcrumb list.
|
|
145
|
+
* Iterates over breadcrumb items to generate the breadcrumb trail.
|
|
146
|
+
*
|
|
147
|
+
* @param {BreadcrumbProps['items']} items - Array of breadcrumb items to render.
|
|
148
|
+
*
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
renderBreadcrumbItems(r, e) {
|
|
152
|
+
return a`
|
|
153
|
+
<ol class="c-breadcrumb-list" data-test-id="pie-breadcrumb-list">
|
|
154
|
+
${e ? this.renderCompactBreadcrumb(r) : this.renderDefaultBreadcrumb(r)}
|
|
155
|
+
</ol>
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
const { items: r, variant: e, isCompact: o } = this;
|
|
160
|
+
return a`
|
|
24
161
|
<nav
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
162
|
+
aria-label="breadcrumb"
|
|
163
|
+
data-test-id="pie-breadcrumb"
|
|
164
|
+
class="${b({
|
|
165
|
+
"c-breadcrumb": !0,
|
|
166
|
+
"c-breadcrumb--scrim": e === "scrim"
|
|
167
|
+
})}">
|
|
168
|
+
${r ? this.renderBreadcrumbItems(r, o) : u}
|
|
31
169
|
</nav>`;
|
|
32
170
|
}
|
|
33
171
|
};
|
|
34
|
-
|
|
35
|
-
let n =
|
|
36
|
-
|
|
172
|
+
p.styles = g(S);
|
|
173
|
+
let n = p;
|
|
174
|
+
m([
|
|
175
|
+
d({ type: Array })
|
|
176
|
+
], n.prototype, "items");
|
|
177
|
+
m([
|
|
178
|
+
d({ type: String }),
|
|
179
|
+
y(h, w, l.variant)
|
|
180
|
+
], n.prototype, "variant");
|
|
181
|
+
m([
|
|
182
|
+
d({ type: Boolean })
|
|
183
|
+
], n.prototype, "isCompact");
|
|
184
|
+
C(h, n);
|
|
37
185
|
export {
|
|
38
186
|
n as PieBreadcrumb,
|
|
39
|
-
|
|
40
|
-
|
|
187
|
+
l as defaultProps,
|
|
188
|
+
w as variants
|
|
41
189
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -5,12 +5,24 @@ import * as React_2 from 'react';
|
|
|
5
5
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
6
6
|
import type { TemplateResult } from 'lit-html';
|
|
7
7
|
|
|
8
|
+
export declare type BreadcrumbItem = {
|
|
9
|
+
label: string;
|
|
10
|
+
href: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
8
13
|
export declare interface BreadcrumbProps {
|
|
14
|
+
items: BreadcrumbItem[];
|
|
15
|
+
/**
|
|
16
|
+
* Optional variant for styling the breadcrumb component.
|
|
17
|
+
*/
|
|
18
|
+
variant?: typeof variants[number];
|
|
19
|
+
/**
|
|
20
|
+
* Optional property for rendering a compact variation of the breadcrumb.
|
|
21
|
+
*/
|
|
22
|
+
isCompact?: boolean;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
export declare const componentSelector = "pie-breadcrumb";
|
|
25
|
+
export declare const defaultProps: Pick<BreadcrumbProps, 'variant' | 'isCompact'>;
|
|
14
26
|
|
|
15
27
|
export declare const PieBreadcrumb: React_2.ForwardRefExoticComponent<BreadcrumbProps & React_2.RefAttributes<PieBreadcrumb_2> & ReactBaseType>;
|
|
16
28
|
|
|
@@ -18,6 +30,78 @@ export declare const PieBreadcrumb: React_2.ForwardRefExoticComponent<Breadcrumb
|
|
|
18
30
|
* @tagname pie-breadcrumb
|
|
19
31
|
*/
|
|
20
32
|
declare class PieBreadcrumb_2 extends PieBreadcrumb_base implements BreadcrumbProps {
|
|
33
|
+
items: BreadcrumbProps['items'];
|
|
34
|
+
variant: "default" | "scrim" | undefined;
|
|
35
|
+
isCompact: boolean | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Renders a separator icon between breadcrumb items.
|
|
38
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
39
|
+
*
|
|
40
|
+
* @returns {TemplateResult} HTML template for the separator icon.
|
|
41
|
+
*
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private renderSeparator;
|
|
45
|
+
/**
|
|
46
|
+
* Renders a navigation link for a breadcrumb item.
|
|
47
|
+
*
|
|
48
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
49
|
+
*
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
private renderNavigationLink;
|
|
53
|
+
/**
|
|
54
|
+
* Renders the last breadcrumb item.
|
|
55
|
+
* It has 250px of max-width. If the label reaches this width the text truncates.
|
|
56
|
+
*
|
|
57
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private renderLastItem;
|
|
62
|
+
/**
|
|
63
|
+
* Renders an individual breadcrumb item.
|
|
64
|
+
|
|
65
|
+
* Conditionally renders either a clickable link or plain text for the last item.
|
|
66
|
+
*
|
|
67
|
+
* @param {BreadcrumbItem} item - The breadcrumb item to render.
|
|
68
|
+
* @param {boolean} [isLastItem=false] - Indicates if the item is the last in the breadcrumb trail.
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private renderItem;
|
|
73
|
+
/**
|
|
74
|
+
* Renders breadcrumb items using the default variant style.
|
|
75
|
+
*
|
|
76
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
77
|
+
*
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private renderDefaultBreadcrumb;
|
|
81
|
+
/**
|
|
82
|
+
* Renders a separator icon specifically for the back variant.
|
|
83
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private renderCompactBreadcrumbSeparator;
|
|
88
|
+
/**
|
|
89
|
+
* Renders breadcrumb items using the back variant style, displaying only the last item with a preceding separator.
|
|
90
|
+
*
|
|
91
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
92
|
+
*
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
private renderCompactBreadcrumb;
|
|
96
|
+
/**
|
|
97
|
+
* Renders a complete breadcrumb list.
|
|
98
|
+
* Iterates over breadcrumb items to generate the breadcrumb trail.
|
|
99
|
+
*
|
|
100
|
+
* @param {BreadcrumbProps['items']} items - Array of breadcrumb items to render.
|
|
101
|
+
*
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
private renderBreadcrumbItems;
|
|
21
105
|
render(): TemplateResult<1>;
|
|
22
106
|
static styles: CSSResult;
|
|
23
107
|
}
|
|
@@ -26,4 +110,6 @@ declare const PieBreadcrumb_base: GenericConstructor<RTLInterface> & typeof PieE
|
|
|
26
110
|
|
|
27
111
|
declare type ReactBaseType = React_2.HTMLAttributes<HTMLElement>;
|
|
28
112
|
|
|
113
|
+
export declare const variants: readonly ["default", "scrim"];
|
|
114
|
+
|
|
29
115
|
export { }
|
package/dist/react.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as r } from "@lit/react";
|
|
3
|
-
import { PieBreadcrumb as
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
3
|
+
import { PieBreadcrumb as a } from "./index.js";
|
|
4
|
+
import { defaultProps as p, variants as d } from "./index.js";
|
|
5
|
+
const m = r({
|
|
6
6
|
displayName: "PieBreadcrumb",
|
|
7
|
-
elementClass:
|
|
7
|
+
elementClass: a,
|
|
8
8
|
react: e,
|
|
9
9
|
tagName: "pie-breadcrumb",
|
|
10
10
|
events: {}
|
|
11
|
-
}), c =
|
|
11
|
+
}), c = m;
|
|
12
12
|
export {
|
|
13
13
|
c as PieBreadcrumb,
|
|
14
|
-
p as
|
|
15
|
-
|
|
14
|
+
p as defaultProps,
|
|
15
|
+
d as variants
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-breadcrumb",
|
|
3
3
|
"description": "PIE Design System Breadcrumb built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"license": "Apache-2.0",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
36
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
36
|
+
"@justeattakeaway/pie-components-config": "0.20.0",
|
|
37
37
|
"@justeattakeaway/pie-css": "0.16.0",
|
|
38
38
|
"@justeattakeaway/pie-monorepo-utils": "0.5.0",
|
|
39
39
|
"cem-plugin-module-file-extensions": "0.0.5"
|
package/src/breadcrumb.scss
CHANGED
|
@@ -2,19 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
.c-breadcrumb {
|
|
4
4
|
--breadcrumb-background-color: var(--dt-color-transparent);
|
|
5
|
-
|
|
5
|
+
background-color: var(--breadcrumb-background-color);
|
|
6
6
|
padding: var(--dt-spacing-a) var(--dt-spacing-d) var(--dt-spacing-a) var(--dt-spacing-d);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.c-breadcrumb-list {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-flow: row;
|
|
14
|
+
|
|
15
|
+
gap: var(--dt-spacing-a);
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
padding: 0;
|
|
17
|
+
li {
|
|
18
|
+
list-style-type: none;
|
|
11
19
|
display: flex;
|
|
12
|
-
|
|
20
|
+
align-items: center;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.c-breadcrumb--scrim {
|
|
26
|
+
--breadcrumb-background-color: var(--dt-color-overlay);
|
|
27
|
+
border-radius: var(--dt-radius-rounded-e);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.c-breadcrumb-list-last-item {
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
max-width: 250px;
|
|
34
|
+
color: var(--dt-color-content-subdued);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.c-breadcrumb-list-last-item--scrim {
|
|
38
|
+
color: var(--dt-color-content-link-light);
|
|
39
|
+
}
|
|
13
40
|
|
|
14
|
-
|
|
41
|
+
.c-breadcrumb-separator {
|
|
42
|
+
color: var(--dt-color-content-subdued);
|
|
43
|
+
}
|
|
15
44
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
45
|
+
.c-breadcrumb-separator--scrim {
|
|
46
|
+
color: var(--dt-color-content-link-light);
|
|
47
|
+
}
|
package/src/defs.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
export const variants = ['default', 'scrim'] as const;
|
|
2
|
+
|
|
3
|
+
export type BreadcrumbItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
href: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface BreadcrumbProps {
|
|
9
|
+
items: BreadcrumbItem[];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Optional variant for styling the breadcrumb component.
|
|
13
|
+
*/
|
|
14
|
+
variant?: typeof variants[number];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Optional property for rendering a compact variation of the breadcrumb.
|
|
18
|
+
*/
|
|
19
|
+
isCompact?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const defaultProps: Pick<BreadcrumbProps, 'variant' | 'isCompact'> = {
|
|
23
|
+
variant: 'default',
|
|
24
|
+
isCompact: false,
|
|
25
|
+
};
|
|
4
26
|
|
|
5
|
-
export const componentSelector = 'pie-breadcrumb';
|
|
6
|
-
export const componentClass = 'c-breadcrumb';
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import { html, unsafeCSS } from 'lit';
|
|
2
|
-
import {
|
|
1
|
+
import { html, nothing, unsafeCSS } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { RtlMixin, defineCustomElement, validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
3
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
5
|
|
|
5
6
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
7
|
+
|
|
8
|
+
import '@justeattakeaway/pie-link';
|
|
9
|
+
import '@justeattakeaway/pie-icons-webc/dist/IconChevronRight.js';
|
|
10
|
+
import '@justeattakeaway/pie-icons-webc/dist/IconChevronLeft.js';
|
|
11
|
+
|
|
6
12
|
import styles from './breadcrumb.scss?inline';
|
|
7
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type BreadcrumbProps,
|
|
15
|
+
type BreadcrumbItem,
|
|
16
|
+
variants,
|
|
17
|
+
defaultProps,
|
|
18
|
+
} from './defs';
|
|
19
|
+
|
|
20
|
+
const componentSelector = 'pie-breadcrumb';
|
|
8
21
|
|
|
9
22
|
// Valid values available to consumers
|
|
10
23
|
export * from './defs';
|
|
@@ -13,19 +26,172 @@ export * from './defs';
|
|
|
13
26
|
* @tagname pie-breadcrumb
|
|
14
27
|
*/
|
|
15
28
|
export class PieBreadcrumb extends RtlMixin(PieElement) implements BreadcrumbProps {
|
|
29
|
+
@property({ type: Array })
|
|
30
|
+
public items: BreadcrumbProps['items'] = [];
|
|
31
|
+
|
|
32
|
+
@property({ type: String })
|
|
33
|
+
@validPropertyValues(componentSelector, variants, defaultProps.variant)
|
|
34
|
+
public variant = defaultProps.variant;
|
|
35
|
+
|
|
36
|
+
@property({ type: Boolean })
|
|
37
|
+
public isCompact = defaultProps.isCompact;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Renders a separator icon between breadcrumb items.
|
|
41
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
42
|
+
*
|
|
43
|
+
* @returns {TemplateResult} HTML template for the separator icon.
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
private renderSeparator () {
|
|
48
|
+
const separatorVariant = this.variant === 'scrim' ? 'c-breadcrumb-separator--scrim' : 'c-breadcrumb-separator';
|
|
49
|
+
|
|
50
|
+
return html`
|
|
51
|
+
<li
|
|
52
|
+
role="presentation"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
class="${separatorVariant}"
|
|
55
|
+
data-test-id="pie-breadcrumb-separator">
|
|
56
|
+
${this.isRTL ? html`<icon-chevron-left></icon-chevron-left>` : html`<icon-chevron-right></icon-chevron-right>`}
|
|
57
|
+
</li>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Renders a navigation link for a breadcrumb item.
|
|
63
|
+
*
|
|
64
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private renderNavigationLink (item: BreadcrumbItem) {
|
|
69
|
+
const linkVariant = this.variant === 'scrim' ? 'inverse' : 'default';
|
|
70
|
+
|
|
71
|
+
return html`
|
|
72
|
+
<pie-link variant="${linkVariant}" isStandalone underline="reversed" isBold href="${item.href}">
|
|
73
|
+
${item.label}
|
|
74
|
+
</pie-link>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Renders the last breadcrumb item.
|
|
80
|
+
* It has 250px of max-width. If the label reaches this width the text truncates.
|
|
81
|
+
*
|
|
82
|
+
* @param {BreadcrumbItem} item - The breadcrumb item containing label and URL.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private renderLastItem (item: BreadcrumbItem) {
|
|
87
|
+
const wrapperClasses = {
|
|
88
|
+
'c-breadcrumb-list-last-item': true,
|
|
89
|
+
'c-breadcrumb-list-last-item--scrim': this.variant === 'scrim',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return html`<span class="${classMap(wrapperClasses)}">${item.label}</span>`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Renders an individual breadcrumb item.
|
|
97
|
+
|
|
98
|
+
* Conditionally renders either a clickable link or plain text for the last item.
|
|
99
|
+
*
|
|
100
|
+
* @param {BreadcrumbItem} item - The breadcrumb item to render.
|
|
101
|
+
* @param {boolean} [isLastItem=false] - Indicates if the item is the last in the breadcrumb trail.
|
|
102
|
+
*
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
private renderItem (item: BreadcrumbItem, isLastItem = false) {
|
|
106
|
+
return html`
|
|
107
|
+
<li role="listitem" data-test-id="pie-breadcrumb-item">
|
|
108
|
+
${
|
|
109
|
+
isLastItem
|
|
110
|
+
? this.renderLastItem(item)
|
|
111
|
+
: this.renderNavigationLink(item)
|
|
112
|
+
}
|
|
113
|
+
</li>
|
|
114
|
+
${isLastItem ? nothing : this.renderSeparator()}
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Renders breadcrumb items using the default variant style.
|
|
120
|
+
*
|
|
121
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
122
|
+
*
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
private renderDefaultBreadcrumb (items: BreadcrumbProps['items']) {
|
|
126
|
+
const numberOfSeparators = items.length - 1;
|
|
127
|
+
|
|
128
|
+
return html`${items.map((item, index) => this.renderItem(item, numberOfSeparators <= index))}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Renders a separator icon specifically for the back variant.
|
|
133
|
+
* The icon direction depends on the RTL (Right-to-Left) setting.
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
private renderCompactBreadcrumbSeparator () {
|
|
138
|
+
const separatorVariant = this.variant === 'scrim' ? 'c-breadcrumb-separator--scrim' : 'c-breadcrumb-separator';
|
|
139
|
+
|
|
140
|
+
return html`
|
|
141
|
+
<li role="presentation" aria-hidden="true" class="${separatorVariant}" data-test-id="pie-breadcrumb-separator">
|
|
142
|
+
${this.isRTL ? html`<icon-chevron-right></icon-chevron-right>` : html`<icon-chevron-left></icon-chevron-left>`}
|
|
143
|
+
</li>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Renders breadcrumb items using the back variant style, displaying only the last item with a preceding separator.
|
|
149
|
+
*
|
|
150
|
+
* @param {BreadcrumbProps['items']} items - Breadcrumb items to render.
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
private renderCompactBreadcrumb (items: BreadcrumbProps['items']) {
|
|
155
|
+
const lastItem = items[items.length - 1];
|
|
156
|
+
|
|
157
|
+
return html`
|
|
158
|
+
${this.renderCompactBreadcrumbSeparator()}
|
|
159
|
+
<li role="listitem" data-test-id="pie-breadcrumb-item">
|
|
160
|
+
${this.renderNavigationLink(lastItem)}
|
|
161
|
+
</li>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Renders a complete breadcrumb list.
|
|
167
|
+
* Iterates over breadcrumb items to generate the breadcrumb trail.
|
|
168
|
+
*
|
|
169
|
+
* @param {BreadcrumbProps['items']} items - Array of breadcrumb items to render.
|
|
170
|
+
*
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
private renderBreadcrumbItems (items: BreadcrumbProps['items'], isCompact: BreadcrumbProps['isCompact']) {
|
|
174
|
+
return html`
|
|
175
|
+
<ol class="c-breadcrumb-list" data-test-id="pie-breadcrumb-list">
|
|
176
|
+
${isCompact ? this.renderCompactBreadcrumb(items) : this.renderDefaultBreadcrumb(items)}
|
|
177
|
+
</ol>
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
|
|
16
181
|
render () {
|
|
182
|
+
const { items, variant, isCompact } = this;
|
|
183
|
+
|
|
17
184
|
const componentWrapperClasses = {
|
|
18
|
-
|
|
185
|
+
'c-breadcrumb': true,
|
|
186
|
+
'c-breadcrumb--scrim': variant === 'scrim',
|
|
19
187
|
};
|
|
20
188
|
|
|
21
189
|
return html`
|
|
22
190
|
<nav
|
|
23
|
-
|
|
191
|
+
aria-label="breadcrumb"
|
|
192
|
+
data-test-id="pie-breadcrumb"
|
|
24
193
|
class="${classMap(componentWrapperClasses)}">
|
|
25
|
-
|
|
26
|
-
<li><span>Previous Page</span></li>
|
|
27
|
-
<li><span>Current Page</span></li>
|
|
28
|
-
</ol>
|
|
194
|
+
${items ? this.renderBreadcrumbItems(items, isCompact) : nothing}
|
|
29
195
|
</nav>`;
|
|
30
196
|
}
|
|
31
197
|
|