@medixdeck/ui 0.1.21 → 0.1.22
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 +203 -18
- package/dist/index.cjs +46 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +163 -50
- package/dist/index.js +7729 -6383
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -237,11 +237,90 @@ function NotesForm() {
|
|
|
237
237
|
}
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
##
|
|
240
|
+
## Navbar
|
|
241
|
+
|
|
242
|
+
The `Navbar` component provides responsive brand navigation with animated desktop dropdown menus and mobile accordion sub-menus.
|
|
243
|
+
|
|
244
|
+
### Basic & Dropdown Usage
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import { Navbar, type NavItem } from '@medixdeck/ui';
|
|
248
|
+
|
|
249
|
+
const navItems: NavItem[] = [
|
|
250
|
+
{ label: 'Home', href: '/' },
|
|
251
|
+
{
|
|
252
|
+
label: 'Services',
|
|
253
|
+
children: [
|
|
254
|
+
{
|
|
255
|
+
label: 'Doctor Consultations',
|
|
256
|
+
href: '/services/doctors',
|
|
257
|
+
description: 'Connect with certified Nigerian medical practitioners 24/7.',
|
|
258
|
+
badge: 'Popular',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
label: 'Homecare Visits',
|
|
262
|
+
href: '/services/homecare',
|
|
263
|
+
description: 'Personalized nursing and clinical care at your residence.',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
label: 'Medical Outreach',
|
|
267
|
+
href: '/services/outreach',
|
|
268
|
+
description: 'Community screening & corporate healthcare programs.',
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
label: 'Resources',
|
|
274
|
+
children: [
|
|
275
|
+
{
|
|
276
|
+
label: 'Health Blog',
|
|
277
|
+
href: '/blog',
|
|
278
|
+
description: 'Wellness advice, clinical articles, and healthcare updates.',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
label: 'Developer API',
|
|
282
|
+
href: 'https://docs.medixdeck.com',
|
|
283
|
+
description: 'Public health API integration guides.',
|
|
284
|
+
isExternal: true,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
{ label: 'Pricing', href: '/pricing' },
|
|
289
|
+
{ label: 'About Us', href: '/about' },
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
export function Header() {
|
|
293
|
+
return (
|
|
294
|
+
<Navbar
|
|
295
|
+
navItems={navItems}
|
|
296
|
+
ctaLabel="Talk to a Doctor"
|
|
297
|
+
ctaHref="/consult"
|
|
298
|
+
secondaryCtaLabel="Sign In"
|
|
299
|
+
secondaryCtaHref="/login"
|
|
300
|
+
isSticky
|
|
301
|
+
colorScheme="blue"
|
|
302
|
+
/>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### `NavItem` properties
|
|
308
|
+
|
|
309
|
+
| Prop | Type | Description |
|
|
310
|
+
|---|---|---|
|
|
311
|
+
| `label` | `string` | Display text for the item |
|
|
312
|
+
| `href` | `string` | Target URL (optional for dropdown triggers) |
|
|
313
|
+
| `children` | `NavItem[]` | Nested items for desktop floating menus and mobile accordions |
|
|
314
|
+
| `description` | `string` | Subtitle text displayed below label in dropdown items |
|
|
315
|
+
| `icon` | `ReactNode` | Leading icon element |
|
|
316
|
+
| `badge` | `string \| number \| ReactNode` | Status tag or count (e.g. `"Popular"`, `"NDPR"`) |
|
|
317
|
+
| `isActive` | `boolean` | Highlights active route item |
|
|
318
|
+
| `isExternal` | `boolean` | Opens link in a new tab with an external arrow icon |
|
|
319
|
+
| `onClick` | `() => void` | Optional click callback |
|
|
241
320
|
|
|
242
|
-
|
|
321
|
+
---
|
|
243
322
|
|
|
244
|
-
|
|
323
|
+
## DashboardLayout
|
|
245
324
|
|
|
246
325
|
```tsx
|
|
247
326
|
import { DashboardLayout } from '@medixdeck/ui';
|
|
@@ -345,23 +424,129 @@ An optional second line below the greeting. The top bar expands from 64 px → 8
|
|
|
345
424
|
</DashboardLayout>
|
|
346
425
|
```
|
|
347
426
|
|
|
427
|
+
### Automatic Test & Sandbox Environment Banner
|
|
428
|
+
|
|
429
|
+
`DashboardLayout` includes a built-in, cross-framework test & sandbox environment banner that displays **automatically by default** whenever the app runs in non-production environments (e.g. `localhost`, `*.vercel.app`, `*.netlify.app`, `*.pages.dev`, `*staging*`, `*sandbox*`, `*dev*`, `*test*`, or `NODE_ENV !== 'production'`).
|
|
430
|
+
|
|
431
|
+
It is completely safe across SSR and CSR runtimes (Next.js App/Pages Router, Vite + React, Remix, Astro, TanStack Start, SolidJS bridges) with zero hydration mismatches.
|
|
432
|
+
|
|
433
|
+
```tsx
|
|
434
|
+
// 1. Automatic Default: Displays automatically in local / staging / sandbox / preview environments
|
|
435
|
+
<DashboardLayout user={user} navGroups={navGroups}>
|
|
436
|
+
{children}
|
|
437
|
+
</DashboardLayout>
|
|
438
|
+
|
|
439
|
+
// 2. Explicit Sandbox / Test / Staging Mode
|
|
440
|
+
<DashboardLayout environment="sandbox" user={user} navGroups={navGroups}>
|
|
441
|
+
{children}
|
|
442
|
+
</DashboardLayout>
|
|
443
|
+
|
|
444
|
+
// 3. Custom Banner Configuration (custom message, custom badge label, action button, dismissible)
|
|
445
|
+
<DashboardLayout
|
|
446
|
+
environmentBanner={{
|
|
447
|
+
environment: 'sandbox',
|
|
448
|
+
badgeLabel: 'SIMULATION LAB',
|
|
449
|
+
message: 'Simulated clinical testing environment. Actions will not affect live patient records.',
|
|
450
|
+
action: <a href="https://app.medixdeck.com">Switch to Live →</a>,
|
|
451
|
+
dismissible: true,
|
|
452
|
+
onDismiss: () => console.log('Banner closed'),
|
|
453
|
+
}}
|
|
454
|
+
user={user}
|
|
455
|
+
navGroups={navGroups}
|
|
456
|
+
>
|
|
457
|
+
{children}
|
|
458
|
+
</DashboardLayout>
|
|
459
|
+
|
|
460
|
+
// 4. Suppress banner completely in any environment
|
|
461
|
+
<DashboardLayout showEnvironmentBanner={false} user={user} navGroups={navGroups}>
|
|
462
|
+
{children}
|
|
463
|
+
</DashboardLayout>
|
|
464
|
+
|
|
465
|
+
// 5. Or mark environment as production
|
|
466
|
+
<DashboardLayout environment="production" user={user} navGroups={navGroups}>
|
|
467
|
+
{children}
|
|
468
|
+
</DashboardLayout>
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
`DashboardEnvironmentBannerConfig` props:
|
|
472
|
+
|
|
473
|
+
| Prop | Type | Default | Description |
|
|
474
|
+
|---|---|---|---|
|
|
475
|
+
| `environment` | `"auto" \| "production" \| "live" \| "sandbox" \| "test" \| "development" \| "staging" \| "preview"` | `"auto"` | Environment classification |
|
|
476
|
+
| `badgeLabel` | `string` | auto | Uppercase badge label (e.g., `"SANDBOX ENVIRONMENT"`) |
|
|
477
|
+
| `message` | `string` | auto | Descriptive warning / notice text |
|
|
478
|
+
| `status` | `"warning" \| "info" \| "error" \| "neutral"` | auto | Visual color scheme (amber warning, blue info, red error) |
|
|
479
|
+
| `action` | `ReactNode` | — | Action link or button on the right |
|
|
480
|
+
| `dismissible` | `boolean` | `false` | Shows a close (✕) button |
|
|
481
|
+
| `onDismiss` | `() => void` | — | Called when the close button is clicked |
|
|
482
|
+
|
|
483
|
+
### Collapsible Sidebar (`collapsible`, `isCollapsed`, `onCollapseChange`)
|
|
484
|
+
|
|
485
|
+
On desktop (`md+`), `DashboardLayout` supports shrinking the sidebar into a compact icon rail (68px) and expanding it back to full width (220px). Supports both uncontrolled (`defaultCollapsed`) and controlled (`isCollapsed`, `onCollapseChange`) operation:
|
|
486
|
+
|
|
487
|
+
- **Toggle Buttons**: Built-in panel collapse icon buttons (◧ / ◨) placed in the sidebar header (next to logo when expanded, directly below the logo mark in collapsed rail mode; `collapseTogglePlacement="sidebar-header"` by default).
|
|
488
|
+
- **Icon Rail Transformation**: Logo collapses into the icon mark, navigation items become centered 40px icon pills with tooltips, and badges/dots are pinned on top-right.
|
|
489
|
+
- **Sub-Items Flyout**: Clicking a navigation item with sub-links in collapsed mode opens an anchored floating flyout popover menu.
|
|
490
|
+
- **Doctor Score Card Transformation**: Collapses smoothly into a centered circular clinician tier ring avatar with full tooltip metadata.
|
|
491
|
+
|
|
492
|
+
```tsx
|
|
493
|
+
// 1. Uncontrolled with default expanded or collapsed
|
|
494
|
+
<DashboardLayout
|
|
495
|
+
collapsible={true}
|
|
496
|
+
defaultCollapsed={false}
|
|
497
|
+
user={user}
|
|
498
|
+
navGroups={navGroups}
|
|
499
|
+
>
|
|
500
|
+
{children}
|
|
501
|
+
</DashboardLayout>
|
|
502
|
+
|
|
503
|
+
// 2. Controlled collapse state
|
|
504
|
+
function App() {
|
|
505
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
<DashboardLayout
|
|
509
|
+
collapsible={true}
|
|
510
|
+
isCollapsed={isCollapsed}
|
|
511
|
+
onCollapseChange={setIsCollapsed}
|
|
512
|
+
collapsedSidebarWidth={68}
|
|
513
|
+
user={user}
|
|
514
|
+
navGroups={navGroups}
|
|
515
|
+
>
|
|
516
|
+
{children}
|
|
517
|
+
</DashboardLayout>
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
348
522
|
### All `DashboardLayout` props
|
|
349
523
|
|
|
350
|
-
| Prop
|
|
351
|
-
|
|
|
352
|
-
| `user`
|
|
353
|
-
| `navGroups`
|
|
354
|
-
| `
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
| `
|
|
364
|
-
| `
|
|
524
|
+
| Prop | Type | Default | Description |
|
|
525
|
+
| ------------------------ | ----------------------------------- | ---------- | --------------------------------------------- |
|
|
526
|
+
| `user` | `DashboardUser` | — | Name, email, optional avatar |
|
|
527
|
+
| `navGroups` | `DashboardNavGroup[]` | — | Sidebar navigation tree |
|
|
528
|
+
| `collapsible` | `boolean` | `true` | Enables collapsible sidebar icon rail |
|
|
529
|
+
| `defaultCollapsed` | `boolean` | `false` | Initial collapsed state (uncontrolled) |
|
|
530
|
+
| `isCollapsed` | `boolean` | — | Controlled collapsed state |
|
|
531
|
+
| `onCollapseChange` | `(collapsed: boolean) => void` | — | Fired when sidebar collapse state toggles |
|
|
532
|
+
| `sidebarWidth` | `number` | `220` | Full sidebar width in px |
|
|
533
|
+
| `collapsedSidebarWidth` | `number` | `68` | Compact icon rail width in px |
|
|
534
|
+
| `collapseTogglePlacement`| `"sidebar-header" \| "topbar" \| "both" \| "none"` | `"sidebar-header"` | Placement of collapse/expand toggle buttons |
|
|
535
|
+
| `collapsedLogo` | `ReactNode` | `<Logo type="icon" />` | Custom logo displayed in collapsed mode |
|
|
536
|
+
| `colorScheme` | `"blue" \| "purple"` | `"blue"` | Brand accent colour |
|
|
537
|
+
| `environment` | `DashboardEnvironment` | `"auto"` | Auto-detects test/sandbox/staging environments |
|
|
538
|
+
| `showEnvironmentBanner` | `boolean` | auto | Force show (`true`) or suppress (`false`) banner |
|
|
539
|
+
| `environmentBanner` | `DashboardEnvironmentBannerConfig` | — | Detailed banner message, action, & dismiss config |
|
|
540
|
+
| `environmentBannerSlot` | `ReactNode` | — | Custom slot overriding the entire banner |
|
|
541
|
+
| `logo` | `ReactNode` | `<Logo />` | Override the sidebar logo |
|
|
542
|
+
| `greeting` | `string` | auto | Override "Good morning / afternoon / evening" |
|
|
543
|
+
| `greetingSubtext` | `string` | — | Subtitle line below the greeting |
|
|
544
|
+
| `mobileNavItems` | `DashboardMobileNavItem[]` | — | Mobile bottom tab bar items |
|
|
545
|
+
| `scoreCard` | `DashboardScoreCardData` | — | Doctor identity card (desktop only) |
|
|
546
|
+
| `topBarSlot` | `ReactNode` | — | Slot right of greeting (search, bell, etc.) |
|
|
547
|
+
| `dropdownItems` | `DashboardDropdownItem[]` | — | Extra user dropdown items |
|
|
548
|
+
| `renderLink` | `(item, children) => ReactNode` | `<a>` | Router integration |
|
|
549
|
+
| `onLogout` | `() => void` | — | Logout callback |
|
|
365
550
|
|
|
366
551
|
## Footer
|
|
367
552
|
|