@bjj/nuxt-layer-shadcn-ui 0.12.15 → 0.13.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/SidebarBrand.vue +80 -0
- package/app/components/ui/AdminLayout/en.json +4 -0
- package/app/components/ui/AdminLayout/index.stories.ts +53 -21
- package/app/components/ui/AdminLayout/index.vue +28 -21
- package/app/components/ui/AdminLayout/types.ts +2 -1
- package/app/components/ui/DataTable/index.vue +9 -3
- 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
- package/app/components/ui/AdminLayout/Navbar.vue +0 -35
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { SidebarTrigger, useSidebar } from '../../shadcn/sidebar'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
/** Brand name shown next to the logo. Hidden while the sidebar is collapsed. */
|
|
6
|
+
brandName?: string
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
defineSlots<{
|
|
10
|
+
/** Brand logo/mark. Shown in every state; on a collapsed sidebar it is
|
|
11
|
+
replaced by the collapse toggle on hover. */
|
|
12
|
+
logo?: () => any
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const { state } = useSidebar()
|
|
16
|
+
const T = useTranslations('components.ui.AdminLayout')
|
|
17
|
+
|
|
18
|
+
// The trigger toggles the sidebar, so its label reflects the resulting action.
|
|
19
|
+
const toggleLabel = computed(() =>
|
|
20
|
+
state.value === 'collapsed' ? T('expandSidebar') : T('collapseSidebar'),
|
|
21
|
+
)
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<!--
|
|
26
|
+
Brand row. Expanded: [logo + name] on the left, collapse toggle on the right.
|
|
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
|
+
-->
|
|
32
|
+
<div
|
|
33
|
+
class="
|
|
34
|
+
group/brand h-8 gap-2 relative flex items-center
|
|
35
|
+
group-data-[collapsible=icon]:justify-center
|
|
36
|
+
"
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
class="
|
|
40
|
+
min-w-0 gap-2 flex flex-1 items-center
|
|
41
|
+
group-data-[collapsible=icon]:flex-none
|
|
42
|
+
"
|
|
43
|
+
>
|
|
44
|
+
<span
|
|
45
|
+
class="
|
|
46
|
+
size-8 flex shrink-0 items-center justify-center transition-opacity
|
|
47
|
+
group-data-[collapsible=icon]:group-hover/brand:opacity-0
|
|
48
|
+
"
|
|
49
|
+
>
|
|
50
|
+
<slot name="logo" />
|
|
51
|
+
</span>
|
|
52
|
+
<span
|
|
53
|
+
v-if="brandName"
|
|
54
|
+
class="
|
|
55
|
+
text-base font-semibold truncate
|
|
56
|
+
group-data-[collapsible=icon]:hidden
|
|
57
|
+
"
|
|
58
|
+
>
|
|
59
|
+
{{ brandName }}
|
|
60
|
+
</span>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<Tooltip
|
|
64
|
+
:text="toggleLabel"
|
|
65
|
+
position="right"
|
|
66
|
+
>
|
|
67
|
+
<SidebarTrigger
|
|
68
|
+
class="
|
|
69
|
+
text-muted-foreground
|
|
70
|
+
group-data-[collapsible=icon]:inset-0
|
|
71
|
+
shrink-0 cursor-pointer transition-opacity
|
|
72
|
+
group-data-[collapsible=icon]:absolute
|
|
73
|
+
group-data-[collapsible=icon]:m-auto
|
|
74
|
+
group-data-[collapsible=icon]:opacity-0
|
|
75
|
+
group-data-[collapsible=icon]:group-hover/brand:opacity-100
|
|
76
|
+
"
|
|
77
|
+
/>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
2
|
import type { AdminLayoutSidebarDropdownProfile, AdminLayoutSidebarMenuItem, AdminLayoutSidebarDropdownMenuItem } from './types'
|
|
3
3
|
import AdminLayout from './index.vue'
|
|
4
|
-
import Avatar from '../Avatar/index.vue'
|
|
5
|
-
import Breadcrumb from '../Breadcrumb/index.vue'
|
|
6
4
|
import Button from '../Button/index.vue'
|
|
7
5
|
import Card from '../Card/index.vue'
|
|
8
6
|
|
|
@@ -76,11 +74,34 @@ const menus: AdminLayoutSidebarMenuItem[] = [
|
|
|
76
74
|
},
|
|
77
75
|
]
|
|
78
76
|
|
|
77
|
+
// Footer dropdown: the trigger shows the signed-in user; the workspace/org info
|
|
78
|
+
// and preference sub-menus live inside the menu.
|
|
79
79
|
const menuItems: AdminLayoutSidebarDropdownMenuItem[] = [
|
|
80
|
-
{ type: 'profile', title: '
|
|
81
|
-
{ type: 'action', label: '
|
|
82
|
-
{ type: '
|
|
83
|
-
{ type: '
|
|
80
|
+
{ type: 'profile', icon: 'building-2', title: 'Acme Inc.', subtitle: 'Owner' },
|
|
81
|
+
{ type: 'action', label: 'Switch Workspace', icon: 'arrow-left-right', command: () => {} },
|
|
82
|
+
{ type: 'separator' },
|
|
83
|
+
{ type: 'label', label: 'Account' },
|
|
84
|
+
{ type: 'action', label: 'Change Password', icon: 'lock-keyhole', command: () => {} },
|
|
85
|
+
{ type: 'separator' },
|
|
86
|
+
{
|
|
87
|
+
type: 'action',
|
|
88
|
+
label: 'Language',
|
|
89
|
+
icon: 'languages',
|
|
90
|
+
subMenus: [
|
|
91
|
+
{ label: 'English', active: true, command: () => {} },
|
|
92
|
+
{ label: '日本語', command: () => {} },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'action',
|
|
97
|
+
label: 'Theme',
|
|
98
|
+
icon: 'sun-moon',
|
|
99
|
+
subMenus: [
|
|
100
|
+
{ label: 'Light', icon: 'sun', active: true, command: () => {} },
|
|
101
|
+
{ label: 'System', icon: 'monitor', command: () => {} },
|
|
102
|
+
{ label: 'Dark', icon: 'moon', command: () => {} },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
84
105
|
{ type: 'separator' },
|
|
85
106
|
{ type: 'action', label: 'Sign Out', icon: 'log-out', command: () => {} },
|
|
86
107
|
]
|
|
@@ -91,13 +112,8 @@ const profile: AdminLayoutSidebarDropdownProfile = {
|
|
|
91
112
|
}
|
|
92
113
|
|
|
93
114
|
const layoutContent = `
|
|
94
|
-
<template #
|
|
95
|
-
<
|
|
96
|
-
</template>
|
|
97
|
-
<template #navbar-right>
|
|
98
|
-
<Button variant="ghost" size="icon" icon="search" aria-label="Search" />
|
|
99
|
-
<Button variant="ghost" size="icon" icon="bell" aria-label="Notifications" />
|
|
100
|
-
<Avatar label="DU" size="small" />
|
|
115
|
+
<template #logo>
|
|
116
|
+
<div class="flex size-7 items-center justify-center rounded-md bg-primary text-sm font-bold text-primary-foreground">A</div>
|
|
101
117
|
</template>
|
|
102
118
|
|
|
103
119
|
<div class="space-y-6 p-6">
|
|
@@ -148,26 +164,22 @@ const meta = {
|
|
|
148
164
|
component: AdminLayout,
|
|
149
165
|
argTypes: {
|
|
150
166
|
menus: { control: 'object' },
|
|
151
|
-
|
|
167
|
+
brandName: { control: 'text' },
|
|
152
168
|
footerDropdown: { control: 'object' },
|
|
153
169
|
variant: { control: 'select', options: variants },
|
|
154
170
|
collapsible: { control: 'select', options: collapsibles },
|
|
155
171
|
},
|
|
156
172
|
args: {
|
|
157
173
|
menus,
|
|
158
|
-
|
|
174
|
+
brandName: 'Acme Inc.',
|
|
159
175
|
footerDropdown: { profile, menuItems },
|
|
160
176
|
variant: 'sidebar',
|
|
161
177
|
collapsible: 'icon',
|
|
162
178
|
},
|
|
163
179
|
render: args => ({
|
|
164
|
-
components: { AdminLayout,
|
|
180
|
+
components: { AdminLayout, Button, Card },
|
|
165
181
|
setup () {
|
|
166
|
-
|
|
167
|
-
{ label: 'Dashboard', href: '#' },
|
|
168
|
-
{ label: 'Overview' },
|
|
169
|
-
]
|
|
170
|
-
return { args, breadcrumb }
|
|
182
|
+
return { args }
|
|
171
183
|
},
|
|
172
184
|
template: `<AdminLayout v-bind="args">${layoutContent}</AdminLayout>`,
|
|
173
185
|
}),
|
|
@@ -206,3 +218,23 @@ export const Inset: Story = {
|
|
|
206
218
|
variant: 'inset',
|
|
207
219
|
},
|
|
208
220
|
}
|
|
221
|
+
|
|
222
|
+
// Pins the canvas to a phone viewport so the sidebar collapses into the mobile
|
|
223
|
+
// drawer and the floating trigger (top-left) becomes the way to open it.
|
|
224
|
+
export const Mobile: Story = {
|
|
225
|
+
parameters: {
|
|
226
|
+
...noControls,
|
|
227
|
+
viewport: {
|
|
228
|
+
options: {
|
|
229
|
+
mobile: {
|
|
230
|
+
name: 'Mobile',
|
|
231
|
+
styles: { width: '390px', height: '844px' },
|
|
232
|
+
type: 'mobile',
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
globals: {
|
|
238
|
+
viewport: { value: 'mobile', isRotated: false },
|
|
239
|
+
},
|
|
240
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { AdminLayoutProps } from './types'
|
|
3
|
-
import
|
|
3
|
+
import SidebarBrand from './SidebarBrand.vue'
|
|
4
4
|
import SidebarDropdown from './SidebarDropdown.vue'
|
|
5
5
|
import SidebarMenus from './SidebarMenus.vue'
|
|
6
6
|
import {
|
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
SidebarInset,
|
|
12
12
|
SidebarProvider,
|
|
13
13
|
SidebarRail,
|
|
14
|
+
SidebarTrigger,
|
|
14
15
|
} from '../../shadcn/sidebar'
|
|
15
16
|
|
|
16
17
|
const props = withDefaults(defineProps<AdminLayoutProps>(), {
|
|
17
|
-
|
|
18
|
+
brandName: undefined,
|
|
18
19
|
footerDropdown: undefined,
|
|
19
20
|
variant: 'sidebar',
|
|
20
21
|
collapsible: 'icon',
|
|
@@ -22,11 +23,10 @@ const props = withDefaults(defineProps<AdminLayoutProps>(), {
|
|
|
22
23
|
})
|
|
23
24
|
|
|
24
25
|
defineSlots<{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'navbar-right'?: () => any
|
|
26
|
+
default?: () => any
|
|
27
|
+
header?: () => any
|
|
28
|
+
footer?: () => any
|
|
29
|
+
logo?: () => any
|
|
30
30
|
}>()
|
|
31
31
|
|
|
32
32
|
const mergedContentClass = computed(() =>
|
|
@@ -42,11 +42,11 @@ const mergedContentClass = computed(() =>
|
|
|
42
42
|
>
|
|
43
43
|
<SidebarHeader>
|
|
44
44
|
<slot name="header">
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
<SidebarBrand :brandName="brandName">
|
|
46
|
+
<template #logo>
|
|
47
|
+
<slot name="logo" />
|
|
48
|
+
</template>
|
|
49
|
+
</SidebarBrand>
|
|
50
50
|
</slot>
|
|
51
51
|
</SidebarHeader>
|
|
52
52
|
|
|
@@ -67,15 +67,22 @@ const mergedContentClass = computed(() =>
|
|
|
67
67
|
<SidebarRail />
|
|
68
68
|
</Sidebar>
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
/>
|
|
79
86
|
|
|
80
87
|
<div :class="mergedContentClass">
|
|
81
88
|
<slot />
|
|
@@ -36,7 +36,8 @@ export interface AdminLayoutSidebarDropdownConfig {
|
|
|
36
36
|
|
|
37
37
|
export interface AdminLayoutProps {
|
|
38
38
|
menus: AdminLayoutSidebarMenuItem[]
|
|
39
|
-
|
|
39
|
+
/** Brand name shown next to the logo in the sidebar header (hidden when collapsed). */
|
|
40
|
+
brandName?: string
|
|
40
41
|
footerDropdown?: AdminLayoutSidebarDropdownConfig
|
|
41
42
|
variant?: 'sidebar' | 'floating' | 'inset'
|
|
42
43
|
collapsible?: 'offcanvas' | 'icon' | 'none'
|
|
@@ -275,6 +275,7 @@ const headerCellClass = 'h-auto bg-border px-4 py-3 text-xs font-normal text-for
|
|
|
275
275
|
const headerDividerClass = 'relative after:absolute after:top-1/2 after:right-0 after:h-4 after:w-px after:-translate-y-1/2 after:bg-muted-foreground/25'
|
|
276
276
|
const stickyLeftClass = 'sticky left-0 z-10'
|
|
277
277
|
const emptyCellClass = 'h-0.5 w-2.5 bg-muted-foreground/50 inline-block rounded-full align-middle'
|
|
278
|
+
const footerViewportClass = 'sticky left-0 box-border w-[100cqw] px-4 py-2'
|
|
278
279
|
|
|
279
280
|
const selectionColumnClass = '[&:has([role=checkbox])]:pr-4'
|
|
280
281
|
const selectionColumnStyle = { width: '1%' }
|
|
@@ -291,7 +292,10 @@ defineExpose({
|
|
|
291
292
|
<template>
|
|
292
293
|
<div
|
|
293
294
|
:class="cn(
|
|
294
|
-
|
|
295
|
+
`
|
|
296
|
+
rounded-lg bg-border px-1 text-foreground @container relative
|
|
297
|
+
overflow-hidden
|
|
298
|
+
`,
|
|
295
299
|
!$slots.footer && 'pb-1',
|
|
296
300
|
height && 'has-sticky-bounds',
|
|
297
301
|
)"
|
|
@@ -505,9 +509,11 @@ defineExpose({
|
|
|
505
509
|
<TableRow>
|
|
506
510
|
<TableCell
|
|
507
511
|
:colspan="totalColumns"
|
|
508
|
-
class="bg-border"
|
|
512
|
+
class="bg-border p-0!"
|
|
509
513
|
>
|
|
510
|
-
<
|
|
514
|
+
<div :class="footerViewportClass">
|
|
515
|
+
<slot name="footer" />
|
|
516
|
+
</div>
|
|
511
517
|
</TableCell>
|
|
512
518
|
</TableRow>
|
|
513
519
|
</TableFooter>
|
package/i18n/messages/ar.json
CHANGED
package/i18n/messages/de.json
CHANGED
package/i18n/messages/en.json
CHANGED
package/i18n/messages/es.json
CHANGED
package/i18n/messages/fr.json
CHANGED
package/i18n/messages/hi.json
CHANGED
package/i18n/messages/id.json
CHANGED
package/i18n/messages/it.json
CHANGED
package/i18n/messages/ja.json
CHANGED
package/i18n/messages/ko.json
CHANGED
package/i18n/messages/nl.json
CHANGED
package/i18n/messages/pl.json
CHANGED
package/i18n/messages/pt.json
CHANGED
package/i18n/messages/ru.json
CHANGED
package/i18n/messages/th.json
CHANGED
package/i18n/messages/tr.json
CHANGED
package/i18n/messages/vi.json
CHANGED
package/i18n/messages/zh-CN.json
CHANGED
package/i18n/messages/zh-TW.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bjj/nuxt-layer-shadcn-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
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": "0d12f77334178f14b18add16ee1b99d04c392007"
|
|
46
46
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { SidebarTrigger } from '../../shadcn/sidebar'
|
|
3
|
-
|
|
4
|
-
const props = defineProps<{
|
|
5
|
-
class?: ClassValue
|
|
6
|
-
}>()
|
|
7
|
-
|
|
8
|
-
defineSlots<{
|
|
9
|
-
default?: () => any
|
|
10
|
-
}>()
|
|
11
|
-
|
|
12
|
-
const mergedClass = computed(() =>
|
|
13
|
-
cn(
|
|
14
|
-
`
|
|
15
|
-
h-14 gap-3 border-sidebar-border bg-card px-4 text-card-foreground
|
|
16
|
-
group-has-data-[collapsible=icon]/sidebar-wrapper:h-12
|
|
17
|
-
flex shrink-0 items-center border-b transition-[width,height] ease-linear
|
|
18
|
-
`,
|
|
19
|
-
props.class,
|
|
20
|
-
),
|
|
21
|
-
)
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<template>
|
|
25
|
-
<header :class="mergedClass">
|
|
26
|
-
<SidebarTrigger class="-mx-1" />
|
|
27
|
-
<Divider
|
|
28
|
-
type="vertical"
|
|
29
|
-
class="h-4!"
|
|
30
|
-
/>
|
|
31
|
-
<div class="flex flex-1 items-center">
|
|
32
|
-
<slot />
|
|
33
|
-
</div>
|
|
34
|
-
</header>
|
|
35
|
-
</template>
|