@olwiba/ui 0.0.34 → 0.0.35
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/dist/index.d.ts +3 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/app/AppShell.tsx +29 -5
package/package.json
CHANGED
package/src/app/AppShell.tsx
CHANGED
|
@@ -89,6 +89,8 @@ export interface AppShellProps {
|
|
|
89
89
|
pageTitle?: string;
|
|
90
90
|
/** Slot rendered at the start of the top header bar, after the sidebar trigger. */
|
|
91
91
|
headerStart?: ReactNode;
|
|
92
|
+
/** Slot rendered at the end of the top header bar. */
|
|
93
|
+
headerEnd?: ReactNode;
|
|
92
94
|
/** Override link rendering for SPA navigation. Defaults to a native <a>. */
|
|
93
95
|
renderLink?: AppShellRenderLink;
|
|
94
96
|
children?: ReactNode;
|
|
@@ -205,18 +207,26 @@ function ShellSidebar({
|
|
|
205
207
|
side: 'left' | 'right';
|
|
206
208
|
sidebarPosition: 'viewport' | 'contained';
|
|
207
209
|
}) {
|
|
210
|
+
const fallbackLogo = typeof brand.name === 'string' ? brand.name.slice(0, 1).toUpperCase() : null;
|
|
211
|
+
|
|
208
212
|
return (
|
|
209
213
|
<Sidebar side={side} collapsible={collapsible} sidebarPosition={sidebarPosition}>
|
|
210
214
|
<SidebarHeader>
|
|
211
215
|
<SidebarMenu>
|
|
212
216
|
<SidebarMenuItem>
|
|
213
|
-
<SidebarMenuButton asChild className="data-[slot=sidebar-menu-button]:!p-1.5">
|
|
217
|
+
<SidebarMenuButton asChild tooltip={typeof brand.name === 'string' ? brand.name : undefined} className="data-[slot=sidebar-menu-button]:!p-1.5">
|
|
214
218
|
{renderLink({
|
|
215
219
|
href: brand.href ?? '#',
|
|
216
220
|
children: (
|
|
217
221
|
<>
|
|
218
|
-
{brand.logo
|
|
219
|
-
|
|
222
|
+
{brand.logo ?? (
|
|
223
|
+
<span className="flex size-4 shrink-0 items-center justify-center text-sm font-semibold">
|
|
224
|
+
{fallbackLogo}
|
|
225
|
+
</span>
|
|
226
|
+
)}
|
|
227
|
+
<span className="min-w-0 truncate text-base font-semibold group-data-[collapsible=icon]:hidden">
|
|
228
|
+
{brand.name}
|
|
229
|
+
</span>
|
|
220
230
|
</>
|
|
221
231
|
),
|
|
222
232
|
})}
|
|
@@ -289,7 +299,15 @@ function ShellSidebar({
|
|
|
289
299
|
);
|
|
290
300
|
}
|
|
291
301
|
|
|
292
|
-
function ShellHeader({
|
|
302
|
+
function ShellHeader({
|
|
303
|
+
pageTitle,
|
|
304
|
+
headerStart,
|
|
305
|
+
headerEnd,
|
|
306
|
+
}: {
|
|
307
|
+
pageTitle: string;
|
|
308
|
+
headerStart?: ReactNode;
|
|
309
|
+
headerEnd?: ReactNode;
|
|
310
|
+
}) {
|
|
293
311
|
return (
|
|
294
312
|
<header className="flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
|
|
295
313
|
<div className="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
|
|
@@ -301,6 +319,11 @@ function ShellHeader({ pageTitle, headerStart }: { pageTitle: string; headerStar
|
|
|
301
319
|
)}
|
|
302
320
|
<Separator orientation="vertical" className="mx-2 data-[orientation=vertical]:h-4" />
|
|
303
321
|
<h1 className="text-base font-medium">{pageTitle}</h1>
|
|
322
|
+
{headerEnd && (
|
|
323
|
+
<div className="ml-auto flex items-center gap-1">
|
|
324
|
+
{headerEnd}
|
|
325
|
+
</div>
|
|
326
|
+
)}
|
|
304
327
|
</div>
|
|
305
328
|
</header>
|
|
306
329
|
);
|
|
@@ -331,6 +354,7 @@ export function AppShell({
|
|
|
331
354
|
user = defaultUser,
|
|
332
355
|
pageTitle = 'Dashboard',
|
|
333
356
|
headerStart,
|
|
357
|
+
headerEnd,
|
|
334
358
|
renderLink = defaultRenderLink,
|
|
335
359
|
collapsible = 'icon',
|
|
336
360
|
sidebarPosition = 'viewport',
|
|
@@ -355,7 +379,7 @@ export function AppShell({
|
|
|
355
379
|
sidebarPosition={sidebarPosition}
|
|
356
380
|
/>
|
|
357
381
|
<SidebarInset className={isContained ? undefined : 'overflow-y-auto'}>
|
|
358
|
-
<ShellHeader pageTitle={pageTitle} headerStart={headerStart} />
|
|
382
|
+
<ShellHeader pageTitle={pageTitle} headerStart={headerStart} headerEnd={headerEnd} />
|
|
359
383
|
{children}
|
|
360
384
|
</SidebarInset>
|
|
361
385
|
</SidebarProvider>
|