@matteoaliano/forest-ui 0.8.9 → 1.0.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 CHANGED
@@ -57,20 +57,14 @@ Because `ForestProvider` is a client component, wrap your app in a client bounda
57
57
 
58
58
  ## Theme Presets
59
59
 
60
- Three presets are available:
61
-
62
- | Preset | Use Case |
63
- |--------|----------|
64
- | `forest-agency` | Internal tools + partner agencies (default) |
65
- | `forest-external` | Client-facing products |
66
- | `forest-internal` | Internal tools |
60
+ The built-in preset is `forest-alkemy-plus`, which is also the default theme applied when no `preset` is set. Register your own with `registerPreset()`.
67
61
 
68
62
  ### Using a Preset
69
63
 
70
64
  ```tsx
71
65
  import { ForestProvider } from '@matteoaliano/forest-ui';
72
66
 
73
- <ForestProvider preset="forest-external">
67
+ <ForestProvider preset="forest-alkemy+">
74
68
  {/* Your app */}
75
69
  </ForestProvider>
76
70
  ```
@@ -78,17 +72,67 @@ import { ForestProvider } from '@matteoaliano/forest-ui';
78
72
  ### Using a Custom Theme
79
73
 
80
74
  ```tsx
81
- import { ForestProvider, buildTheme } from '@matteoaliano/forest-ui';
82
- import { getPreset } from '@matteoaliano/forest-ui';
75
+ import { ForestProvider, buildTheme, getPreset } from '@matteoaliano/forest-ui';
83
76
 
84
- const preset = getPreset('forest-agency');
85
- const theme = buildTheme(preset.variants.light.tokens);
77
+ const preset = getPreset('forest-alkemy+');
78
+ const theme = buildTheme(preset.tokens, preset.tokensDark);
86
79
 
87
80
  <ForestProvider theme={theme}>
88
81
  {/* Your app */}
89
82
  </ForestProvider>
90
83
  ```
91
84
 
85
+ ## Dark Mode
86
+
87
+ `forest-alkemy-plus` ships a dark color scheme built on MUI's `colorSchemes` (CSS
88
+ variables). It activates on a **`.dark` class**, the same convention as
89
+ `@matteoaliano/forest-web`.
90
+
91
+ **Recommended: `useColorScheme()`** (below) — it puts the class on `<html>` for you,
92
+ so portaled components (Modal, Menu, Tooltip, Popover, which render at
93
+ `document.body`) switch too.
94
+
95
+ ```tsx
96
+ // Manual class toggle: put `dark` on <html> (not a deep wrapper) so portaled
97
+ // content inherits it. A wrapper only darkens its own subtree, leaving
98
+ // modals/menus light.
99
+ document.documentElement.classList.toggle("dark", isDark);
100
+ ```
101
+
102
+ Set the initial scheme with `defaultMode` (`"light"` default, `"dark"`, or
103
+ `"system"` to follow `prefers-color-scheme`):
104
+
105
+ ```tsx
106
+ <ForestProvider preset="forest-alkemy+" defaultMode="system">
107
+ {/* Your app */}
108
+ </ForestProvider>
109
+ ```
110
+
111
+ Toggle programmatically with the re-exported MUI hook:
112
+
113
+ ```tsx
114
+ import { useColorScheme } from '@matteoaliano/forest-ui';
115
+
116
+ function ThemeToggle() {
117
+ const { mode, setMode } = useColorScheme();
118
+ return (
119
+ <button onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')}>
120
+ {mode === 'dark' ? '☀️' : '🌙'}
121
+ </button>
122
+ );
123
+ }
124
+ ```
125
+
126
+ **Next.js App Router** — render `InitColorSchemeScript` at the top of `<body>` to
127
+ prevent a flash of the wrong scheme on load:
128
+
129
+ ```tsx
130
+ import { InitColorSchemeScript } from '@matteoaliano/forest-ui';
131
+
132
+ // app/layout.tsx, first child of <body>
133
+ <InitColorSchemeScript attribute="class" />
134
+ ```
135
+
92
136
  ## Components
93
137
 
94
138
  40+ wrapped MUI components with Forest defaults. See [Storybook](https://storybook.url) for all components.