@marcoschwartz/lite-ui 0.25.3 → 0.25.4
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/README.md +73 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,8 +102,10 @@ export default function Page() {
|
|
|
102
102
|
- **DateTimePicker** - Combined date and time picker
|
|
103
103
|
|
|
104
104
|
### Layout & Navigation
|
|
105
|
+
- **AppShell** - Complete app layout with header, navbar, aside, and footer
|
|
105
106
|
- **Navbar** - Responsive navigation bar
|
|
106
107
|
- **Sidebar** - Collapsible sidebar with mobile support
|
|
108
|
+
- **SidebarNav** - Collapsible navigation with icon-only mode and tooltips
|
|
107
109
|
- **Drawer** - Slide-out drawer panel
|
|
108
110
|
- **Modal** - Accessible modal dialog
|
|
109
111
|
- **Tabs** - Tabbed navigation component
|
|
@@ -313,6 +315,77 @@ export function ConfirmDialog() {
|
|
|
313
315
|
}
|
|
314
316
|
```
|
|
315
317
|
|
|
318
|
+
### Collapsible Sidebar Navigation
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
"use client";
|
|
322
|
+
|
|
323
|
+
import { useState } from 'react';
|
|
324
|
+
import {
|
|
325
|
+
AppShell,
|
|
326
|
+
SidebarNav,
|
|
327
|
+
SidebarNavItem,
|
|
328
|
+
SidebarNavSection,
|
|
329
|
+
SidebarNavDivider,
|
|
330
|
+
SidebarNavCollapseToggle,
|
|
331
|
+
HomeIcon,
|
|
332
|
+
UserIcon,
|
|
333
|
+
SettingsIcon,
|
|
334
|
+
} from '@marcoschwartz/lite-ui';
|
|
335
|
+
|
|
336
|
+
export function DashboardLayout({ children }) {
|
|
337
|
+
const [activeItem, setActiveItem] = useState('dashboard');
|
|
338
|
+
const [navbarWidth, setNavbarWidth] = useState<number | undefined>();
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<AppShell
|
|
342
|
+
title="My App"
|
|
343
|
+
navbar={{
|
|
344
|
+
content: (
|
|
345
|
+
<SidebarNav
|
|
346
|
+
collapsible
|
|
347
|
+
onCollapseChange={(_, width) => setNavbarWidth(width)}
|
|
348
|
+
>
|
|
349
|
+
<SidebarNavSection grow>
|
|
350
|
+
<SidebarNavItem
|
|
351
|
+
icon={<HomeIcon size="sm" />}
|
|
352
|
+
label="Dashboard"
|
|
353
|
+
active={activeItem === 'dashboard'}
|
|
354
|
+
onClick={() => setActiveItem('dashboard')}
|
|
355
|
+
/>
|
|
356
|
+
<SidebarNavItem
|
|
357
|
+
icon={<UserIcon size="sm" />}
|
|
358
|
+
label="Users"
|
|
359
|
+
active={activeItem === 'users'}
|
|
360
|
+
onClick={() => setActiveItem('users')}
|
|
361
|
+
/>
|
|
362
|
+
<SidebarNavItem
|
|
363
|
+
icon={<SettingsIcon size="sm" />}
|
|
364
|
+
label="Settings"
|
|
365
|
+
active={activeItem === 'settings'}
|
|
366
|
+
onClick={() => setActiveItem('settings')}
|
|
367
|
+
/>
|
|
368
|
+
</SidebarNavSection>
|
|
369
|
+
<SidebarNavDivider />
|
|
370
|
+
<SidebarNavCollapseToggle />
|
|
371
|
+
</SidebarNav>
|
|
372
|
+
),
|
|
373
|
+
width: navbarWidth, // Dynamic width from SidebarNav
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
{children}
|
|
377
|
+
</AppShell>
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**SidebarNav Features:**
|
|
383
|
+
- **Collapsible mode** - Toggle between full and icon-only view
|
|
384
|
+
- **Tooltips** - Show labels on hover when collapsed
|
|
385
|
+
- **Persistent state** - Collapse state saved to localStorage
|
|
386
|
+
- **Smooth transitions** - Animated width changes
|
|
387
|
+
- **Mantine-compatible API** - Use `leftSection` as alias for `icon`
|
|
388
|
+
|
|
316
389
|
## 🛠️ Development
|
|
317
390
|
|
|
318
391
|
### Running the Demo
|
package/dist/index.js
CHANGED
|
@@ -829,7 +829,7 @@ var SidebarNav = ({
|
|
|
829
829
|
"nav",
|
|
830
830
|
{
|
|
831
831
|
className: `
|
|
832
|
-
flex flex-col h-full overflow-hidden
|
|
832
|
+
flex flex-col h-full overflow-x-hidden overflow-y-auto
|
|
833
833
|
transition-[width] duration-200 ease-in-out
|
|
834
834
|
${className}
|
|
835
835
|
`,
|
|
@@ -844,7 +844,7 @@ var SidebarNavSection = ({
|
|
|
844
844
|
grow = false,
|
|
845
845
|
className = ""
|
|
846
846
|
}) => {
|
|
847
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className:
|
|
847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `p-3 space-y-1 ${grow ? "flex-1 overflow-y-auto overflow-x-hidden" : ""} ${className}`, children });
|
|
848
848
|
};
|
|
849
849
|
var SidebarNavItem = ({
|
|
850
850
|
icon,
|
|
@@ -869,8 +869,8 @@ var SidebarNavItem = ({
|
|
|
869
869
|
flex items-center gap-3 w-full px-3 py-2.5 rounded-lg
|
|
870
870
|
text-sm font-medium
|
|
871
871
|
transition-colors duration-150
|
|
872
|
-
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer
|
|
873
|
-
${active ? "bg-[hsl(var(--
|
|
872
|
+
${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
873
|
+
${active ? "bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]" : "text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--foreground))]"}
|
|
874
874
|
${collapsed ? "justify-center px-0" : ""}
|
|
875
875
|
${className}
|
|
876
876
|
`;
|
|
@@ -1812,7 +1812,7 @@ var AppShell = ({
|
|
|
1812
1812
|
style: getWidthStyle(navbarWidth),
|
|
1813
1813
|
children: [
|
|
1814
1814
|
(logo || title) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: `${heightClasses[headerHeight]} px-4 flex items-center border-b border-[hsl(var(--border))] shrink-0`, children: logo || /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "text-xl font-bold text-[hsl(var(--foreground))]", children: title }) }),
|
|
1815
|
-
/* @__PURE__ */ (0, import_jsx_runtime79.jsx)("nav", { className: "flex-1 overflow-y-auto", children: navbar.content })
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime79.jsx)("nav", { className: "flex-1 overflow-y-auto overflow-x-hidden", children: navbar.content })
|
|
1816
1816
|
]
|
|
1817
1817
|
}
|
|
1818
1818
|
),
|
|
@@ -1856,7 +1856,7 @@ var AppShell = ({
|
|
|
1856
1856
|
aside && !asideCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1857
1857
|
"aside",
|
|
1858
1858
|
{
|
|
1859
|
-
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1859
|
+
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto overflow-x-hidden`,
|
|
1860
1860
|
style: getWidthStyle(asideWidth),
|
|
1861
1861
|
children: aside.content
|
|
1862
1862
|
}
|
|
@@ -1939,7 +1939,7 @@ var AppShell = ({
|
|
|
1939
1939
|
navbar && !navbarCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1940
1940
|
"nav",
|
|
1941
1941
|
{
|
|
1942
|
-
className: `${navbarDesktopShowClass} ${getWidthClass(navbarWidth)} ${getVariantClasses(navbarVariant, navbarWithBorder)} ${navbarWithBorder ? "border-r" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1942
|
+
className: `${navbarDesktopShowClass} ${getWidthClass(navbarWidth)} ${getVariantClasses(navbarVariant, navbarWithBorder)} ${navbarWithBorder ? "border-r" : ""} flex-col shrink-0 overflow-y-auto overflow-x-hidden`,
|
|
1943
1943
|
style: getWidthStyle(navbarWidth),
|
|
1944
1944
|
children: navbar.content
|
|
1945
1945
|
}
|
|
@@ -1948,7 +1948,7 @@ var AppShell = ({
|
|
|
1948
1948
|
aside && !asideCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1949
1949
|
"aside",
|
|
1950
1950
|
{
|
|
1951
|
-
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1951
|
+
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto overflow-x-hidden`,
|
|
1952
1952
|
style: getWidthStyle(asideWidth),
|
|
1953
1953
|
children: aside.content
|
|
1954
1954
|
}
|