@rootnative/core 0.0.0-alpha.12 → 0.0.0-alpha.13
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 +6 -2
- package/dist/{chunk-QQ3ME6R7.mjs → chunk-HMQZLDPN.mjs} +32 -7
- package/dist/create-theme/index.mjs +5151 -19
- package/dist/index.mjs +1 -1
- package/llms.txt +44 -5
- package/package.json +4 -10
package/dist/index.mjs
CHANGED
package/llms.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @rootnative/core — Theme System for React Native
|
|
2
2
|
|
|
3
|
-
> Version: 0.0.0-alpha.
|
|
4
|
-
> Peer deps: react >=18, react-native >=0.72, @rootnative/inertia >=0.0.
|
|
5
|
-
>
|
|
3
|
+
> Version: 0.0.0-alpha.13
|
|
4
|
+
> Peer deps: react >=18, react-native >=0.72, @rootnative/inertia >=0.0.8 <0.1.0 (required — every animation runs on it)
|
|
5
|
+
> createMaterialTheme needs no extra install — its color engine (@material/material-color-utilities) is bundled behind the create-theme subpath
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
@@ -20,6 +20,19 @@ export default function App() {
|
|
|
20
20
|
|
|
21
21
|
## API
|
|
22
22
|
|
|
23
|
+
### When to pick which — theme paths
|
|
24
|
+
|
|
25
|
+
Ask this first. Every path below ends in the same `<ThemeProvider theme={...}>`.
|
|
26
|
+
|
|
27
|
+
| You want | Reach for |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| MD3 defaults, no setup | `<ThemeProvider>` alone (light), or `theme={{ light: lightTheme, dark: darkTheme }}` to follow the OS |
|
|
30
|
+
| A full MD3 palette from one brand color | `createMaterialTheme(seed)` from `@rootnative/core/create-theme` |
|
|
31
|
+
| MD3 with a few token overrides | Spread over `lightTheme` / `darkTheme` (see the custom-theme example under ThemeProvider) |
|
|
32
|
+
| MD3 with sharper or rounder corners | The `roundness` option on `createMaterialTheme`, or `applyRoundness()` on an existing theme |
|
|
33
|
+
| A fully custom design system (your own tokens) | `defineTheme<MyTheme>()` + `useTheme<MyTheme>()` |
|
|
34
|
+
| Light/dark switching and persistence | The `{ light, dark }` pair + `useThemeMode()`; add `storage` to persist |
|
|
35
|
+
|
|
23
36
|
### ThemeProvider
|
|
24
37
|
|
|
25
38
|
Wrap your app root to supply the theme to all components. Works with any design system — Material Design 3 or custom themes. Defaults to the MD3 light theme when no theme is provided.
|
|
@@ -148,7 +161,27 @@ Generates a complete MD3 light and dark theme from a single seed color. Uses Goo
|
|
|
148
161
|
Defaults are byte-identical to the upstream MD3 `material-color-utilities` library — pure spec output.
|
|
149
162
|
|
|
150
163
|
**Spec-aligned options:**
|
|
151
|
-
- `variant?: 'tonalSpot' | 'neutral' | 'vibrant' | 'expressive' | 'fidelity' | 'content' | 'monochrome' | 'rainbow' | 'fruitSalad'` — MD3 scheme variant (default `'tonalSpot'`, the Material You default on Android 12+). Each is a spec-defined recipe for deriving the palette. Use `'monochrome'` for spec-legal pure-grey themes, `'vibrant'` for high-colorfulness, etc.
|
|
164
|
+
- `variant?: 'tonalSpot' | 'neutral' | 'vibrant' | 'expressive' | 'fidelity' | 'content' | 'monochrome' | 'rainbow' | 'fruitSalad'` — MD3 scheme variant (default `'tonalSpot'`, the Material You default on Android 12+). Each is a spec-defined recipe for deriving the palette. Use `'monochrome'` for spec-legal pure-grey themes, `'vibrant'` for high-colorfulness, etc. **Two variants move the primary hue away from your seed — see the table below.**
|
|
165
|
+
|
|
166
|
+
**Does the variant keep the seed hue?**
|
|
167
|
+
|
|
168
|
+
Ask this first if the seed is a brand color. `expressive` and `fruitSalad` rotate the primary hue by design — this is correct MD3 behavior, not a defect, but it means the generated `primary` is not your brand color. Example results for the seed `#E07A3F` (a strong orange):
|
|
169
|
+
|
|
170
|
+
| Variant | Light `primary` | Keeps the seed hue? |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| `tonalSpot` | `#8d4e2a` | Yes |
|
|
173
|
+
| `neutral` | — | Yes (low chroma) |
|
|
174
|
+
| `vibrant` | `#9d4300` | Yes |
|
|
175
|
+
| `expressive` | `#585799` | **No — rotates to blue-violet** |
|
|
176
|
+
| `fidelity` | `#9b450b` | Yes — also returns the seed as `primaryContainer` |
|
|
177
|
+
| `content` | `#9b450b` | Yes |
|
|
178
|
+
| `monochrome` | — | Yes (chroma 0) |
|
|
179
|
+
| `rainbow` | `#984714` | Yes |
|
|
180
|
+
| `fruitSalad` | `#974066` | **No — rotates to magenta** |
|
|
181
|
+
|
|
182
|
+
Use `fidelity`, `content`, or `tonalSpot` to keep the seed hue. Pick `expressive` for colorfulness only when the palette does not have to match a brand color.
|
|
183
|
+
|
|
184
|
+
**`fidelity` pins `primaryContainer` to the seed in both modes.** With `variant: 'fidelity'` the seed is returned as `primaryContainer` in the light theme **and** the dark theme (`onPrimaryContainer` stays dark in both). This is upstream MD3 fidelity behavior: the scheme holds the source color exactly. Every other container role gets darker in dark mode, so a bright container with dark text can break the surface ramp. Override `primaryContainer` / `onPrimaryContainer` for the dark theme if the ramp matters more than seed fidelity.
|
|
152
185
|
- `contrastLevel?: 'standard' | 'medium' | 'high'` — MD3 contrast preset (default `'standard'`). Maps to MD3 contrast values `0 / 0.5 / 1.0`. Use `'medium'` or `'high'` for WCAG AAA / low-vision modes.
|
|
153
186
|
- `fontFamily?: string` — Custom font family applied to all 30 typography styles (15 base + 15 emphasized). When omitted, platform defaults are used (Roboto on Android, System on iOS).
|
|
154
187
|
- `roundness?: number` — Global corner-radius multiplier. `0` = sharp corners, `1` = default MD3 (default), `2` = double rounding. Does not affect `cornerNone` or `cornerFull`.
|
|
@@ -198,7 +231,13 @@ Returns: `{ lightTheme: Theme, darkTheme: Theme }`
|
|
|
198
231
|
|
|
199
232
|
The generated themes include all 49 MD3 color roles plus shared tokens (typography, shape, spacing, stateLayer, elevation, motion, topAppBar).
|
|
200
233
|
|
|
201
|
-
|
|
234
|
+
No extra install is needed: `@material/material-color-utilities` is bundled inside `@rootnative/core`, behind the `create-theme` subpath. Projects that never import the subpath never load it.
|
|
235
|
+
|
|
236
|
+
The subpath also imports nothing from `react-native`, so it runs in plain Node — print a palette from a script, check a theme in CI, or feed the roles to a design-token pipeline:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
node -e "import('@rootnative/core/create-theme').then(({ createMaterialTheme }) => console.log(createMaterialTheme('#006A6A').lightTheme.colors))"
|
|
240
|
+
```
|
|
202
241
|
|
|
203
242
|
### applyRoundness(roundness)
|
|
204
243
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootnative/core",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.13",
|
|
4
4
|
"description": "Design-system agnostic theme engine for RootNative UI — a React Native component library. Ships with Material Design 3 out of the box.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,20 +53,14 @@
|
|
|
53
53
|
"md3"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"@rootnative/inertia": ">=0.0.7 <0.1.0",
|
|
56
|
+
"@rootnative/inertia": ">=0.0.8 <0.1.0",
|
|
58
57
|
"react": ">=18.0.0",
|
|
59
58
|
"react-native": ">=0.72.0"
|
|
60
59
|
},
|
|
61
|
-
"peerDependenciesMeta": {
|
|
62
|
-
"@material/material-color-utilities": {
|
|
63
|
-
"optional": true
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
60
|
"devDependencies": {
|
|
67
61
|
"@material/material-color-utilities": "^0.4.0",
|
|
68
62
|
"@react-native/babel-preset": "^0.81.5",
|
|
69
|
-
"@rootnative/inertia": "0.0.
|
|
63
|
+
"@rootnative/inertia": "0.0.8",
|
|
70
64
|
"@testing-library/react-native": "^13.3.3",
|
|
71
65
|
"@types/jest": "^29.5.14",
|
|
72
66
|
"@types/react": "^19.0.0",
|
|
@@ -78,7 +72,7 @@
|
|
|
78
72
|
"typescript": "^5.0.0"
|
|
79
73
|
},
|
|
80
74
|
"scripts": {
|
|
81
|
-
"build": "tsup
|
|
75
|
+
"build": "tsup",
|
|
82
76
|
"typecheck": "tsc --noEmit",
|
|
83
77
|
"test": "jest",
|
|
84
78
|
"lint": "eslint . --max-warnings 0"
|