import {type CSSResultGroup, html, unsafeCSS} from 'lit'; import {property, state} from 'lit/decorators.js'; import ZnTabs from "../tabs"; import styles from './page-nav.scss'; interface PageNavData { data: PageNavigation[]; } interface PageNavigation { title: string; items: PageNavigationItem[]; } interface PageNavigationItem { icon?: string; label: string; uri: string; } /** * @summary Short summary of the component's intended use. * @documentation https://zinc.style/components/page-nav * @status experimental * @since 1.0 * * @dependency zn-example * * @event zn-event-name - Emitted as an example. * * @slot - The default slot. * @slot example - An example slot. * * @csspart base - The component's base wrapper. * * @cssproperty --example - An example CSS custom property. */ export default class ZnPageNav extends ZnTabs { static styles: CSSResultGroup = [ZnTabs.styles, unsafeCSS(styles)]; @property({type: Object}) navigation: PageNavData; @state() breadcrumb: string toggleNavigation() { const navigationElement = this.shadowRoot?.querySelector('.navigation'); if (navigationElement) { // Toggle the 'active' class to show/hide the navigation navigationElement.classList.toggle('active'); } // toggle menu overlay const menuOverlay = this.shadowRoot?.querySelector('.menu-overlay'); if (menuOverlay) { menuOverlay.classList.toggle('active'); } } setActiveTab(tabName: string, store: boolean, refresh: boolean, refTab: string | null = null) { super.setActiveTab(tabName, store, refresh, refTab); const firstTab = this.shadowRoot?.querySelector('.navigation-item.active'); if (firstTab) { this.breadcrumb = firstTab.textContent?.trim() || ''; } else { this.breadcrumb = ''; } } clickTab(target: HTMLElement, refresh: boolean, close = true) { super.clickTab(target, refresh); this.breadcrumb = target.textContent?.trim() || ''; if(close) { this.toggleNavigation(); } } render() { if (!this.navigation) { return html`

No navigation data available.

`; } const navItems = this.navigation.data.map(data => { return html` `; }); return html`
`; } }