@bjj/nuxt-layer-shadcn-ui 0.12.16 → 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.
@@ -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>
@@ -0,0 +1,4 @@
1
+ {
2
+ "collapseSidebar": "Collapse sidebar",
3
+ "expandSidebar": "Expand sidebar"
4
+ }
@@ -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: 'Demo User', subtitle: 'demo@example.com' },
81
- { type: 'action', label: 'Account', icon: 'badge-check', command: () => {} },
82
- { type: 'action', label: 'Billing', icon: 'credit-card', command: () => {} },
83
- { type: 'action', label: 'Notifications', icon: 'bell', command: () => {} },
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 #navbar-left>
95
- <Breadcrumb :model="breadcrumb" />
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
- headerDropdown: { control: 'object' },
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
- headerDropdown: undefined,
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, Avatar, Breadcrumb, Button, Card },
180
+ components: { AdminLayout, Button, Card },
165
181
  setup () {
166
- const breadcrumb = [
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 Navbar from './Navbar.vue'
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
- headerDropdown: undefined,
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
- 'default'?: () => any
26
- 'header'?: () => any
27
- 'footer'?: () => any
28
- 'navbar-left'?: () => any
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
- <SidebarDropdown
46
- v-if="headerDropdown"
47
- :profile="headerDropdown.profile"
48
- :menuItems="headerDropdown.menuItems"
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
- <SidebarInset class="min-w-0">
71
- <Navbar>
72
- <div class="gap-3 flex flex-1 items-center">
73
- <slot name="navbar-left" />
74
- </div>
75
- <div class="gap-3 flex items-center">
76
- <slot name="navbar-right" />
77
- </div>
78
- </Navbar>
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
- headerDropdown?: AdminLayoutSidebarDropdownConfig
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'
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "طي الشريط الجانبي",
32
+ "expandSidebar": "توسيع الشريط الجانبي"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "الإجراءات",
32
36
  "loadFailed": "فشل التحميل"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Seitenleiste einklappen",
32
+ "expandSidebar": "Seitenleiste aufklappen"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Aktionen",
32
36
  "loadFailed": "Fehler beim Laden"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Collapse sidebar",
32
+ "expandSidebar": "Expand sidebar"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Actions",
32
36
  "loadFailed": "Failed to load"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Contraer barra lateral",
32
+ "expandSidebar": "Expandir barra lateral"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Acciones",
32
36
  "loadFailed": "No se pudo cargar"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Réduire la barre latérale",
32
+ "expandSidebar": "Développer la barre latérale"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Actions",
32
36
  "loadFailed": "Échec du chargement"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "साइडबार को संक्षिप्त करें",
32
+ "expandSidebar": "साइडबार को विस्तार करें"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "क्रियाएं",
32
36
  "loadFailed": "लोड करने में विफल"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Sembunyikan bilah samping",
32
+ "expandSidebar": "Tampilkan bilah samping"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Tindakan",
32
36
  "loadFailed": "Gagal memuat"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Comprimi barra laterale",
32
+ "expandSidebar": "Espandi barra laterale"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Azioni",
32
36
  "loadFailed": "Caricamento non riuscito"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "サイドバーを閉じる",
32
+ "expandSidebar": "サイドバーを開く"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "アクション",
32
36
  "loadFailed": "読み込みに失敗しました"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "사이드바 축소",
32
+ "expandSidebar": "사이드바 확장"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "작업",
32
36
  "loadFailed": "로드 실패"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Samenvouwen",
32
+ "expandSidebar": "Uitvouwen"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Acties",
32
36
  "loadFailed": "Laden mislukt"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Zwiń pasek boczny",
32
+ "expandSidebar": "Rozwiń pasek boczny"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Akcje",
32
36
  "loadFailed": "Nie udało się załadować"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Recolher barra lateral",
32
+ "expandSidebar": "Expandir barra lateral"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Ações",
32
36
  "loadFailed": "Falha ao carregar"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Свернуть боковую панель",
32
+ "expandSidebar": "Развернуть боковую панель"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Действия",
32
36
  "loadFailed": "Ошибка загрузки"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "ยุบแถบด้านข้าง",
32
+ "expandSidebar": "ขยายแถบด้านข้าง"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "การกระทำ",
32
36
  "loadFailed": "ไม่สามารถโหลดได้"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Kenar çubuğunu daralt",
32
+ "expandSidebar": "Kenar çubuğunu genişlet"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "İşlemler",
32
36
  "loadFailed": "Yüklenemedi"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "Thu gọn thanh bên",
32
+ "expandSidebar": "Mở rộng thanh bên"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "Hành động",
32
36
  "loadFailed": "Không thể tải"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "折叠侧边栏",
32
+ "expandSidebar": "展开侧边栏"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "操作",
32
36
  "loadFailed": "加载失败"
@@ -27,6 +27,10 @@
27
27
  },
28
28
  "components": {
29
29
  "ui": {
30
+ "AdminLayout": {
31
+ "collapseSidebar": "收起側邊欄",
32
+ "expandSidebar": "展開側邊欄"
33
+ },
30
34
  "AsyncDataTable": {
31
35
  "actions": "操作",
32
36
  "loadFailed": "載入失敗"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.12.16",
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": "e4a930eee97e686f984f1970ec4cb4e6baec363e"
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>