1818 */
1919import { html , LitElement , css } from "lit" ;
2020import { customElement , property , state } from 'lit/decorators.js' ;
21- import { ThemableMixin } from "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js" ;
2221import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js' ;
2322import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js' ;
2423import { 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}
0 commit comments