@medixdeck/ui 0.1.6 → 0.1.8
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 +46 -3
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +74 -2
- package/dist/index.js +2276 -2253
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,27 @@ npm install @medixdeck/ui @chakra-ui/react react react-dom
|
|
|
17
17
|
## Quick start
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
Button,
|
|
22
|
+
Logo,
|
|
23
|
+
MedixProvider,
|
|
24
|
+
Navbar,
|
|
25
|
+
useThemeMode,
|
|
26
|
+
} from "@medixdeck/ui";
|
|
27
|
+
|
|
28
|
+
// Next.js App Router: mark this component "use client" when using hooks.
|
|
29
|
+
function ThemeToggle() {
|
|
30
|
+
const { mounted, themeMode, toggleThemeMode } = useThemeMode();
|
|
31
|
+
|
|
32
|
+
// Avoid hydration mismatch: next-themes resolves the theme after mount.
|
|
33
|
+
if (!mounted) return null;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Button variant="solid" colorScheme="blue" onClick={toggleThemeMode}>
|
|
37
|
+
Switch to {themeMode === "dark" ? "light" : "dark"} mode
|
|
38
|
+
</Button>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
21
41
|
|
|
22
42
|
export function App() {
|
|
23
43
|
return (
|
|
@@ -27,7 +47,7 @@ export function App() {
|
|
|
27
47
|
ctaLabel="Talk to a Doctor"
|
|
28
48
|
ctaHref="/consult"
|
|
29
49
|
/>
|
|
30
|
-
<
|
|
50
|
+
<ThemeToggle />
|
|
31
51
|
<Logo variant="purple" height={28} />
|
|
32
52
|
</MedixProvider>
|
|
33
53
|
);
|
|
@@ -38,7 +58,7 @@ export function App() {
|
|
|
38
58
|
|
|
39
59
|
| Area | Exports |
|
|
40
60
|
| --- | --- |
|
|
41
|
-
| Provider + theme | `MedixProvider`, `system`, `medixConfig`, token exports |
|
|
61
|
+
| Provider + theme | `MedixProvider`, `useThemeMode`, `useIsDarkMode`, `system`, `medixConfig`, token exports |
|
|
42
62
|
| Primitive | `Button`, `IconButton`, `Badge`, `Avatar`, `AvatarGroup`, `Spinner`, `FullPageSpinner`, `Tag`, `Divider`, `Logo` |
|
|
43
63
|
| Form | `Input`, `SearchInput`, `Textarea`, `Select`, `Checkbox`, `RadioGroup`, `Switch`, `FormControl`, `OTPInput`, `PinInput`, `PhoneInput`, `DatePicker`, `DateRangePicker`, `Combobox`, `FileUpload` |
|
|
44
64
|
| Layout | `Card`, `CardHeader`, `CardBody`, `CardFooter`, `StatCard`, `Container`, `SectionHeader`, `DashboardLayout` |
|
|
@@ -56,6 +76,29 @@ export function App() {
|
|
|
56
76
|
- For color-critical interactive controls, prefer the repo's native-first pattern instead of Chakra recipes.
|
|
57
77
|
- Apply dark mode on `document.documentElement`, not an inner container.
|
|
58
78
|
|
|
79
|
+
## Theme hooks
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { useIsDarkMode, useThemeMode } from "@medixdeck/ui";
|
|
83
|
+
|
|
84
|
+
function ThemeStatus() {
|
|
85
|
+
const { themeMode, themeSetting, setThemeMode, toggleThemeMode } = useThemeMode();
|
|
86
|
+
const isDarkMode = useIsDarkMode();
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
<p>Resolved mode: {themeMode}</p>
|
|
91
|
+
<p>Following: {themeSetting ?? "system"}</p>
|
|
92
|
+
<p>Dark mode active: {String(isDarkMode)}</p>
|
|
93
|
+
<button onClick={() => setThemeMode("dark")}>Dark</button>
|
|
94
|
+
<button onClick={() => setThemeMode("light")}>Light</button>
|
|
95
|
+
<button onClick={() => setThemeMode("system")}>System</button>
|
|
96
|
+
<button onClick={toggleThemeMode}>Toggle</button>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
59
102
|
## Repository index
|
|
60
103
|
|
|
61
104
|
```txt
|