@functionalcms/svelte-components 5.12.1 → 5.12.3
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.
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
uiHelpers,
|
|
14
14
|
SidebarBrand
|
|
15
15
|
} from 'flowbite-svelte';
|
|
16
|
+
import { OutlinedIcons } from '../icons.js';
|
|
16
17
|
|
|
17
18
|
interface TwoColumnLayoutProps {
|
|
18
19
|
children: Snippet;
|
|
@@ -34,6 +35,9 @@
|
|
|
34
35
|
|
|
35
36
|
let container: HTMLElement | undefined = undefined;
|
|
36
37
|
const helpers = uiHelpers();
|
|
38
|
+
let isCollapsed = $state(false);
|
|
39
|
+
let icon = $derived(isCollapsed ? OutlinedIcons.ChevronDoubleRight : OutlinedIcons.ChevronDoubleLeft);
|
|
40
|
+
|
|
37
41
|
afterNavigate(() => {
|
|
38
42
|
window.scrollTo({ top: 0, behavior: 'instant' });
|
|
39
43
|
});
|
|
@@ -47,30 +51,51 @@
|
|
|
47
51
|
isOpen={helpers.isOpen}
|
|
48
52
|
closeSidebar={helpers.close}
|
|
49
53
|
position={sidebarPosition}
|
|
50
|
-
class="z-50 h-full"
|
|
54
|
+
class="z-50 h-full transition-all duration-300 {isCollapsed ? 'w-16' : 'w-64'}"
|
|
51
55
|
>
|
|
52
56
|
<SidebarGroup>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{#each menuItems as item}
|
|
57
|
-
{#if 'items' in item}
|
|
58
|
-
<SidebarDropdownWrapper label={item.label}>
|
|
59
|
-
{#each item.items as subItem}
|
|
60
|
-
<SidebarDropdownItem label={subItem.label} href={subItem.href} />
|
|
61
|
-
{/each}
|
|
62
|
-
</SidebarDropdownWrapper>
|
|
63
|
-
{:else}
|
|
64
|
-
<SidebarItem label={item.label} href={item.href}>
|
|
65
|
-
{#snippet icon()}
|
|
66
|
-
<Icon icon={item.icon} />
|
|
67
|
-
{/snippet}
|
|
68
|
-
</SidebarItem>
|
|
57
|
+
<div class="mb-4 flex items-center justify-between px-2">
|
|
58
|
+
{#if logo && !isCollapsed}
|
|
59
|
+
<SidebarBrand site={logo} classes={{ img: 'h-6 w-6' }} />
|
|
69
60
|
{/if}
|
|
70
|
-
|
|
61
|
+
<button
|
|
62
|
+
onclick={() => (isCollapsed = !isCollapsed)}
|
|
63
|
+
class="rounded-lg p-2 hover:bg-gray-100 dark:hover:bg-gray-700"
|
|
64
|
+
title={isCollapsed ? 'Expand menu' : 'Collapse menu'}
|
|
65
|
+
>
|
|
66
|
+
<Icon icon={icon} />
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
{#if !isCollapsed}
|
|
70
|
+
{#each menuItems as item}
|
|
71
|
+
{#if 'items' in item}
|
|
72
|
+
<SidebarDropdownWrapper label={item.label}>
|
|
73
|
+
{#each item.items as subItem}
|
|
74
|
+
<SidebarDropdownItem label={subItem.label} href={subItem.href} />
|
|
75
|
+
{/each}
|
|
76
|
+
</SidebarDropdownWrapper>
|
|
77
|
+
{:else}
|
|
78
|
+
<SidebarItem label={item.label} href={item.href}>
|
|
79
|
+
{#snippet icon()}
|
|
80
|
+
<Icon icon={item.icon} />
|
|
81
|
+
{/snippet}
|
|
82
|
+
</SidebarItem>
|
|
83
|
+
{/if}
|
|
84
|
+
{/each}
|
|
85
|
+
{:else}
|
|
86
|
+
{#each menuItems as item}
|
|
87
|
+
{#if !('items' in item)}
|
|
88
|
+
<SidebarItem label="" href={item.href} class="justify-center" title={item.label}>
|
|
89
|
+
{#snippet icon()}
|
|
90
|
+
<Icon icon={item.icon} />
|
|
91
|
+
{/snippet}
|
|
92
|
+
</SidebarItem>
|
|
93
|
+
{/if}
|
|
94
|
+
{/each}
|
|
95
|
+
{/if}
|
|
71
96
|
</SidebarGroup>
|
|
72
97
|
</Sidebar>
|
|
73
|
-
<div class="content h-full overflow-auto px-4 md:ml-64" style:flex="1">
|
|
98
|
+
<div class="content h-full overflow-auto px-4 transition-all duration-300 {isCollapsed ? 'md:ml-16' : 'md:ml-64'}" style:flex="1">
|
|
74
99
|
{@render children?.()}
|
|
75
100
|
</div>
|
|
76
101
|
</main>
|