@classic-homes/theme-svelte 0.1.13 → 0.1.14
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/lib/components/layout/Sidebar.svelte +15 -3
- package/dist/lib/components/layout/sidebar/SidebarFlyout.svelte +34 -8
- package/dist/lib/components/layout/sidebar/SidebarFlyout.svelte.d.ts +2 -0
- package/dist/lib/components/layout/sidebar/SidebarNavItem.svelte +2 -1
- package/package.json +1 -1
|
@@ -149,7 +149,8 @@
|
|
|
149
149
|
|
|
150
150
|
// Variant-based styling
|
|
151
151
|
const isLight = $derived(variant === 'light');
|
|
152
|
-
|
|
152
|
+
// Use the actual width props instead of hardcoded Tailwind classes
|
|
153
|
+
const currentWidth = $derived(collapsed ? collapsedWidth : expandedWidth);
|
|
153
154
|
|
|
154
155
|
// Track previous search to avoid redundant updates
|
|
155
156
|
let prevSearchQuery = '';
|
|
@@ -365,12 +366,22 @@
|
|
|
365
366
|
// Variant-based background and text colors
|
|
366
367
|
isLight ? 'bg-background text-foreground' : 'bg-sidebar text-sidebar-foreground',
|
|
367
368
|
strongBorder ? 'border-r-2 border-black' : 'border-r border-black',
|
|
368
|
-
isMobile
|
|
369
|
+
isMobile && !mobileOpen && '-translate-x-full',
|
|
369
370
|
// Disable transition during swipe for smooth following
|
|
370
371
|
isSwiping && 'transition-none',
|
|
371
372
|
className
|
|
372
373
|
)}
|
|
373
|
-
style={
|
|
374
|
+
style={(() => {
|
|
375
|
+
const styles: string[] = [];
|
|
376
|
+
// Apply width - use expandedWidth for mobile, respect collapsed state for desktop
|
|
377
|
+
const width = isMobile ? expandedWidth : currentWidth;
|
|
378
|
+
styles.push(`width: ${width}px`);
|
|
379
|
+
// Apply swipe transform if swiping
|
|
380
|
+
if (isSwiping && swipeOffset < 0) {
|
|
381
|
+
styles.push(`transform: translateX(${swipeOffset}px)`);
|
|
382
|
+
}
|
|
383
|
+
return styles.join('; ');
|
|
384
|
+
})()}
|
|
374
385
|
aria-label="Main navigation"
|
|
375
386
|
ontouchstart={handleTouchStart}
|
|
376
387
|
ontouchmove={handleTouchMove}
|
|
@@ -495,6 +506,7 @@
|
|
|
495
506
|
<SidebarFlyout
|
|
496
507
|
item={hoveredFlyoutItem}
|
|
497
508
|
top={flyoutTop}
|
|
509
|
+
left={collapsedWidth}
|
|
498
510
|
{isLight}
|
|
499
511
|
onNavigate={handleNavigate}
|
|
500
512
|
onMouseEnter={handleFlyoutMouseEnter}
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
item: NavItem;
|
|
14
14
|
/** Top position in pixels */
|
|
15
15
|
top: number;
|
|
16
|
+
/** Left position in pixels (sidebar width) */
|
|
17
|
+
left?: number;
|
|
16
18
|
/** Whether using light variant */
|
|
17
19
|
isLight?: boolean;
|
|
18
20
|
/** Callback when a navigation item is clicked */
|
|
@@ -23,7 +25,15 @@
|
|
|
23
25
|
onMouseLeave?: () => void;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
let {
|
|
28
|
+
let {
|
|
29
|
+
item,
|
|
30
|
+
top,
|
|
31
|
+
left = 64,
|
|
32
|
+
isLight = true,
|
|
33
|
+
onNavigate,
|
|
34
|
+
onMouseEnter,
|
|
35
|
+
onMouseLeave,
|
|
36
|
+
}: Props = $props();
|
|
27
37
|
|
|
28
38
|
let flyoutElement = $state<HTMLElement | null>(null);
|
|
29
39
|
|
|
@@ -99,11 +109,11 @@
|
|
|
99
109
|
<div
|
|
100
110
|
bind:this={flyoutElement}
|
|
101
111
|
class={cn(
|
|
102
|
-
'fixed
|
|
112
|
+
'fixed min-w-48 rounded-md border shadow-lg z-[calc(var(--z-sidebar,50)+10)]',
|
|
103
113
|
'motion-reduce:transition-none',
|
|
104
114
|
isLight ? 'bg-background border-border' : 'bg-sidebar border-sidebar-foreground/20'
|
|
105
115
|
)}
|
|
106
|
-
style="top: {top}px;"
|
|
116
|
+
style="top: {top}px; left: {left}px;"
|
|
107
117
|
role="menu"
|
|
108
118
|
tabindex="0"
|
|
109
119
|
onmouseenter={onMouseEnter}
|
|
@@ -112,20 +122,28 @@
|
|
|
112
122
|
transition:fly={{ x: -10, duration: 150 }}
|
|
113
123
|
>
|
|
114
124
|
<div class="p-2">
|
|
115
|
-
<!-- Item name as header -->
|
|
125
|
+
<!-- Item name as header - always clickable unless disabled -->
|
|
116
126
|
<div
|
|
117
127
|
class={cn(
|
|
118
128
|
'px-3 py-2 text-sm font-medium',
|
|
119
129
|
isLight ? 'text-foreground' : 'text-sidebar-foreground'
|
|
120
130
|
)}
|
|
121
131
|
>
|
|
122
|
-
{#if item.
|
|
132
|
+
{#if item.disabled}
|
|
133
|
+
<span class="opacity-50 cursor-not-allowed">
|
|
134
|
+
{item.name}
|
|
135
|
+
</span>
|
|
136
|
+
{:else if item.href}
|
|
123
137
|
<a
|
|
124
138
|
href={item.href}
|
|
125
|
-
class=
|
|
139
|
+
class={cn(
|
|
140
|
+
'hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 rounded',
|
|
141
|
+
'cursor-pointer'
|
|
142
|
+
)}
|
|
126
143
|
target={item.external ? '_blank' : undefined}
|
|
127
144
|
rel={item.external ? 'noopener noreferrer' : undefined}
|
|
128
145
|
onclick={() => onNavigate?.(item)}
|
|
146
|
+
role="menuitem"
|
|
129
147
|
>
|
|
130
148
|
{item.name}
|
|
131
149
|
{#if item.external}
|
|
@@ -133,9 +151,17 @@
|
|
|
133
151
|
{/if}
|
|
134
152
|
</a>
|
|
135
153
|
{:else}
|
|
136
|
-
<
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
class={cn(
|
|
157
|
+
'hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 rounded',
|
|
158
|
+
'cursor-pointer text-left bg-transparent border-none p-0 font-medium text-inherit'
|
|
159
|
+
)}
|
|
160
|
+
onclick={() => onNavigate?.(item)}
|
|
161
|
+
role="menuitem"
|
|
162
|
+
>
|
|
137
163
|
{item.name}
|
|
138
|
-
</
|
|
164
|
+
</button>
|
|
139
165
|
{/if}
|
|
140
166
|
</div>
|
|
141
167
|
|
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
{/if}
|
|
343
343
|
</a>
|
|
344
344
|
{:else}
|
|
345
|
-
<!-- Item without href (parent with children only, or
|
|
345
|
+
<!-- Item without href (parent with children only, or action button) - render as button -->
|
|
346
346
|
<button
|
|
347
347
|
type="button"
|
|
348
348
|
class={cn(
|
|
@@ -355,6 +355,7 @@
|
|
|
355
355
|
aria-haspopup={hasChildren ? 'menu' : undefined}
|
|
356
356
|
aria-disabled={item.disabled || undefined}
|
|
357
357
|
disabled={item.disabled}
|
|
358
|
+
onclick={handleClick}
|
|
358
359
|
onmouseenter={handleMouseEnter}
|
|
359
360
|
onmouseleave={onMouseLeave}
|
|
360
361
|
>
|