@classic-homes/theme-svelte 1.22.2 → 1.22.4

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.
@@ -45,6 +45,8 @@
45
45
  autoCollapse?: boolean;
46
46
  /** IDs of expandable items alongside this one */
47
47
  siblingIds?: string[];
48
+ /** Rendered inside another item's submenu panel (internal) */
49
+ nested?: boolean;
48
50
  }
49
51
 
50
52
  let {
@@ -62,6 +64,7 @@
62
64
  onMouseLeave,
63
65
  autoCollapse = false,
64
66
  siblingIds = [],
67
+ nested = false,
65
68
  }: Props = $props();
66
69
 
67
70
  // Highlight matching text in item names
@@ -99,11 +102,11 @@
99
102
  return cn(
100
103
  isLight &&
101
104
  !active &&
102
- 'text-foreground bg-background hover:bg-accent hover:text-accent-foreground',
105
+ 'text-foreground bg-transparent hover:bg-accent hover:text-accent-foreground',
103
106
  isLight && active && 'bg-primary/10 text-primary',
104
107
  !isLight &&
105
108
  !active &&
106
- 'text-sidebar-foreground bg-sidebar hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
109
+ 'text-sidebar-foreground bg-transparent hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
107
110
  !isLight && active && 'bg-sidebar-primary text-sidebar-primary-foreground',
108
111
  disabled && 'opacity-50 pointer-events-none cursor-not-allowed'
109
112
  );
@@ -266,9 +269,12 @@
266
269
  <div
267
270
  class={cn(
268
271
  'group flex w-full items-center rounded-md',
269
- isLight && !item.active && 'bg-background hover:bg-accent',
272
+ // Inside a submenu panel rows sit on the panel's grey, so no rest fill
273
+ isLight && !item.active && (nested ? 'bg-transparent' : 'bg-background'),
274
+ isLight && !item.active && 'hover:bg-accent',
270
275
  isLight && item.active && 'bg-primary/10',
271
- !isLight && !item.active && 'bg-sidebar hover:bg-sidebar-accent',
276
+ !isLight && !item.active && (nested ? 'bg-transparent' : 'bg-sidebar'),
277
+ !isLight && !item.active && 'hover:bg-sidebar-accent',
272
278
  !isLight && item.active && 'bg-sidebar-primary'
273
279
  )}
274
280
  >
@@ -372,54 +378,64 @@
372
378
  </div>
373
379
 
