@bjj/nuxt-layer-shadcn-ui 0.13.0 → 0.13.2
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.
|
@@ -7,8 +7,7 @@ defineProps<{
|
|
|
7
7
|
}>()
|
|
8
8
|
|
|
9
9
|
defineSlots<{
|
|
10
|
-
/** Brand logo/mark.
|
|
11
|
-
replaced by the collapse toggle on hover. */
|
|
10
|
+
/** Brand logo/mark. */
|
|
12
11
|
logo?: () => any
|
|
13
12
|
}>()
|
|
14
13
|
|
|
@@ -22,13 +21,8 @@ const toggleLabel = computed(() =>
|
|
|
22
21
|
</script>
|
|
23
22
|
|
|
24
23
|
<template>
|
|
25
|
-
<!--
|
|
26
|
-
|
|
27
|
-
Collapsed (`data-collapsible=icon` on the sidebar root): only the logo shows,
|
|
28
|
-
centered; hovering the row swaps it for the toggle so the sidebar can be
|
|
29
|
-
re-expanded. The toggle keeps capturing clicks even while transparent, so a
|
|
30
|
-
click anywhere on the collapsed brand expands the sidebar.
|
|
31
|
-
-->
|
|
24
|
+
<!-- Collapsed: only the logo shows; hovering swaps it for the toggle (which
|
|
25
|
+
stays clickable while transparent, so the whole row re-expands). -->
|
|
32
26
|
<div
|
|
33
27
|
class="
|
|
34
28
|
group/brand h-8 gap-2 relative flex items-center
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { AdminLayoutSidebarDropdownProfile, AdminLayoutSidebarDropdownMenuItem } from './types'
|
|
3
|
-
import { ChevronsUpDown } from 'lucide-vue-next'
|
|
4
3
|
import {
|
|
5
4
|
SidebarMenu,
|
|
6
5
|
SidebarMenuButton,
|
|
@@ -15,13 +14,15 @@ const props = defineProps<{
|
|
|
15
14
|
|
|
16
15
|
const { isMobile } = useSidebar()
|
|
17
16
|
|
|
18
|
-
//
|
|
19
|
-
//
|
|
17
|
+
// 'profile' items render through the 'profile' slot: clickable (`custom-action`,
|
|
18
|
+
// padding reset so the slot owns it) when it has a `command`, else a label.
|
|
20
19
|
const dropdownItems = computed<DropdownItem[]>(() =>
|
|
21
20
|
(props.menuItems ?? []).map(item => {
|
|
22
21
|
if (item.type === 'profile') {
|
|
23
|
-
const { type: _, ...rest } = item
|
|
24
|
-
return
|
|
22
|
+
const { type: _, command, ...rest } = item
|
|
23
|
+
return command
|
|
24
|
+
? { type: 'custom-action', slot: 'profile', command, ...rest, class: 'p-0' }
|
|
25
|
+
: { type: 'custom-label', slot: 'profile', ...rest }
|
|
25
26
|
}
|
|
26
27
|
return item
|
|
27
28
|
}),
|
|
@@ -58,19 +59,25 @@ const dropdownItems = computed<DropdownItem[]>(() =>
|
|
|
58
59
|
class="size-4"
|
|
59
60
|
/>
|
|
60
61
|
</Avatar>
|
|
61
|
-
<div class="grid flex-1 text-left
|
|
62
|
-
<span class="
|
|
62
|
+
<div class="text-sm/tight grid flex-1 text-left">
|
|
63
|
+
<span class="font-medium truncate">
|
|
63
64
|
{{ profile?.title }}
|
|
64
65
|
</span>
|
|
65
|
-
<span class="
|
|
66
|
+
<span class="text-xs truncate">
|
|
66
67
|
{{ profile?.subtitle }}
|
|
67
68
|
</span>
|
|
68
69
|
</div>
|
|
69
|
-
<
|
|
70
|
+
<Icon
|
|
71
|
+
v-if="profile?.actionIcon"
|
|
72
|
+
:name="profile.actionIcon"
|
|
73
|
+
class="size-4 ml-auto shrink-0"
|
|
74
|
+
/>
|
|
70
75
|
</SidebarMenuButton>
|
|
71
76
|
|
|
72
77
|
<template #profile="{ item }">
|
|
73
|
-
<div
|
|
78
|
+
<div
|
|
79
|
+
class="gap-2 px-1 py-1.5 text-sm flex w-full items-center text-left"
|
|
80
|
+
>
|
|
74
81
|
<Avatar
|
|
75
82
|
:image="item.icon ? undefined : (item.image || undefined)"
|
|
76
83
|
:fallbackLabel="item.icon ? undefined : item.title?.charAt(0)?.toUpperCase()"
|
|
@@ -83,17 +90,22 @@ const dropdownItems = computed<DropdownItem[]>(() =>
|
|
|
83
90
|
class="size-4"
|
|
84
91
|
/>
|
|
85
92
|
</Avatar>
|
|
86
|
-
<div class="grid flex-1 text-left
|
|
87
|
-
<span class="
|
|
93
|
+
<div class="text-sm/tight grid flex-1 text-left">
|
|
94
|
+
<span class="font-semibold truncate">
|
|
88
95
|
{{ item.title }}
|
|
89
96
|
</span>
|
|
90
97
|
<span
|
|
91
98
|
v-if="item.subtitle"
|
|
92
|
-
class="
|
|
99
|
+
class="text-xs truncate"
|
|
93
100
|
>
|
|
94
101
|
{{ item.subtitle }}
|
|
95
102
|
</span>
|
|
96
103
|
</div>
|
|
104
|
+
<Icon
|
|
105
|
+
v-if="item.command && item.actionIcon"
|
|
106
|
+
:name="item.actionIcon"
|
|
107
|
+
class="size-4 text-muted-foreground ml-auto shrink-0"
|
|
108
|
+
/>
|
|
97
109
|
</div>
|
|
98
110
|
</template>
|
|
99
111
|
</Dropdown>
|
|
@@ -75,12 +75,11 @@ const menus: AdminLayoutSidebarMenuItem[] = [
|
|
|
75
75
|
]
|
|
76
76
|
|
|
77
77
|
// Footer dropdown: the trigger shows the signed-in user; the workspace/org info
|
|
78
|
-
// and preference sub-menus live inside the menu.
|
|
78
|
+
// and preference sub-menus live inside the menu. The profile item carries a
|
|
79
|
+
// `command`, so it is clickable (opens a workspace switcher).
|
|
79
80
|
const menuItems: AdminLayoutSidebarDropdownMenuItem[] = [
|
|
80
|
-
{ type: 'profile', icon: 'building-2', title: 'Acme Inc.', subtitle: 'Owner' },
|
|
81
|
-
{ type: 'action', label: 'Switch Workspace', icon: 'arrow-left-right', command: () => {} },
|
|
81
|
+
{ type: 'profile', icon: 'building-2', title: 'Acme Inc.', subtitle: 'Owner', command: () => {}, actionIcon: 'arrow-left-right' },
|
|
82
82
|
{ type: 'separator' },
|
|
83
|
-
{ type: 'label', label: 'Account' },
|
|
84
83
|
{ type: 'action', label: 'Change Password', icon: 'lock-keyhole', command: () => {} },
|
|
85
84
|
{ type: 'separator' },
|
|
86
85
|
{
|
|
@@ -109,6 +108,7 @@ const menuItems: AdminLayoutSidebarDropdownMenuItem[] = [
|
|
|
109
108
|
const profile: AdminLayoutSidebarDropdownProfile = {
|
|
110
109
|
title: 'Demo User',
|
|
111
110
|
subtitle: 'demo@example.com',
|
|
111
|
+
actionIcon: 'chevrons-up-down',
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
const layoutContent = `
|
|
@@ -17,17 +17,18 @@ export interface AdminLayoutSidebarDropdownProfile {
|
|
|
17
17
|
subtitle?: string
|
|
18
18
|
icon?: string | Component
|
|
19
19
|
image?: string
|
|
20
|
+
/** Trailing affordance icon (lucide name or component). Omitted → not rendered. */
|
|
21
|
+
actionIcon?: string | Component
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* a profile header (avatar + title + subtitle) as a label inside the menu.
|
|
25
|
+
* A DropdownItem, or a 'profile' variant rendering an avatar + title + subtitle.
|
|
26
|
+
* With a `command` the profile is clickable (shows its `actionIcon`); without,
|
|
27
|
+
* it is a static label.
|
|
27
28
|
*/
|
|
28
29
|
export type AdminLayoutSidebarDropdownMenuItem
|
|
29
30
|
= | DropdownItem
|
|
30
|
-
| ({ type: 'profile' } & AdminLayoutSidebarDropdownProfile)
|
|
31
|
+
| ({ type: 'profile', command?: () => void } & AdminLayoutSidebarDropdownProfile)
|
|
31
32
|
|
|
32
33
|
export interface AdminLayoutSidebarDropdownConfig {
|
|
33
34
|
profile?: AdminLayoutSidebarDropdownProfile | null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bjj/nuxt-layer-shadcn-ui",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Nuxt layer providing shadcn-vue based UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"vue-i18n": "^11",
|
|
43
43
|
"vue-router": "^4 || ^5"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "d58825867361704b209b34458f063c28f8af47c3"
|
|
46
46
|
}
|