@medixdeck/ui 0.1.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/README.md ADDED
@@ -0,0 +1,461 @@
1
+ # @medixdeck/ui
2
+
3
+ > **Shared UI Component Library** for MedixDeck — built with Vite, React 18, TypeScript, and Chakra UI v3.
4
+
5
+ [![npm version](https://img.shields.io/badge/npm-%400.1.0-blue)](https://npmjs.com/package/@medixdeck/ui)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
+ [![Chakra UI](https://img.shields.io/badge/Chakra%20UI-v3-teal)](https://chakra-ui.com/)
8
+ [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ `@medixdeck/ui` is a **production-ready, design-system-driven** React component library that provides:
15
+
16
+ - **43 components** covering primitives, forms, layout, navigation, feedback, data display, and healthcare-specific UI
17
+ - **Full TypeScript support** with exported prop interfaces
18
+ - **Light & dark mode** via semantic tokens + `next-themes` (`.dark` class on `<html>`)
19
+ - **Satoshi font** (Fontshare CDN) + **Inter** (Google Fonts) — both loaded automatically by `MedixProvider`
20
+ - **`Logo` component** — inline SVG, 4 color variants (blue/purple/black/white), full + icon-only modes
21
+ - **ESM + CJS** dual outputs with `.d.ts` declarations
22
+ - **Zero runtime CSS** — styles are generated by Chakra UI v3's Panda CSS engine
23
+
24
+ ---
25
+
26
+ ## Quick Start
27
+
28
+ ### Install
29
+
30
+ ```bash
31
+ npm install @medixdeck/ui @chakra-ui/react next-themes
32
+ ```
33
+
34
+ ### Wrap your root
35
+
36
+ ```tsx
37
+ // app/layout.tsx (Next.js App Router)
38
+ import { MedixProvider } from "@medixdeck/ui";
39
+
40
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
41
+ return (
42
+ <html lang="en">
43
+ <body>
44
+ {/* MedixProvider injects Satoshi + Inter fonts and all CSS vars automatically */}
45
+ <MedixProvider defaultColorMode="light">
46
+ {children}
47
+ </MedixProvider>
48
+ </body>
49
+ </html>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ```tsx
55
+ // main.tsx (Vite)
56
+ import { MedixProvider } from "@medixdeck/ui";
57
+ import ReactDOM from "react-dom/client";
58
+ import App from "./App";
59
+
60
+ ReactDOM.createRoot(document.getElementById("root")!).render(
61
+ <MedixProvider defaultColorMode="light">
62
+ <App />
63
+ </MedixProvider>
64
+ );
65
+ ```
66
+
67
+ ### Use components
68
+
69
+ ```tsx
70
+ import { Button, DoctorCard, OTPInput, PhoneInput, DataTable, Logo } from "@medixdeck/ui";
71
+
72
+ // Button
73
+ <Button variant="solid" colorScheme="blue">Talk to a Doctor</Button>
74
+
75
+ // Logo — inline SVG, no image assets needed
76
+ <Logo /> // full blue, 32px
77
+ <Logo variant="purple" type="icon" /> // icon-only, purple
78
+ <Logo variant="white" height={28} /> // white full logo
79
+ <Logo variant="black" type="icon" height={48} /> // black icon
80
+
81
+ // Logo in a Navbar (or pass no logo prop for automatic default)
82
+ <Navbar logo={<Logo variant="purple" height={28} />} navItems={[...]} />
83
+
84
+ // Phone input with country code
85
+ <PhoneInput label="Phone number" defaultCountryCode="+234" onChange={setPhone} />
86
+
87
+ // OTP verification
88
+ <OTPInput length={6} label="Enter verification code" onComplete={verifyCode} />
89
+
90
+ // Data table with sorting
91
+ <DataTable
92
+ columns={[{ key: "name", label: "Patient", sortable: true }]}
93
+ data={patients}
94
+ rowKey="id"
95
+ striped
96
+ onRowClick={(row) => router.push(`/patients/${row.id}`)}
97
+ />
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Component Index
103
+
104
+ ### 🔵 Primitive (8)
105
+
106
+ | Component | Props | Description |
107
+ | --- | --- | --- |
108
+ | `Button` | `variant`, `size`, `colorScheme`, `isLoading`, `leftIcon`, `rightIcon` | Primary action button |
109
+ | `IconButton` | `icon`, `label`, `variant`, `size` | Icon-only button |
110
+ | `Badge` | `status`, `variant`, `size` | Status indicator label |
111
+ | `Avatar` | `src`, `name`, `size`, `showStatus`, `statusColor` | Profile picture with initials fallback |
112
+ | `AvatarGroup` | `max`, `size` | Stacked avatar display |
113
+ | `Spinner` / `FullPageSpinner` | `size`, `label`, `color` | Loading animation |
114
+ | `Tag` | `colorScheme`, `variant`, `onClose` | Filter chip |
115
+ | `Divider` | `orientation`, `label` | Section separator |
116
+ | `Logo` | `variant`, `type`, `height` | MedixDeck brand logo — inline SVG, no asset files needed |
117
+
118
+ ### 📝 Form (10)
119
+
120
+ | Component | Props | Description |
121
+ | --- | --- | --- |
122
+ | `Input` | `type`, `placeholder`, `isInvalid`, `leftIcon`, `rightIcon` | Text field |
123
+ | `SearchInput` | `placeholder`, `onChange` | Search field with icon |
124
+ | `Textarea` | `rows`, `maxLength`, `showCount` | Multi-line input |
125
+ | `Select` | `options[]`, `placeholder`, `isInvalid` | Native dropdown |
126
+ | `Checkbox` | `colorScheme`, `description` | Single checkbox |
127
+ | `RadioGroup` | `name`, `options[]`, `onChange`, `direction` | Radio button group |
128
+ | `Switch` | `label`, `description`, `size`, `colorScheme` | Toggle switch |
129
+ | `FormControl` | `label`, `helperText`, `errorMessage`, `isRequired` | Field wrapper with label/error |
130
+ | `OTPInput` / `PinInput` | `length`, `value`, `onChange`, `onComplete`, `mask`, `isInvalid` | One-time password boxes |
131
+ | `PhoneInput` | `defaultCountryCode`, `placeholder`, `onChange` | Phone + country code selector |
132
+ | `DatePicker` | `value`, `min`, `max`, `onChange`, `includeTime` | Styled date/datetime input |
133
+
134
+ ### 🧩 Layout (4)
135
+
136
+ | Component | Props | Description |
137
+ | --- | --- | --- |
138
+ | `Card` / `CardHeader` / `CardBody` / `CardFooter` | `hoverable`, `title`, `subtitle` | Surface container |
139
+ | `StatCard` | `value`, `label`, `change`, `trend` | KPI metric card |
140
+ | `Container` | `maxWidth` | Centered page wrapper |
141
+ | `SectionHeader` | `eyebrow`, `title`, `description`, `align` | Section heading block |
142
+
143
+ ### 🔗 Navigation (5)
144
+
145
+ | Component | Props | Description |
146
+ | --- | --- | --- |
147
+ | `Navbar` | `logo?`, `navItems[]`, `ctaLabel`, `isSticky`, `renderLink`, `variant` | Responsive header. Falls back to `<Logo />` when `logo` is omitted |
148
+ | `Breadcrumb` | `items[]`, `separator`, `renderLink` | Page path navigator |
149
+ | `Tabs` | `tabs[]`, `variant`, `activeId`, `onChange` | Line and pill variants |
150
+ | `Pagination` | `total`, `pageSize`, `currentPage`, `onChange`, `compact` | Page navigation |
151
+ | `Stepper` | `steps[]`, `currentStep`, `orientation`, `colorScheme` | Multi-step progress |
152
+
153
+ ### 🔔 Feedback & Overlays (8)
154
+
155
+ | Component | Props | Description |
156
+ | --- | --- | --- |
157
+ | `Alert` | `status`, `variant`, `title`, `description`, `closable` | Inline message |
158
+ | `Skeleton` / `SkeletonText` / `SkeletonCard` | `isLoaded`, `lines` | Loading placeholder |
159
+ | `Progress` | `value`, `colorScheme`, `size`, `isIndeterminate`, `showLabel` | Progress bar |
160
+ | `Modal` | `isOpen`, `onClose`, `title`, `description`, `size`, `footer` | Dialog overlay |
161
+ | `Drawer` | `isOpen`, `onClose`, `title`, `placement`, `size`, `footer` | Slide-in panel |
162
+ | `Tooltip` | `label`, `placement` | Hover label |
163
+ | `EmptyState` | `icon`, `title`, `description`, `actionLabel` | Zero-data screen |
164
+
165
+ ### 📊 Data Display (4)
166
+
167
+ | Component | Props | Description |
168
+ | --- | --- | --- |
169
+ | `Accordion` | `items[]`, `allowMultiple`, `variant` | Collapsible FAQ |
170
+ | `TestimonialCard` | `quote`, `authorName`, `authorTitle`, `rating` | Review card |
171
+ | `BlogCard` | `title`, `excerpt`, `category`, `coverImage`, `href` | Article preview |
172
+ | `DataTable` | `columns[]`, `data[]`, `sortable`, `striped`, `onRowClick`, `isLoading` | Sortable data table |
173
+
174
+ ### 🏥 Healthcare-Specific (3)
175
+
176
+ | Component | Props | Description |
177
+ | --- | --- | --- |
178
+ | `DoctorCard` | `name`, `specialty`, `rating`, `consultationFee`, `isVerified`, `isAvailable`, `onBookClick` | Doctor profile card |
179
+ | `VitalBadge` | `label`, `value`, `unit`, `status` | Vital sign display |
180
+ | `AppointmentCard` | `doctorName`, `date`, `time`, `type`, `status`, `onJoin`, `onReschedule`, `onCancel` | Appointment summary |
181
+
182
+ ---
183
+
184
+ ## Design Tokens
185
+
186
+ ### Color Palette
187
+
188
+ | Token | Light | Dark | Hex |
189
+ | --- | --- | --- | --- |
190
+ | `bg` | #FEFEFE | #0A1220 | — |
191
+ | `bg.surface` | #F6F6F6 | #152035 | — |
192
+ | `text.heading` | #111926 | #F5F6F8 | — |
193
+ | `text.body` | #374151 | #CBD5E1 | — |
194
+ | `text.muted` | #6B7280 | #94A3B8 | — |
195
+ | `border` | #E2E8F0 | #1E3554 | — |
196
+ | `blue.500` | — | — | #0685FF |
197
+ | `purple.500` | — | — | #7700CC |
198
+
199
+ ### Typography
200
+
201
+ ```tsx
202
+ // CSS custom properties injected by MedixProvider
203
+ --font-body: "Satoshi", sans-serif
204
+ --font-heading: "Satoshi", sans-serif
205
+ ```
206
+
207
+ ### Using tokens directly
208
+
209
+ ```tsx
210
+ import { Box } from "@medixdeck/ui";
211
+
212
+ // Use semantic tokens in any Box prop
213
+ <Box bg="bg.surface" color="text.heading" border="1px solid" borderColor="border">
214
+ Hello World
215
+ </Box>
216
+ ```
217
+
218
+ ### Accessing the raw `system` object
219
+
220
+ ```tsx
221
+ import { system } from "@medixdeck/ui";
222
+ import { ChakraProvider } from "@chakra-ui/react";
223
+
224
+ // Use the design system without MedixProvider
225
+ <ChakraProvider value={system}>
226
+ {children}
227
+ </ChakraProvider>
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Dark Mode
233
+
234
+ Dark mode is managed by `next-themes`. `MedixProvider` handles it automatically by applying a `.dark` class to `<html>`.
235
+
236
+ ```tsx
237
+ // next-themes hook — use in any child component
238
+ import { useTheme } from "next-themes";
239
+
240
+ function DarkModeButton() {
241
+ const { theme, setTheme } = useTheme();
242
+ return (
243
+ <Button onClick={() => setTheme(theme === "light" ? "dark" : "light")}>
244
+ {theme === "light" ? "🌙 Dark" : "☀️ Light"}
245
+ </Button>
246
+ );
247
+ }
248
+ ```
249
+
250
+ Or manage it manually — just add/remove `dark` from `document.documentElement`:
251
+
252
+ ```tsx
253
+ // Toggle dark mode without next-themes (e.g. in a Vite dev preview)
254
+ useEffect(() => {
255
+ document.documentElement.classList.toggle("dark", isDark);
256
+ }, [isDark]);
257
+ ```
258
+
259
+ > **Important:** Always apply the `dark` class on `<html>` (or a root ancestor that wraps **all** components including `<Navbar>`). Applying it on an inner `<Box>` while leaving sticky/portal components outside will break their dark mode.
260
+
261
+ ---
262
+
263
+ ## Custom Link Renderer
264
+
265
+ For Next.js or React Router routing without anchor reloads:
266
+
267
+ ```tsx
268
+ import Link from "next/link"; // or from react-router-dom
269
+
270
+ // Navbar
271
+ <Navbar
272
+ navItems={[{ label: "Home", href: "/" }, { label: "Doctors", href: "/doctors" }]}
273
+ renderLink={(item, children) => (
274
+ <Link href={item.href} style={{ textDecoration: "none" }}>
275
+ {children}
276
+ </Link>
277
+ )}
278
+ />
279
+
280
+ // Breadcrumb
281
+ <Breadcrumb
282
+ items={[{ label: "Home", href: "/" }, { label: "Doctors" }]}
283
+ renderLink={(item, children) => <Link href={item.href}>{children}</Link>}
284
+ />
285
+ ```
286
+
287
+ ---
288
+
289
+ ## OTPInput / PinInput
290
+
291
+ ```tsx
292
+ <OTPInput
293
+ length={6}
294
+ label="Enter verification code"
295
+ helperText="We sent a 6-digit code to your registered phone"
296
+ value={otp}
297
+ onChange={setOtp}
298
+ onComplete={(code) => verifyOtp(code)}
299
+ />
300
+
301
+ // Masked PIN mode
302
+ <PinInput length={4} mask label="Enter your PIN" />
303
+ ```
304
+
305
+ ---
306
+
307
+ ## PhoneInput
308
+
309
+ ```tsx
310
+ <PhoneInput
311
+ label="Phone number"
312
+ defaultCountryCode="+234"
313
+ placeholder="80 000 0000"
314
+ value={phone}
315
+ onChange={setPhone}
316
+ helperText="We'll send your confirmation here"
317
+ />
318
+ ```
319
+
320
+ Supported country codes: 🇳🇬 +234, 🇺🇸 +1, 🇬🇧 +44, 🇬🇭 +233, 🇰🇪 +254, 🇿🇦 +27, 🇪🇹 +251, 🇹🇿 +255
321
+
322
+ ---
323
+
324
+ ## DataTable
325
+
326
+ ```tsx
327
+ <DataTable
328
+ columns={[
329
+ { key: "name", label: "Patient Name", sortable: true },
330
+ { key: "date", label: "Date", sortable: true },
331
+ {
332
+ key: "status",
333
+ label: "Status",
334
+ render: (val) => <Badge status={val === "Active" ? "success" : "warning"}>{val}</Badge>,
335
+ },
336
+ ]}
337
+ data={patients}
338
+ rowKey="id"
339
+ striped
340
+ isLoading={isFetching}
341
+ onRowClick={(row) => router.push(`/patients/${row.id}`)}
342
+ />
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Project Structure
348
+
349
+ ```txt
350
+ medixdeck-ui/
351
+ ├── lib/ ← Library source
352
+ │ ├── index.ts ← Single export entry point
353
+ │ ├── theme/
354
+ │ │ ├── index.ts ← createSystem (Chakra v3)
355
+ │ │ ├── colors.ts ← Primitive color tokens
356
+ │ │ ├── typography.ts ← Font scale & text styles
357
+ │ │ └── spacing.ts ← Spacing, radii, shadows
358
+ │ └── components/
359
+ │ ├── provider/
360
+ │ │ └── MedixProvider.tsx ← Theme + dark mode provider
361
+ │ ├── primitive/
362
+ │ │ ├── Button.tsx
363
+ │ │ ├── IconButton.tsx
364
+ │ │ ├── Badge.tsx
365
+ │ │ ├── Avatar.tsx ← Avatar + AvatarGroup
366
+ │ │ ├── Spinner.tsx
367
+ │ │ ├── Tag.tsx
368
+ │ │ ├── Divider.tsx
369
+ │ │ └── Logo.tsx ← Brand logo, 4 variants, full + icon modes
370
+ │ ├── form/
371
+ │ │ ├── Input.tsx ← Input + SearchInput
372
+ │ │ ├── Textarea.tsx
373
+ │ │ ├── Select.tsx
374
+ │ │ ├── CheckboxRadio.tsx ← Checkbox + RadioGroup
375
+ │ │ ├── Switch.tsx
376
+ │ │ ├── FormControl.tsx
377
+ │ │ ├── OTPInput.tsx ← OTPInput + PinInput
378
+ │ │ ├── PhoneInput.tsx ← With country code selector
379
+ │ │ └── DatePicker.tsx
380
+ │ ├── layout/
381
+ │ │ ├── Card.tsx ← Card + Header/Body/Footer
382
+ │ │ ├── StatCard.tsx
383
+ │ │ └── Container.tsx ← Container + SectionHeader
384
+ │ ├── navigation/
385
+ │ │ ├── Navbar.tsx
386
+ │ │ ├── Breadcrumb.tsx
387
+ │ │ ├── Tabs.tsx
388
+ │ │ ├── Pagination.tsx
389
+ │ │ └── Stepper.tsx
390
+ │ ├── feedback/
391
+ │ │ ├── Alert.tsx
392
+ │ │ ├── Skeleton.tsx ← Skeleton + SkeletonText + SkeletonCard
393
+ │ │ ├── Progress.tsx
394
+ │ │ ├── Modal.tsx
395
+ │ │ ├── Drawer.tsx
396
+ │ │ ├── Tooltip.tsx
397
+ │ │ └── EmptyState.tsx
398
+ │ ├── data/
399
+ │ │ ├── Accordion.tsx
400
+ │ │ ├── Cards.tsx ← TestimonialCard + BlogCard
401
+ │ │ └── DataTable.tsx
402
+ │ └── healthcare/
403
+ │ └── DoctorCard.tsx ← DoctorCard + VitalBadge + AppointmentCard
404
+ ├── src/
405
+ │ ├── main.tsx ← Dev preview entry
406
+ │ └── App.tsx ← Component showcase app
407
+ ├── dist/ ← Built output (git-ignored)
408
+ │ ├── index.js ← ESM build
409
+ │ ├── index.cjs ← CJS build
410
+ │ └── index.d.ts ← TypeScript declarations
411
+ ├── AGENTS.md ← AI agent guidelines
412
+ ├── index.html
413
+ ├── vite.config.ts
414
+ ├── tsconfig.json
415
+ ├── tsconfig.build.json
416
+ └── package.json
417
+ ```
418
+
419
+ ---
420
+
421
+ ## Scripts
422
+
423
+ | Script | Command | Description |
424
+ | --- | --- | --- |
425
+ | Dev preview | `npm run dev` | Start Vite dev server (<http://localhost:5173>) |
426
+ | Build library | `npm run build` | Compile to `dist/` (ESM + CJS + types) |
427
+ | Type check | `npm run typecheck` | Run `tsc --noEmit` |
428
+
429
+ ---
430
+
431
+ ## Publishing
432
+
433
+ ```bash
434
+ # Bump version in package.json first, then:
435
+ npm run build
436
+ npm publish --access public
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Roadmap
442
+
443
+ - [x] Primitive components (Button, Badge, Avatar, Spinner, Tag, Divider, **Logo**)
444
+ - [x] Form components (Input, Textarea, Select, Checkbox, RadioGroup, Switch, FormControl)
445
+ - [x] OTPInput / PinInput
446
+ - [x] PhoneInput with country code selector
447
+ - [x] DatePicker
448
+ - [x] Layout components (Card, StatCard, Container, SectionHeader)
449
+ - [x] Navigation (Navbar with default Logo fallback, Breadcrumb, Tabs, Pagination, Stepper)
450
+ - [x] Feedback (Alert, Skeleton, Progress, Modal, Drawer, Tooltip, EmptyState)
451
+ - [x] DataTable with sorting + loading state
452
+ - [x] Healthcare components (DoctorCard, VitalBadge, AppointmentCard)
453
+ - [x] Font auto-injection (Satoshi + Inter via MedixProvider)
454
+ - [x] Dark mode via `.dark` class on `<html>` (all components including Navbar respond correctly)
455
+ - [ ] Storybook interactive docs
456
+ - [ ] Vitest + React Testing Library unit tests
457
+ - [ ] GitHub Actions CI/CD for automated publishing
458
+ - [ ] `DateRangePicker` component
459
+ - [ ] `Combobox` / searchable select
460
+ - [ ] `FileUpload` component
461
+ - [ ] `Notification` / toast system