Skip to content

Commit 31eda63

Browse files
committed
refactor: upgrade to v25
1 parent d605b54 commit 31eda63

File tree

12 files changed

+143
-164
lines changed

12 files changed

+143
-164
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Add `<vcf-breadcrumbs>` element to the page. Inside added element add few `<vcf-
3535
![breadcrumbs-02](https://github.com/user-attachments/assets/f56e9aa0-756a-412e-86d6-71ee341fd878)
3636
![breadcrumbs-03](https://github.com/user-attachments/assets/ae3b4816-0892-4651-b002-b4ac99412687)
3737

38+
## Updates since version 3.0.0
39+
40+
By default, the component uses a minimal set of functional styles that provide a foundation for a custom theme.
41+
To use the component with the Vaadin Lumo theme, import the component's Lumo theme from `@vaadin-component-factory/vcf-breadcrumb/theme/lumo.css`.
42+
43+
`ThemableMixin` has been removed from the component, and injecting styles into the component's shadow root using `registerStyles` is no longer supported.
44+
Use global CSS to style the component using part names and CSS variables instead.
45+
3846
## Updates since version 2.0.0
3947

4048
- Lit based component with theming support.

demo/demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import '@polymer/iron-demo-helpers/demo-pages-shared-styles';
22
import '@polymer/iron-demo-helpers/demo-snippet';
3-
import '../dist/src/vcf-breadcrumbs.js';
3+
import '@vaadin/vaadin-lumo-styles/icons.js';
4+
import '../dist/src/vcf-breadcrumbs.js';

demo/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<title>vcf-breadcrumb demo</title>
77
<script dev src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
88
<script dev type="module" src="demo.js"></script>
9+
<link rel="stylesheet" href="/node_modules/@vaadin/vaadin-lumo-styles/lumo.css" />
10+
<link rel="stylesheet" href="/theme/lumo.css" />
911
<custom-style>
1012
<style is="custom-style" include="demo-pages-shared-styles">
1113
.centered {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
"license": "https://raw.githubusercontent.com/vaadin-component-factory/vcf-breadcrumb/master/LICENSE",
1010
"exports": {
1111
".": "./dist/src/index.js",
12-
"./dist/src/vcf-breadcrumbs.js": "./dist/src/vcf-breadcrumbs.js"
12+
"./dist/src/vcf-breadcrumbs.js": "./dist/src/vcf-breadcrumbs.js",
13+
"./theme/*": "./theme/*"
1314
},
1415
"files": [
1516
"vcf-*.js",
1617
"src",
18+
"theme",
1719
"dist"
1820
],
1921
"repository": {
@@ -42,11 +44,9 @@
4244
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
4345
},
4446
"dependencies": {
45-
"@vaadin/component-base": "^24.5.8",
46-
"@vaadin/popover": "^24.5.8",
47-
"@vaadin/vaadin-lumo-styles": "^24.5.8",
48-
"@vaadin/vaadin-themable-mixin": "^24.5.8",
49-
"@vaadin/vertical-layout": "^24.5.8",
47+
"@vaadin/component-base": "^25.0.0-beta1",
48+
"@vaadin/popover": "^25.0.0-beta1",
49+
"@vaadin/vertical-layout": "^25.0.0-beta1",
5050
"lit": "^3.0.0"
5151
},
5252
"devDependencies": {
@@ -58,6 +58,7 @@
5858
"@types/jest": "^29.5.14",
5959
"@typescript-eslint/eslint-plugin": "^5.48.0",
6060
"@typescript-eslint/parser": "^5.48.0",
61+
"@vaadin/vaadin-lumo-styles": "^25.0.0-beta1",
6162
"@web/dev-server": "^0.4.3",
6263
"@web/test-runner": "^0.19.0",
6364
"@webcomponents/webcomponentsjs": "^2.0.0",

src/component/vcf-breadcrumb.ts

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
*/
1919
import { html, LitElement, css } from "lit";
2020
import { customElement, property } from 'lit/decorators.js';
21-
import { ThemableMixin } from "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js";
2221
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
2322
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
24-
import { typography } from "@vaadin/vaadin-lumo-styles";
2523

2624
/**
2725
* A Web Component for individual breadcrumb items in a breadcrumb navigation system.
@@ -39,16 +37,15 @@ import { typography } from "@vaadin/vaadin-lumo-styles";
3937
* <vcf-breadcrumb href="/products">Products</vcf-breadcrumb>
4038
* <vcf-breadcrumb>Current Page</vcf-breadcrumb>
4139
* ```
42-
*
40+
*
4341
* @memberof Vaadin
4442
* @name vcf-breadcrumb
4543
* @mixes ElementMixin
46-
* @mixes ThemableMixin
4744
* @mixes PolylitMixin
4845
* @demo demo/index.html
4946
*/
5047
@customElement("vcf-breadcrumb")
51-
class VcfBreadcrumb extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
48+
class VcfBreadcrumb extends ElementMixin(PolylitMixin(LitElement)) {
5249

5350
@property({ type: String, reflect: true })
5451
href = '';
@@ -75,16 +72,76 @@ class VcfBreadcrumb extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))
7572
}
7673