374
380
  {#if isExpanded}
375
- <ul
376
- class="mt-1 space-y-1 pl-4 overflow-hidden"
381
+ <!-- Submenu panel: an inset grey surface at the top level so open children
382
+ read as separate from the main list. Deeper levels get a left rail
383
+ instead, so the grey never stacks darker -->
384
+ <div
385
+ class={cn(
386
+ 'mt-1 overflow-hidden',
387
+ !nested && 'ml-3 rounded-md p-1',
388
+ !nested && (isLight ? 'bg-muted/50' : 'bg-sidebar-accent/30')
389
+ )}
377
390
  transition:slide={{ duration: sidebarStore.animate ? 200 : 0 }}
378
391
  >
379
- {#each item.children ?? [] as child (child.id)}
380
- <li>
381
- {#if child.children?.length}
382
- <!-- A nested category: same expandable row, one level deeper -->
383
- <SidebarNavItem
384
- item={child}
385
- {isLight}
386
- {isMobile}
387
- {icon}
388
- {searchQuery}
389
- {onNavigate}
390
- {autoCollapse}
391
- siblingIds={expandableChildIds}
392
- />
393
- {:else}
394
- <a
395
- href={child.disabled ? undefined : child.href}
396
- class={cn(
397
- 'flex min-w-0 items-center gap-3 rounded-md px-3 py-2 text-sm font-medium',
398
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1',
399
- getItemStateClasses(child.active, child.disabled)
400
- )}
401
- target={child.external ? '_blank' : undefined}
402
- rel={child.external ? 'noopener noreferrer' : undefined}
403
- aria-current={child.active ? 'page' : undefined}
404
- aria-disabled={child.disabled || undefined}
405
- tabindex={child.disabled ? -1 : undefined}
406
- onclick={(e) => {
407
- if (child.disabled) {
408
- e.preventDefault();
409
- return;
410
- }
411
- onNavigate?.(child);
412
- }}
413
- >
414
- {@render navIcon(child)}
415
- {@render highlightedName(child.name, highlightText(child.name, searchQuery))}
416
- {@render navBadge(child.badge)}
417
- {#if child.external}{@render externalIndicator()}{/if}
418
- </a>
419
- {/if}
420
- </li>
421
- {/each}
422
- </ul>
392
+ <ul class={cn('space-y-1', nested && 'ml-3 border-l border-outline/40 pl-1')}>
393
+ {#each item.children ?? [] as child (child.id)}
394
+ <li>
395
+ {#if child.children?.length}
396
+ <!-- A nested category: same expandable row, one level deeper -->
397
+ <SidebarNavItem
398
+ item={child}
399
+ {isLight}
400
+ {isMobile}
401
+ {icon}
402
+ {searchQuery}
403
+ {onNavigate}
404
+ {autoCollapse}
405
+ siblingIds={expandableChildIds}
406
+ nested
407
+ />
408
+ {:else}
409
+ <a
410
+ href={child.disabled ? undefined : child.href}
411
+ class={cn(
412
+ 'flex min-w-0 items-center gap-3 rounded-md px-3 py-2 text-sm font-medium',
413
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1',
414
+ getItemStateClasses(child.active, child.disabled)
415
+ )}
416
+ target={child.external ? '_blank' : undefined}
417
+ rel={child.external ? 'noopener noreferrer' : undefined}
418
+ aria-current={child.active ? 'page' : undefined}
419
+ aria-disabled={child.disabled || undefined}
420
+ tabindex={child.disabled ? -1 : undefined}
421
+ onclick={(e) => {
422
+ if (child.disabled) {
423
+ e.preventDefault();
424
+ return;
425
+ }
426
+ onNavigate?.(child);
427
+ }}
428
+ >
429
+ {@render navIcon(child)}
430
+ {@render highlightedName(child.name, highlightText(child.name, searchQuery))}
431
+ {@render navBadge(child.badge)}
432
+ {#if child.external}{@render externalIndicator()}{/if}
433
+ </a>
434
+ {/if}
435
+ </li>
436
+ {/each}
437
+ </ul>
438
+ </div>
423
439
  {/if}
424
440
  </div>
425
441
  {:else}
@@ -428,9 +444,12 @@
428
444
  <div
429
445
  class={cn(
430
446
  'group flex w-full items-center rounded-md',
431
- isLight && !item.active && 'bg-background hover:bg-accent',
447
+ // Inside a section panel rows sit on the panel's grey, so no rest fill
448
+ isLight && !item.active && (nested ? 'bg-transparent' : 'bg-background'),
449
+ isLight && !item.active && 'hover:bg-accent',
432
450
  isLight && item.active && 'bg-primary/10',
433
- !isLight && !item.active && 'bg-sidebar hover:bg-sidebar-accent',
451
+ !isLight && !item.active && (nested ? 'bg-transparent' : 'bg-sidebar'),
452
+ !isLight && !item.active && 'hover:bg-sidebar-accent',
434
453
  !isLight && item.active && 'bg-sidebar-primary'
435
454
  )}
436
455
  >
@@ -32,6 +32,8 @@ interface Props {
32
32
  autoCollapse?: boolean;
33
33
  /** IDs of expandable items alongside this one */
34
34
  siblingIds?: string[];
35
+ /** Rendered inside another item's submenu panel (internal) */
36
+ nested?: boolean;
35
37
  }
36
38
  declare const SidebarNavItem: import("svelte").Component<Props, {}, "">;
37
39
  type SidebarNavItem = ReturnType<typeof SidebarNavItem>;
@@ -145,32 +145,39 @@
145
145
  {/each}
146
146
  </ul>
147
147
  {:else if isExpanded}
148
- <!-- Collapsible and expanded: animate -->
149
- <ul
150
- class="space-y-1 px-2 overflow-hidden"
151
- id={`sidebar-section-${section.id}`}
148
+ <!-- Collapsible and expanded: the same inset grey panel as an open submenu
149
+ (SidebarNavItem), so a section's pages read as inside it. Its items are
150
+ `nested`: no rest fill over the grey, and their own submenus get the rail -->
151
+ <div
152
+ class={cn(
153
+ 'mx-2 overflow-hidden rounded-md p-1',
154
+ isLight ? 'bg-muted/50' : 'bg-sidebar-accent/30'
155
+ )}
152
156
  transition:slide={{ duration: sidebarStore.animate ? 200 : 0 }}
153
157
  >
154
- {#each section.items as item}
155
- <li>
156
- <SidebarNavItem
157
- {item}
158
- {isLight}
159
- {collapsed}
160
- {isMobile}
161
- {icon}
162
- {searchQuery}
163
- {enablePinning}
164
- {pinIcon}
165
- {isPinnedSection}
166
- {onNavigate}
167
- onMouseEnter={onItemMouseEnter}
168
- onMouseLeave={onItemMouseLeave}
169
- {autoCollapse}
170
- siblingIds={expandableItemIds}
171
- />
172
- </li>
173
- {/each}
174
- </ul>
158
+ <ul class="space-y-1" id={`sidebar-section-${section.id}`}>
159
+ {#each section.items as item}
160
+ <li>
161
+ <SidebarNavItem
162
+ {item}
163
+ {isLight}
164
+ {collapsed}
165
+ {isMobile}
166
+ {icon}
167
+ {searchQuery}
168
+ {enablePinning}
169
+ {pinIcon}
170
+ {isPinnedSection}
171
+ {onNavigate}
172
+ onMouseEnter={onItemMouseEnter}
173
+ onMouseLeave={onItemMouseLeave}
174
+ {autoCollapse}
175
+ siblingIds={expandableItemIds}
176
+ nested
177
+ />
178
+ </li>
179
+ {/each}
180
+ </ul>
181
+ </div>
175
182
  {/if}
176
183
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "1.22.2",
3
+ "version": "1.22.4",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",