@kodaris/krubble-app-components 1.0.38 → 1.0.40

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.
@@ -2243,9 +2243,23 @@
2243
2243
  */
2244
2244
  this.navItems = [];
2245
2245
  /**
2246
- * Currently active item ID
2246
+ * Currently active item ID. Auto-detected from the URL by default.
2247
+ * Can be set explicitly by the parent to override.
2247
2248
  */
2248
2249
  this.activeId = '';
2250
+ this.handlePopstate = () => {
2251
+ this.syncActiveFromUrl();
2252
+ };
2253
+ }
2254
+ connectedCallback() {
2255
+ super.connectedCallback();
2256
+ // Defer so property bindings (.navItems) have been applied
2257
+ requestAnimationFrame(() => this.syncActiveFromUrl());
2258
+ window.addEventListener('popstate', this.handlePopstate);
2259
+ }
2260
+ disconnectedCallback() {
2261
+ super.disconnectedCallback();
2262
+ window.removeEventListener('popstate', this.handlePopstate);
2249
2263
  }
2250
2264
  /**
2251
2265
  * Handles click events on navigation items.
@@ -2274,6 +2288,24 @@
2274
2288
  if (navEvent.defaultPrevented) {
2275
2289
  e.preventDefault();
2276
2290
  }
2291
+ this.activeId = item.id;
2292
+ }
2293
+ syncActiveFromUrl() {
2294
+ const pathname = window.location.pathname;
2295
+ const match = this.navItems.find((item) => {
2296
+ if (!item.url) {
2297
+ return false;
2298
+ }
2299
+ // Absolute URL — exact match
2300
+ if (item.url.startsWith('/')) {
2301
+ return pathname === item.url;
2302
+ }
2303
+ // Relative URL — match against the end of the pathname
2304
+ return pathname.endsWith('/' + item.url);
2305
+ });
2306
+ if (match) {
2307
+ this.activeId = match.id;
2308
+ }
2277
2309
  }
2278
2310
  render() {
2279
2311
  return b `
@@ -2316,8 +2348,8 @@
2316
2348
 
2317
2349
  .nav {
2318
2350
  width: 200px;
2319
- background: #F3F7FC;
2320
- //border-right: 1px solid #000000;
2351
+ background: white;
2352
+ border-right: 1px solid #e5e7eb;
2321
2353
  display: flex;
2322
2354
  flex-direction: column;
2323
2355
  flex-shrink: 0;
@@ -2334,7 +2366,7 @@
2334
2366
  }
2335
2367
 
2336
2368
  .nav-header__title {
2337
- font-size: 16px;
2369
+ font-size: 18px;
2338
2370
  font-weight: 600;
2339
2371
  color: #111827;
2340
2372
  white-space: nowrap;