@bjj/nuxt-layer-shadcn-ui 0.14.0 → 0.15.0
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/app/components/ui/AdminLayout/index.vue +29 -70
- package/app/components/ui/AdminLayout/types.ts +2 -10
- package/app/components/ui/{AdminLayout → SidebarLayout}/SidebarMenus.vue +46 -56
- package/app/components/ui/SidebarLayout/index.stories.ts +274 -0
- package/app/components/ui/SidebarLayout/index.vue +141 -0
- package/app/components/ui/SidebarLayout/types.ts +31 -0
- package/app/components/ui/SidebarLayout/utils.ts +29 -0
- package/app/components/ui/SidebarModal/en.json +4 -0
- package/app/components/ui/SidebarModal/index.stories.ts +368 -0
- package/app/components/ui/SidebarModal/index.vue +218 -0
- package/app/components/ui/SidebarModal/types.ts +26 -0
- package/i18n/messages/ar.json +4 -0
- package/i18n/messages/de.json +4 -0
- package/i18n/messages/en.json +4 -0
- package/i18n/messages/es.json +4 -0
- package/i18n/messages/fr.json +4 -0
- package/i18n/messages/hi.json +4 -0
- package/i18n/messages/id.json +4 -0
- package/i18n/messages/it.json +4 -0
- package/i18n/messages/ja.json +4 -0
- package/i18n/messages/ko.json +4 -0
- package/i18n/messages/nl.json +4 -0
- package/i18n/messages/pl.json +4 -0
- package/i18n/messages/pt.json +4 -0
- package/i18n/messages/ru.json +4 -0
- package/i18n/messages/th.json +4 -0
- package/i18n/messages/tr.json +4 -0
- package/i18n/messages/vi.json +4 -0
- package/i18n/messages/zh-CN.json +4 -0
- package/i18n/messages/zh-TW.json +4 -0
- package/package.json +2 -2
|
@@ -2,19 +2,8 @@
|
|
|
2
2
|
import type { AdminLayoutProps } from './types'
|
|
3
3
|
import SidebarBrand from './SidebarBrand.vue'
|
|
4
4
|
import SidebarDropdown from './SidebarDropdown.vue'
|
|
5
|
-
import SidebarMenus from './SidebarMenus.vue'
|
|
6
|
-
import {
|
|
7
|
-
Sidebar,
|
|
8
|
-
SidebarContent,
|
|
9
|
-
SidebarFooter,
|
|
10
|
-
SidebarHeader,
|
|
11
|
-
SidebarInset,
|
|
12
|
-
SidebarProvider,
|
|
13
|
-
SidebarRail,
|
|
14
|
-
SidebarTrigger,
|
|
15
|
-
} from '../../shadcn/sidebar'
|
|
16
5
|
|
|
17
|
-
|
|
6
|
+
withDefaults(defineProps<AdminLayoutProps>(), {
|
|
18
7
|
brandName: undefined,
|
|
19
8
|
footerDropdown: undefined,
|
|
20
9
|
variant: 'sidebar',
|
|
@@ -28,65 +17,35 @@ defineSlots<{
|
|
|
28
17
|
footer?: () => any
|
|
29
18
|
logo?: () => any
|
|
30
19
|
}>()
|
|
31
|
-
|
|
32
|
-
const mergedContentClass = computed(() =>
|
|
33
|
-
cn('flex-1 overflow-auto', props.contentClass),
|
|
34
|
-
)
|
|
35
20
|
</script>
|
|
36
21
|
|
|
37
22
|
<template>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
</
|
|
50
|
-
</
|
|
51
|
-
</
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<SidebarRail />
|
|
68
|
-
</Sidebar>
|
|
69
|
-
|
|
70
|
-
<!-- Top padding on mobile reserves a safe area for the floating trigger. -->
|
|
71
|
-
<SidebarInset
|
|
72
|
-
class="
|
|
73
|
-
min-w-0 pt-14
|
|
74
|
-
md:pt-0
|
|
75
|
-
"
|
|
76
|
-
>
|
|
77
|
-
<!-- Mobile-only trigger: the desktop toggle lives in the sidebar header. -->
|
|
78
|
-
<SidebarTrigger
|
|
79
|
-
class="
|
|
80
|
-
left-3 top-3 size-9 rounded-md bg-background/80 shadow-sm
|
|
81
|
-
backdrop-blur-sm
|
|
82
|
-
md:hidden
|
|
83
|
-
absolute z-30 cursor-pointer border
|
|
84
|
-
"
|
|
85
|
-
/>
|
|
86
|
-
|
|
87
|
-
<div :class="mergedContentClass">
|
|
88
|
-
<slot />
|
|
89
|
-
</div>
|
|
90
|
-
</SidebarInset>
|
|
91
|
-
</SidebarProvider>
|
|
23
|
+
<SidebarLayout
|
|
24
|
+
:menus="menus"
|
|
25
|
+
:variant="variant"
|
|
26
|
+
:collapsible="collapsible"
|
|
27
|
+
:contentClass="contentClass"
|
|
28
|
+
>
|
|
29
|
+
<template #header>
|
|
30
|
+
<slot name="header">
|
|
31
|
+
<SidebarBrand :brandName="brandName">
|
|
32
|
+
<template #logo>
|
|
33
|
+
<slot name="logo" />
|
|
34
|
+
</template>
|
|
35
|
+
</SidebarBrand>
|
|
36
|
+
</slot>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template #footer>
|
|
40
|
+
<slot name="footer">
|
|
41
|
+
<SidebarDropdown
|
|
42
|
+
v-if="footerDropdown"
|
|
43
|
+
:profile="footerDropdown.profile"
|
|
44
|
+
:menuItems="footerDropdown.menuItems"
|
|
45
|
+
/>
|
|
46
|
+
</slot>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<slot />
|
|
50
|
+
</SidebarLayout>
|
|
92
51
|
</template>
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { Component } from 'vue'
|
|
2
2
|
import type { DropdownItem } from '../Dropdown/types'
|
|
3
|
+
import type { SidebarLayoutMenuItem } from '../SidebarLayout/types'
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
-
label: string
|
|
6
|
-
icon?: string | Component
|
|
7
|
-
href?: string
|
|
8
|
-
command?: () => void
|
|
9
|
-
group?: string
|
|
10
|
-
expanded?: boolean
|
|
11
|
-
children?: AdminLayoutSidebarMenuItem[]
|
|
12
|
-
actions?: AdminLayoutSidebarMenuItem[]
|
|
13
|
-
}
|
|
5
|
+
export type AdminLayoutSidebarMenuItem = SidebarLayoutMenuItem
|
|
14
6
|
|
|
15
7
|
export interface AdminLayoutSidebarDropdownProfile {
|
|
16
8
|
title?: string
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SidebarLayoutMenuItem } from './types'
|
|
3
|
+
import { sidebarMenuItemKey } from './utils'
|
|
3
4
|
import {
|
|
4
5
|
Collapsible,
|
|
5
6
|
CollapsibleContent,
|
|
@@ -24,7 +25,14 @@ import {
|
|
|
24
25
|
} from '../../shadcn/sidebar'
|
|
25
26
|
|
|
26
27
|
const props = defineProps<{
|
|
27
|
-
menus:
|
|
28
|
+
menus: SidebarLayoutMenuItem[]
|
|
29
|
+
/** Key of the selected item. Omitted → the active item is matched by route. */
|
|
30
|
+
active?: string
|
|
31
|
+
emptyText?: string
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
select: [item: SidebarLayoutMenuItem]
|
|
28
36
|
}>()
|
|
29
37
|
|
|
30
38
|
const route = useRoute()
|
|
@@ -32,13 +40,13 @@ const route = useRoute()
|
|
|
32
40
|
const isExternal = (href: string) => /^https?:\/\//.test(href)
|
|
33
41
|
|
|
34
42
|
const navGroups = computed(() => {
|
|
35
|
-
const groups: { label?: string, items:
|
|
36
|
-
const groupMap = new Map<string | undefined,
|
|
43
|
+
const groups: { label?: string, items: SidebarLayoutMenuItem[] }[] = []
|
|
44
|
+
const groupMap = new Map<string | undefined, SidebarLayoutMenuItem[]>()
|
|
37
45
|
|
|
38
46
|
for (const item of props.menus) {
|
|
39
47
|
const key = item.group
|
|
40
48
|
if (!groupMap.has(key)) {
|
|
41
|
-
const items:
|
|
49
|
+
const items: SidebarLayoutMenuItem[] = []
|
|
42
50
|
groupMap.set(key, items)
|
|
43
51
|
groups.push({ label: key, items })
|
|
44
52
|
}
|
|
@@ -48,17 +56,25 @@ const navGroups = computed(() => {
|
|
|
48
56
|
return groups
|
|
49
57
|
})
|
|
50
58
|
|
|
51
|
-
function isActive (
|
|
59
|
+
function isActive (item: SidebarLayoutMenuItem): boolean {
|
|
60
|
+
if (props.active !== undefined) return sidebarMenuItemKey(item) === props.active
|
|
61
|
+
const href = item.href
|
|
52
62
|
if (!href || isExternal(href)) return false
|
|
53
63
|
return route.path.startsWith(href)
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
function isLink (item:
|
|
66
|
+
function isLink (item: SidebarLayoutMenuItem): boolean {
|
|
57
67
|
return !!item.href
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
function hasActiveChild (item:
|
|
61
|
-
return item.children?.some(
|
|
70
|
+
function hasActiveChild (item: SidebarLayoutMenuItem): boolean {
|
|
71
|
+
return item.children?.some(isActive) ?? false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// A linked item navigates through its `WebLink`, so `command` is for the rest.
|
|
75
|
+
function handleSelect (item: SidebarLayoutMenuItem) {
|
|
76
|
+
emit('select', item)
|
|
77
|
+
if (!isLink(item)) item.command?.()
|
|
62
78
|
}
|
|
63
79
|
</script>
|
|
64
80
|
|
|
@@ -73,11 +89,11 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
73
89
|
<SidebarMenu>
|
|
74
90
|
<template
|
|
75
91
|
v-for="item in group.items"
|
|
76
|
-
:key="item
|
|
92
|
+
:key="sidebarMenuItemKey(item)"
|
|
77
93
|
>
|
|
78
94
|
<!-- Collapsible item with children -->
|
|
79
95
|
<Collapsible
|
|
80
|
-
v-if="item.children"
|
|
96
|
+
v-if="item.children?.length"
|
|
81
97
|
asChild
|
|
82
98
|
:defaultOpen="item.expanded ?? hasActiveChild(item)"
|
|
83
99
|
class="group/collapsible"
|
|
@@ -103,18 +119,20 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
103
119
|
<SidebarMenuSub>
|
|
104
120
|
<SidebarMenuSubItem
|
|
105
121
|
v-for="child in item.children"
|
|
106
|
-
:key="child
|
|
122
|
+
:key="sidebarMenuItemKey(child)"
|
|
107
123
|
>
|
|
108
124
|
<!-- The vendored sub-button renders `data-active=""` when active while its
|
|
109
125
|
built-in styles only match `data-active="true"`, so the active styles
|
|
110
126
|
are re-applied here via an attribute-presence selector. -->
|
|
111
127
|
<SidebarMenuSubButton
|
|
112
128
|
:asChild="isLink(child)"
|
|
113
|
-
:isActive="isActive(child
|
|
129
|
+
:isActive="isActive(child)"
|
|
114
130
|
class="
|
|
115
131
|
data-active:bg-sidebar-accent
|
|
116
132
|
data-active:text-sidebar-accent-foreground
|
|
133
|
+
cursor-pointer
|
|
117
134
|
"
|
|
135
|
+
@click="handleSelect(child)"
|
|
118
136
|
>
|
|
119
137
|
<WebLink
|
|
120
138
|
v-if="isLink(child)"
|
|
@@ -123,10 +141,7 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
123
141
|
>
|
|
124
142
|
<span>{{ child.label }}</span>
|
|
125
143
|
</WebLink>
|
|
126
|
-
<span
|
|
127
|
-
v-else
|
|
128
|
-
@click="child.command?.()"
|
|
129
|
-
>
|
|
144
|
+
<span v-else>
|
|
130
145
|
{{ child.label }}
|
|
131
146
|
</span>
|
|
132
147
|
</SidebarMenuSubButton>
|
|
@@ -136,13 +151,14 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
136
151
|
</SidebarMenuItem>
|
|
137
152
|
</Collapsible>
|
|
138
153
|
|
|
139
|
-
<!--
|
|
140
|
-
<SidebarMenuItem v-else
|
|
154
|
+
<!-- Leaf item, optionally with an actions dropdown -->
|
|
155
|
+
<SidebarMenuItem v-else>
|
|
141
156
|
<SidebarMenuButton
|
|
142
157
|
:asChild="isLink(item)"
|
|
143
|
-
:isActive="isActive(item
|
|
158
|
+
:isActive="isActive(item)"
|
|
144
159
|
:tooltip="item.label"
|
|
145
|
-
|
|
160
|
+
class="cursor-pointer"
|
|
161
|
+
@click="handleSelect(item)"
|
|
146
162
|
>
|
|
147
163
|
<WebLink
|
|
148
164
|
v-if="isLink(item)"
|
|
@@ -168,7 +184,8 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
168
184
|
<span>{{ item.label }}</span>
|
|
169
185
|
</template>
|
|
170
186
|
</SidebarMenuButton>
|
|
171
|
-
|
|
187
|
+
|
|
188
|
+
<DropdownMenu v-if="item.actions">
|
|
172
189
|
<DropdownMenuTrigger asChild>
|
|
173
190
|
<SidebarMenuAction showOnHover>
|
|
174
191
|
<Icon name="ellipsis" />
|
|
@@ -209,41 +226,14 @@ function hasActiveChild (item: AdminLayoutSidebarMenuItem): boolean {
|
|
|
209
226
|
</DropdownMenuContent>
|
|
210
227
|
</DropdownMenu>
|
|
211
228
|
</SidebarMenuItem>
|
|
212
|
-
|
|
213
|
-
<!-- Simple item -->
|
|
214
|
-
<SidebarMenuItem v-else>
|
|
215
|
-
<SidebarMenuButton
|
|
216
|
-
:asChild="isLink(item)"
|
|
217
|
-
:isActive="isActive(item.href)"
|
|
218
|
-
:tooltip="item.label"
|
|
219
|
-
@click="!isLink(item) ? item.command?.() : undefined"
|
|
220
|
-
>
|
|
221
|
-
<WebLink
|
|
222
|
-
v-if="isLink(item)"
|
|
223
|
-
:href="item.href"
|
|
224
|
-
unstyled
|
|
225
|
-
>
|
|
226
|
-
<Icon
|
|
227
|
-
v-if="item.icon"
|
|
228
|
-
:name="item.icon"
|
|
229
|
-
/>
|
|
230
|
-
<span>{{ item.label }}</span>
|
|
231
|
-
<Icon
|
|
232
|
-
v-if="isExternal(item.href!)"
|
|
233
|
-
name="external-link"
|
|
234
|
-
class="size-3.5 text-sidebar-foreground/50 ml-auto"
|
|
235
|
-
/>
|
|
236
|
-
</WebLink>
|
|
237
|
-
<template v-else>
|
|
238
|
-
<Icon
|
|
239
|
-
v-if="item.icon"
|
|
240
|
-
:name="item.icon"
|
|
241
|
-
/>
|
|
242
|
-
<span>{{ item.label }}</span>
|
|
243
|
-
</template>
|
|
244
|
-
</SidebarMenuButton>
|
|
245
|
-
</SidebarMenuItem>
|
|
246
229
|
</template>
|
|
247
230
|
</SidebarMenu>
|
|
248
231
|
</SidebarGroup>
|
|
232
|
+
|
|
233
|
+
<div
|
|
234
|
+
v-if="emptyText && !navGroups.length"
|
|
235
|
+
class="px-2 py-6 text-sm text-muted-foreground text-center"
|
|
236
|
+
>
|
|
237
|
+
{{ emptyText }}
|
|
238
|
+
</div>
|
|
249
239
|
</template>
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import type { SidebarLayoutMenuItem } from './types'
|
|
3
|
+
import EventLog from '#storybook/EventLog.vue'
|
|
4
|
+
import { useArgsModel } from '#storybook/argsModel'
|
|
5
|
+
import Button from '../Button/index.vue'
|
|
6
|
+
import SidebarLayout from './index.vue'
|
|
7
|
+
|
|
8
|
+
const variants = [ 'sidebar', 'floating', 'inset' ] as const
|
|
9
|
+
const collapsibles = [ 'icon', 'offcanvas', 'none' ] as const
|
|
10
|
+
|
|
11
|
+
const menus: SidebarLayoutMenuItem[] = [
|
|
12
|
+
{ key: 'general', label: 'General', icon: 'settings', group: 'Settings' },
|
|
13
|
+
{ key: 'account', label: 'Account', icon: 'circle-user', group: 'Settings' },
|
|
14
|
+
{ key: 'usage', label: 'Usage', icon: 'chart-column', group: 'Settings' },
|
|
15
|
+
{ key: 'appearance', label: 'Appearance', icon: 'monitor', group: 'Customize' },
|
|
16
|
+
{ key: 'connectors', label: 'Connectors', icon: 'plug', group: 'Customize' },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
const nestedMenus: SidebarLayoutMenuItem[] = [
|
|
20
|
+
{ key: 'overview', label: 'Overview', icon: 'layout-dashboard' },
|
|
21
|
+
{
|
|
22
|
+
label: 'Documentation',
|
|
23
|
+
icon: 'book-open',
|
|
24
|
+
group: 'Platform',
|
|
25
|
+
expanded: true,
|
|
26
|
+
children: [
|
|
27
|
+
{ key: 'intro', label: 'Introduction' },
|
|
28
|
+
{ key: 'tutorials', label: 'Tutorials' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: 'design',
|
|
33
|
+
label: 'Design Engineering',
|
|
34
|
+
icon: 'frame',
|
|
35
|
+
group: 'Projects',
|
|
36
|
+
actions: [
|
|
37
|
+
{ label: 'Share Project', icon: 'forward', command: () => {} },
|
|
38
|
+
{ label: 'Delete Project', icon: 'trash-2', command: () => {} },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
const paneTemplate = `
|
|
44
|
+
<div class="space-y-3">
|
|
45
|
+
<h2 class="text-lg font-semibold">{{ active || 'No selection' }}</h2>
|
|
46
|
+
<p class="text-sm text-muted-foreground">
|
|
47
|
+
The layout owns the menu and its active state; this pane comes from the default slot.
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
const brandTemplate = `
|
|
53
|
+
<template #header>
|
|
54
|
+
<div class="truncate px-2 py-1 text-base font-semibold group-data-[collapsible=icon]:hidden">Acme Inc.</div>
|
|
55
|
+
</template>
|
|
56
|
+
`
|
|
57
|
+
|
|
58
|
+
const meta = {
|
|
59
|
+
title: 'UI/SidebarLayout',
|
|
60
|
+
component: SidebarLayout,
|
|
61
|
+
argTypes: {
|
|
62
|
+
menus: { control: 'object' },
|
|
63
|
+
active: { control: 'text' },
|
|
64
|
+
emptyText: { control: 'text' },
|
|
65
|
+
embedded: { control: 'boolean' },
|
|
66
|
+
variant: { control: 'select', options: variants },
|
|
67
|
+
collapsible: { control: 'select', options: collapsibles },
|
|
68
|
+
sidebarWidth: { control: 'text' },
|
|
69
|
+
contentClass: { control: 'text' },
|
|
70
|
+
},
|
|
71
|
+
args: {
|
|
72
|
+
menus,
|
|
73
|
+
active: 'general',
|
|
74
|
+
emptyText: '',
|
|
75
|
+
embedded: false,
|
|
76
|
+
variant: 'sidebar',
|
|
77
|
+
collapsible: 'icon',
|
|
78
|
+
sidebarWidth: '16rem',
|
|
79
|
+
contentClass: 'p-6',
|
|
80
|
+
},
|
|
81
|
+
render: args => {
|
|
82
|
+
const onUpdateActive = useArgsModel('active')
|
|
83
|
+
return {
|
|
84
|
+
components: { SidebarLayout },
|
|
85
|
+
// The Docs page only round-trips the primary story's args, so selection is
|
|
86
|
+
// mirrored locally to stay clickable there, and pushed back to Controls.
|
|
87
|
+
setup () {
|
|
88
|
+
const active = ref(args.active)
|
|
89
|
+
watch(() => args.active, key => {
|
|
90
|
+
active.value = key
|
|
91
|
+
})
|
|
92
|
+
function onSelect (key: string) {
|
|
93
|
+
active.value = key
|
|
94
|
+
onUpdateActive(key)
|
|
95
|
+
}
|
|
96
|
+
return { args, active, onSelect }
|
|
97
|
+
},
|
|
98
|
+
template: `
|
|
99
|
+
<SidebarLayout
|
|
100
|
+
v-bind="args"
|
|
101
|
+
:active="active"
|
|
102
|
+
@update:active="onSelect"
|
|
103
|
+
>
|
|
104
|
+
${brandTemplate}
|
|
105
|
+
${paneTemplate}
|
|
106
|
+
</SidebarLayout>
|
|
107
|
+
`,
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
// The page-mode sidebar is `position: fixed`; pin it to the preview frame so it
|
|
111
|
+
// does not stretch across the whole Storybook viewport. `[data-state]` keeps the
|
|
112
|
+
// selector off an embedded sidebar, whose last child is its own footer.
|
|
113
|
+
decorators: [
|
|
114
|
+
() => ({
|
|
115
|
+
template: `
|
|
116
|
+
<div
|
|
117
|
+
class="relative h-[600px] overflow-hidden rounded-lg border border-border
|
|
118
|
+
[&_[data-slot=sidebar][data-state]>div:last-child]:absolute!
|
|
119
|
+
[&_[data-slot=sidebar][data-state]>div:last-child]:h-full!"
|
|
120
|
+
>
|
|
121
|
+
<story />
|
|
122
|
+
</div>
|
|
123
|
+
`,
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
} satisfies Meta<typeof SidebarLayout>
|
|
127
|
+
|
|
128
|
+
export default meta
|
|
129
|
+
type Story = StoryObj<typeof meta>
|
|
130
|
+
|
|
131
|
+
const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
132
|
+
|
|
133
|
+
export const Default: Story = {}
|
|
134
|
+
|
|
135
|
+
export const Floating: Story = {
|
|
136
|
+
parameters: noControls,
|
|
137
|
+
args: {
|
|
138
|
+
variant: 'floating',
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const Inset: Story = {
|
|
143
|
+
parameters: noControls,
|
|
144
|
+
args: {
|
|
145
|
+
variant: 'inset',
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const Offcanvas: Story = {
|
|
150
|
+
parameters: noControls,
|
|
151
|
+
args: {
|
|
152
|
+
collapsible: 'offcanvas',
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const Embedded: Story = {
|
|
157
|
+
parameters: noControls,
|
|
158
|
+
args: {
|
|
159
|
+
embedded: true,
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const SidebarWidth: Story = {
|
|
164
|
+
parameters: noControls,
|
|
165
|
+
args: {
|
|
166
|
+
embedded: true,
|
|
167
|
+
sidebarWidth: '11rem',
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export const NestedMenus: Story = {
|
|
172
|
+
parameters: noControls,
|
|
173
|
+
args: {
|
|
174
|
+
embedded: true,
|
|
175
|
+
menus: nestedMenus,
|
|
176
|
+
active: 'intro',
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const EmptyText: Story = {
|
|
181
|
+
parameters: noControls,
|
|
182
|
+
args: {
|
|
183
|
+
embedded: true,
|
|
184
|
+
menus: [],
|
|
185
|
+
emptyText: 'No results',
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const SidebarFooter: Story = {
|
|
190
|
+
parameters: {
|
|
191
|
+
...noControls,
|
|
192
|
+
docs: {
|
|
193
|
+
source: {
|
|
194
|
+
code: `
|
|
195
|
+
<template>
|
|
196
|
+
<SidebarLayout
|
|
197
|
+
v-model:active="active"
|
|
198
|
+
embedded
|
|
199
|
+
:menus="menus"
|
|
200
|
+
contentClass="p-6"
|
|
201
|
+
>
|
|
202
|
+
<template #header>
|
|
203
|
+
<div class="px-2 py-1 text-base font-semibold">Acme Inc.</div>
|
|
204
|
+
</template>
|
|
205
|
+
|
|
206
|
+
<template #footer>
|
|
207
|
+
<Button
|
|
208
|
+
variant="ghost"
|
|
209
|
+
icon="log-out"
|
|
210
|
+
class="justify-start"
|
|
211
|
+
>
|
|
212
|
+
Sign out
|
|
213
|
+
</Button>
|
|
214
|
+
</template>
|
|
215
|
+
|
|
216
|
+
<div class="text-sm text-muted-foreground">Pane for {{ active }}</div>
|
|
217
|
+
</SidebarLayout>
|
|
218
|
+
</template>
|
|
219
|
+
`.trim(),
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
render: () => ({
|
|
224
|
+
components: { SidebarLayout, Button },
|
|
225
|
+
setup () {
|
|
226
|
+
const active = ref('general')
|
|
227
|
+
return { active, menus }
|
|
228
|
+
},
|
|
229
|
+
template: `
|
|
230
|
+
<SidebarLayout
|
|
231
|
+
v-model:active="active"
|
|
232
|
+
embedded
|
|
233
|
+
:menus="menus"
|
|
234
|
+
contentClass="p-6"
|
|
235
|
+
>
|
|
236
|
+
<template #header>
|
|
237
|
+
<div class="px-2 py-1 text-base font-semibold">Acme Inc.</div>
|
|
238
|
+
</template>
|
|
239
|
+
|
|
240
|
+
<template #footer>
|
|
241
|
+
<Button variant="ghost" icon="log-out" class="justify-start">Sign out</Button>
|
|
242
|
+
</template>
|
|
243
|
+
|
|
244
|
+
<div class="text-sm text-muted-foreground">Pane for {{ active }}</div>
|
|
245
|
+
</SidebarLayout>
|
|
246
|
+
`,
|
|
247
|
+
}),
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export const EventHandling: Story = {
|
|
251
|
+
parameters: noControls,
|
|
252
|
+
render: () => ({
|
|
253
|
+
components: { SidebarLayout, EventLog },
|
|
254
|
+
setup () {
|
|
255
|
+
const active = ref('general')
|
|
256
|
+
return { active, menus }
|
|
257
|
+
},
|
|
258
|
+
template: `
|
|
259
|
+
<EventLog v-slot="{ record }">
|
|
260
|
+
<SidebarLayout
|
|
261
|
+
v-model:active="active"
|
|
262
|
+
embedded
|
|
263
|
+
:menus="menus"
|
|
264
|
+
contentClass="p-6"
|
|
265
|
+
class="h-80"
|
|
266
|
+
@select="(item) => record('select', item.label)"
|
|
267
|
+
@update:active="(key) => record('update:active', key)"
|
|
268
|
+
>
|
|
269
|
+
<div class="text-sm text-muted-foreground">Pick a menu item to log its events.</div>
|
|
270
|
+
</SidebarLayout>
|
|
271
|
+
</EventLog>
|
|
272
|
+
`,
|
|
273
|
+
}),
|
|
274
|
+
}
|