7774
static get styles() {
78-
return [typography, css`
79-
:host(:last-of-type) [part='separator'] {
80-
display: none;
81-
}
82-
75+
return [css`
8376
:host {
8477
display: flex;
8578
align-items: center;
8679
min-width: 40px;
87-
}
80+
--vcf-breadcrumb-separator-font-family: 'inherit';
81+
--vcf-breadcrumb-separator-symbol: '/';
82+
--vcf-breadcrumb-separator-color: var(--vaadin-text-color-secondary, #666);
83+
--vcf-breadcrumb-separator-size: var(--vaadin-icon-size, 1lh);
84+
--vcf-breadcrumb-separator-margin: 0;
85+
--vcf-breadcrumb-separator-padding: 0 var(--vaadin-padding-xs, 6px);
86+
--vcf-breadcrumb-mobile-back-symbol: '←';
87+
--vcf-breadcrumb-link-focus-ring-color: var(--vaadin-focus-ring-color, Highlight);
88+
}
89+
90+
:host [part='separator'] {
91+
margin: var(--vcf-breadcrumb-separator-margin);
92+
padding: var(--vcf-breadcrumb-separator-padding);
93+
}
94+
95+
:host [part='separator']::after {
96+
font-family: var(--vcf-breadcrumb-separator-font-family);
97+
content: var(--vcf-breadcrumb-separator-symbol);
98+
color: var(--vcf-breadcrumb-separator-color);
99+
font-size: var(--vcf-breadcrumb-separator-size);
100+
speak: none;
101+
}
102+
103+
:host(:last-of-type) [part='separator'] {
104+
display: none;
105+
}
106+
107+
[part='link'] {
108+
overflow: hidden;
109+
white-space: nowrap;
110+
text-overflow: ellipsis;
111+
}
112+
113+
/* Focus ring */
114+
:host(:focus-within) [part="link"] {
115+
outline: var(--vcf-breadcrumb-link-focus-ring-color) auto 1px;
116+
outline-offset: 1px;
117+
}
118+
119+
::slotted(a:focus) {
120+
outline: none;
121+
}
122+
123+
/* mobile back mode */
124+
:host(.mobile-back) {
125+
display: none;
126+
}
127+
128+
:host(.mobile-back) [part='separator'] {
129+
display: none;
130+
}
131+
132+
:host(.mobile-back.is-last-not-current),
133+
:host(.mobile-back.is-before-current) {
134+
display: inline-block;
135+
}
136+
137+
::slotted(a.breadcrumb-anchor.add-mobile-back-icon)::before {
138+
display: inline;
139+
font-family: var(--vcf-breadcrumb-separator-font-family);
140+
content: var(--vcf-breadcrumb-mobile-back-symbol);
141+
font-size: var(--vcf-breadcrumb-separator-size);
142+
margin: var(--vcf-breadcrumb-separator-margin);
143+
color: inherit;
144+
}
88145
`];
89146
}
90147

src/component/vcf-breadcrumbs.ts

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
import { html, LitElement, css } from "lit";
2020
import { customElement, property, state } from 'lit/decorators.js';
21-
import { ThemableMixin } from "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js";
2221
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
2322
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
2423
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
@@ -56,12 +55,11 @@ import '@vaadin/vertical-layout';
5655
* @name vcf-breadcrumbs
5756
* @mixes ResizeMixin
5857
* @mixes ElementMixin
59-
* @mixes ThemableMixin
6058
* @mixes PolylitMixin
6159
* @demo demo/index.html
6260
*/
6361
@customElement("vcf-breadcrumbs")
64-
export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
62+
export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(PolylitMixin(LitElement))) {
6563

6664
/**
6765
* Flag to indicate if the component is in mobile mode.
@@ -96,9 +94,16 @@ export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(Polyl
9694

9795
static get styles() {
9896
return css`
99-
:host {
100-
display: block;
101-
}
97+
:host {
98+
display: block;
99+
}
100+
101+
[part='links-list'] {
102+
display: flex;
103+
justify-content: start;
104+
align-content: center;
105+
align-items: center;
106+
}
102107
`;
103108
}
104109

@@ -281,41 +286,36 @@ export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(Polyl
281286
ellipsis.style.minWidth = '0';
282287

283288
// Create a popover to show the hidden breadcumbs and add it to the ellipsis element
284-
let popover = document.createElement("vaadin-popover");
289+
const popover = document.createElement("vaadin-popover");
285290
popover.setAttribute("for", id);
286291
popover.setAttribute("overlay-role", "menu");
287-
popover.setAttribute('accessible-name-ref', "hidden breadcrumbs");
292+
popover.setAttribute('accessible-name-ref', "hidden breadcrumbs");
288293
popover.setAttribute("theme", "hidden-breadcrumbs");
289294
popover.setAttribute("position", "bottom-start");
290295
popover.setAttribute("modal", "true");
291296

292-
popover.renderer = (root) => {
293-
// Ensure content is only added once
294-
if (!root.firstChild) {
295-
const verticalLayout = document.createElement('vaadin-vertical-layout');
296-
verticalLayout.classList.add('hidden-breadcrumbs-layout');
297-
298-
// create new anchor elements for the hidden items and add them to the vertical layout
299-
hiddenItems.forEach((element) => {
300-
const item = document.createElement('a');
301-
item.textContent = element.textContent;
302-
item.setAttribute("href", element.getAttribute('href') ?? '');
303-
item.setAttribute("role", "menuitem");
304-
// Copy element class list
305-
const elementClasses = Array.from(element.classList);
306-
item.classList.add(...elementClasses);
307-
item.classList.add("hidden-breadcrumb-anchor");
308-
309-
// Add click event to close popover when clicking an item
310-
item.addEventListener("click", () => {
311-
popover.opened = false;
312-
});
313-
314-
verticalLayout.appendChild(item);
315-
});
316-
root.appendChild(verticalLayout);
317-
}
318-
};
297+
const verticalLayout = document.createElement('vaadin-vertical-layout');
298+
verticalLayout.classList.add('hidden-breadcrumbs-layout');
299+
300+
// create new anchor elements for the hidden items and add them to the vertical layout
301+
hiddenItems.forEach((element) => {
302+
const item = document.createElement('a');
303+
item.textContent = element.textContent;
304+
item.setAttribute("href", element.getAttribute('href') ?? '');
305+
item.setAttribute("role", "menuitem");
306+
// Copy element class list
307+
const elementClasses = Array.from(element.classList);
308+
item.classList.add(...elementClasses);
309+
item.classList.add("hidden-breadcrumb-anchor");
310+
311+
// Add click event to close popover when clicking an item
312+
item.addEventListener("click", () => {
313+
popover.opened = false;
314+
});
315+
316+
verticalLayout.appendChild(item);
317+
});
318+
popover.appendChild(verticalLayout);
319319

320320
// append popover to ellipsis to move it later to the anchor within the container
321321
ellipsis.appendChild(popover);
@@ -342,27 +342,6 @@ export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(Polyl
342342
this._mobile = matches;
343343
}),
344344
);
345-
346-
// Inject a scoped <style> element to define the mobile back icon behavior
347-
const style = document.createElement('style');
348-
style.textContent = `
349-
/*
350-
* This rule targets an <a> element with the 'breadcrumb-anchor' and
351-
* 'add-mobile-back-icon' classes that is a direct child of <vcf-breadcrumb>.
352-
*
353-
* Although technically global, it's scoped through the component selector
354-
* and only applies to breadcrumb anchors styled for mobile mode.
355-
*/
356-
vcf-breadcrumb > a.breadcrumb-anchor.add-mobile-back-icon::before {
357-
display: inline;
358-
font-family: var(--vcf-breadcrumb-separator-font-family);
359-
content: var(--vcf-breadcrumb-mobile-back-symbol);
360-
font-size: var(--vcf-breadcrumb-separator-size);
361-
margin: var(--vcf-breadcrumb-separator-margin);
362-
color: inherit;
363-
}
364-
`;
365-
this.appendChild(style);
366345
}
367346

368347
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { VcfBreadcrumbs as VcfBreadcrumbs } from './component/vcf-breadcrumbs.js';
1+
export * from './vcf-breadcrumbs.js';

src/theme/lumo/vcf-breadcrumb-styles.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/theme/lumo/vcf-breadcrumb.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)