@triptease/tt-navbar 0.0.33 → 0.0.35
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/src/TtNavbar.js +9 -0
- package/dist/src/TtNavbar.js.map +1 -1
- package/dist/test/tt-navbar.test.js +20 -0
- package/dist/test/tt-navbar.test.js.map +1 -1
- package/dist/web/Routes.js +1 -1
- package/dist/web/TtNavbar.js +7 -1
- package/dist/web/TtNavbar.js.map +2 -2
- package/dist/web/index.js +7 -1
- package/dist/web/index.js.map +2 -2
- package/dist/web/styles.js +1 -1
- package/dist/web/triptease-logo.js +1 -1
- package/dist/web/tt-navbar.js +7 -1
- package/dist/web/tt-navbar.js.map +2 -2
- package/dist/web/urlMappings.js +1 -1
- package/package.json +1 -1
- package/src/TtNavbar.ts +13 -2
- package/test/tt-navbar.test.ts +35 -0
package/dist/web/urlMappings.js
CHANGED
package/package.json
CHANGED
package/src/TtNavbar.ts
CHANGED
|
@@ -67,14 +67,19 @@ export class TtNavbar extends LitElement {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
public connectedCallback() {
|
|
70
|
-
|
|
70
|
+
// Listen for browser back/forward navigation
|
|
71
71
|
window.addEventListener('popstate', this.setActiveState);
|
|
72
|
+
|
|
73
|
+
// Listen for Tetris programmatic navigation
|
|
74
|
+
window.addEventListener('tetris:navigate', this.setActiveState);
|
|
75
|
+
|
|
72
76
|
super.connectedCallback();
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
public disconnectedCallback() {
|
|
76
|
-
|
|
77
80
|
window.removeEventListener('popstate', this.setActiveState);
|
|
81
|
+
window.removeEventListener('tetris:navigate', this.setActiveState);
|
|
82
|
+
|
|
78
83
|
super.disconnectedCallback();
|
|
79
84
|
}
|
|
80
85
|
|
|
@@ -141,6 +146,12 @@ export class TtNavbar extends LitElement {
|
|
|
141
146
|
if (bestMatch) {
|
|
142
147
|
bestMatch.classList.add('current-page');
|
|
143
148
|
bestMatch.setAttribute('aria-current', 'page');
|
|
149
|
+
|
|
150
|
+
// Auto-expand parent details if the active link is within a collapsible section
|
|
151
|
+
const parentDetails = bestMatch.closest('details');
|
|
152
|
+
if (parentDetails) {
|
|
153
|
+
parentDetails.setAttribute('open', '');
|
|
154
|
+
}
|
|
144
155
|
} else {
|
|
145
156
|
console.error(`No matching nav link found for path: ${currentPath}`);
|
|
146
157
|
}
|
package/test/tt-navbar.test.ts
CHANGED
|
@@ -345,4 +345,39 @@ describe('TtNavbar', () => {
|
|
|
345
345
|
await expect(getComputedStyle(navbar).getPropertyValue('--nav-bar-width').trim()).to.equal('fit-content');
|
|
346
346
|
|
|
347
347
|
});
|
|
348
|
+
|
|
349
|
+
it('should expand the details when the current page is within that section', async () => {
|
|
350
|
+
// eslint-disable-next-line no-restricted-globals
|
|
351
|
+
history.pushState({}, '', `/parity/${CLIENT_KEY}`);
|
|
352
|
+
|
|
353
|
+
const navbar = await fixture<TtNavbar>(
|
|
354
|
+
`<tt-navbar client-key=${CLIENT_KEY}></tt-navbar>`
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
const marketInsightsDetails = navbar.shadowRoot!.querySelector('#market-insights') as HTMLDetailsElement;
|
|
358
|
+
|
|
359
|
+
expect(marketInsightsDetails).to.exist;
|
|
360
|
+
expect(marketInsightsDetails.open).to.be.true;
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('should set the active route when receives `tetris:navigate` event', async () => {
|
|
364
|
+
const navbar = await fixture<TtNavbar>(
|
|
365
|
+
`<tt-navbar client-key=${CLIENT_KEY}></tt-navbar>`
|
|
366
|
+
);
|
|
367
|
+
// eslint-disable-next-line no-restricted-globals
|
|
368
|
+
history.pushState({}, '', `/account/billing-management/${CLIENT_KEY}`)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
// Dispatch the event to change to Channels route
|
|
372
|
+
const navigateEvent = new CustomEvent('tetris:navigate', {
|
|
373
|
+
});
|
|
374
|
+
window.dispatchEvent(navigateEvent);
|
|
375
|
+
|
|
376
|
+
await elementUpdated(navbar);
|
|
377
|
+
const anchor = navbar.shadowRoot!.querySelector('a[aria-current="page"]');
|
|
378
|
+
|
|
379
|
+
expect(anchor).to.exist;
|
|
380
|
+
expect(anchor!.textContent).to.include('Booking reconciliation');
|
|
381
|
+
|
|
382
|
+
})
|
|
348
383
|
});
|