@rootnative/core 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +185 -0
- package/dist/chunk-DC35U5WG.mjs +328 -0
- package/dist/create-theme/index.d.mts +87 -0
- package/dist/create-theme/index.mjs +207 -0
- package/dist/index.d.mts +186 -0
- package/dist/index.mjs +273 -0
- package/dist/types-GiXhVyob.d.mts +209 -0
- package/llms.txt +234 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 RootNative
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# @rootnative/core
|
|
2
|
+
|
|
3
|
+
Design-system agnostic theme engine for [RootNative UI](https://github.com/rootnative/ui) — a React Native component library. Ships with Material Design 3 out of the box.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @rootnative/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react >=18`, `react-native >=0.72`
|
|
12
|
+
|
|
13
|
+
Optional: `@material/material-color-utilities >=0.4` — only needed for `createMaterialTheme`.
|
|
14
|
+
|
|
15
|
+
## Quick start (Material Design 3)
|
|
16
|
+
|
|
17
|
+
Wrap your app root with `ThemeProvider`:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { ThemeProvider } from '@rootnative/core'
|
|
21
|
+
|
|
22
|
+
export default function App() {
|
|
23
|
+
return (
|
|
24
|
+
<ThemeProvider>
|
|
25
|
+
{/* Your app */}
|
|
26
|
+
</ThemeProvider>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
### ThemeProvider
|
|
34
|
+
|
|
35
|
+
Provides the theme context to all child components. Works with any design system — Material Design 3 or custom themes. Defaults to the MD3 light theme.
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
|------|------|---------|-------------|
|
|
39
|
+
| `theme` | `BaseTheme` | `lightTheme` (MD3) | Theme object |
|
|
40
|
+
| `iconResolver` | `IconResolver` | MaterialCommunityIcons | Resolves string icon names (`leadingIcon="check"`) to icon nodes. Set once at the app root to use Lucide, SF Symbols, custom SVGs, etc. Pre-built adapters: [`@rootnative/icons`](https://www.npmjs.com/package/@rootnative/icons) |
|
|
41
|
+
| `children` | `ReactNode` | — | App content |
|
|
42
|
+
|
|
43
|
+
### useTheme()
|
|
44
|
+
|
|
45
|
+
Returns the current theme from the nearest `ThemeProvider`.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { useTheme } from '@rootnative/core'
|
|
49
|
+
|
|
50
|
+
// MD3 (default)
|
|
51
|
+
const theme = useTheme()
|
|
52
|
+
|
|
53
|
+
// Custom design system
|
|
54
|
+
const theme = useTheme<MyTheme>()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### defineTheme(theme)
|
|
58
|
+
|
|
59
|
+
Type-safe helper for creating custom themes:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { defineTheme } from '@rootnative/core'
|
|
63
|
+
import type { BaseTheme } from '@rootnative/core'
|
|
64
|
+
|
|
65
|
+
const myTheme = defineTheme({
|
|
66
|
+
colors: { brand: '#FF6B00', background: '#FFF', text: '#1A1A1A' },
|
|
67
|
+
typography: { heading: { ... }, body: { ... } },
|
|
68
|
+
shape: { ... },
|
|
69
|
+
spacing: { xs: 4, sm: 8, md: 16, lg: 24, xl: 32 },
|
|
70
|
+
stateLayer: { ... },
|
|
71
|
+
elevation: { ... },
|
|
72
|
+
motion: { ... },
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### createMaterialTheme(seedColor)
|
|
77
|
+
|
|
78
|
+
Generates a complete MD3 light and dark theme from a single seed color using Google's HCT color space.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { createMaterialTheme } from '@rootnative/core/create-theme'
|
|
82
|
+
import { ThemeProvider } from '@rootnative/core'
|
|
83
|
+
|
|
84
|
+
const { lightTheme, darkTheme } = createMaterialTheme('#006A6A')
|
|
85
|
+
|
|
86
|
+
<ThemeProvider theme={lightTheme}>{children}</ThemeProvider>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Requires: `npm install @material/material-color-utilities`
|
|
90
|
+
|
|
91
|
+
### applyRoundness(roundness)
|
|
92
|
+
|
|
93
|
+
Scales the MD3 corner radius tokens by a multiplier — `0` = sharp corners, `1` = default MD3, `2` = double rounding. `cornerNone` stays `0` and `cornerFull` stays `999`.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { lightTheme, applyRoundness } from '@rootnative/core'
|
|
97
|
+
|
|
98
|
+
const sharp: Theme = { ...lightTheme, shape: applyRoundness(0.5) }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### material preset
|
|
102
|
+
|
|
103
|
+
Grouped object with all MD3 theme values:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { material } from '@rootnative/core'
|
|
107
|
+
|
|
108
|
+
material.lightTheme
|
|
109
|
+
material.darkTheme
|
|
110
|
+
material.defaultTopAppBarTokens
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Theme type hierarchy
|
|
114
|
+
|
|
115
|
+
- `BaseTheme` — Generic base. Colors as `Record<string, string>`, typography as `Record<string, TextStyle>`, plus shape, spacing, stateLayer, elevation, motion.
|
|
116
|
+
- `Theme` — MD3 theme. Extends `BaseTheme` with 69 color roles, 15 typography variants, optional `topAppBar` tokens. `MaterialTheme` is an identical alias — use it to disambiguate in multi-design-system codebases.
|
|
117
|
+
|
|
118
|
+
### Theme structure
|
|
119
|
+
|
|
120
|
+
| Token group | Description |
|
|
121
|
+
|-------------|-------------|
|
|
122
|
+
| `colors` | Design-system specific color roles (`Record<string, string>`) |
|
|
123
|
+
| `typography` | Type scale variants (`Record<string, TextStyle>`) |
|
|
124
|
+
| `shape` | Corner radius tokens (none through full) |
|
|
125
|
+
| `spacing` | Spacing scale (xs, sm, md, lg, xl) |
|
|
126
|
+
| `elevation` | Shadow levels 0–3 |
|
|
127
|
+
| `stateLayer` | Opacity values for pressed, focused, hovered, disabled |
|
|
128
|
+
| `motion` | Duration and easing tokens |
|
|
129
|
+
|
|
130
|
+
### Custom MD3 theme
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { lightTheme } from '@rootnative/core'
|
|
134
|
+
import type { Theme } from '@rootnative/core'
|
|
135
|
+
|
|
136
|
+
const custom: Theme = {
|
|
137
|
+
...lightTheme,
|
|
138
|
+
colors: { ...lightTheme.colors, primary: '#006A6A', onPrimary: '#FFFFFF' },
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
<ThemeProvider theme={custom}>{children}</ThemeProvider>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Dark theme
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { ThemeProvider, darkTheme } from '@rootnative/core'
|
|
148
|
+
|
|
149
|
+
<ThemeProvider theme={darkTheme}>{children}</ThemeProvider>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### useBreakpoint()
|
|
153
|
+
|
|
154
|
+
Returns the current MD3 window size class: `'compact'` | `'medium'` | `'expanded'` | `'large'` | `'extraLarge'`.
|
|
155
|
+
|
|
156
|
+
### useBreakpointValue(values)
|
|
157
|
+
|
|
158
|
+
Returns a value based on the current breakpoint with cascade fallback.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
const columns = useBreakpointValue({ compact: 1, medium: 2, expanded: 4 })
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Exports
|
|
165
|
+
|
|
166
|
+
- `ThemeProvider` — Theme context provider (works with any design system, defaults to MD3)
|
|
167
|
+
- `useTheme` — Access current theme (generic)
|
|
168
|
+
- `useIconResolver` — Access the configured icon resolver
|
|
169
|
+
- `defineTheme` — Type-safe theme creation helper
|
|
170
|
+
- `createMaterialTheme` — Generate MD3 themes from a seed color (import from `@rootnative/core/create-theme`)
|
|
171
|
+
- `applyRoundness` — Scale MD3 corner radius tokens by a multiplier
|
|
172
|
+
- `material` — MD3 preset object (`lightTheme`, `darkTheme`, `defaultTopAppBarTokens`)
|
|
173
|
+
- `useBreakpoint` / `breakpoints` — Current window size class
|
|
174
|
+
- `useBreakpointValue` — Responsive values
|
|
175
|
+
- `lightTheme` / `darkTheme` — Built-in MD3 themes
|
|
176
|
+
- `defaultTopAppBarTokens` — MD3 top app bar defaults
|
|
177
|
+
- `BaseTheme`, `Theme`, `MaterialTheme`, `Colors`, `Typography`, `Shape`, `Spacing`, `Elevation`, `StateLayer`, `Motion`, `TopAppBarTokens`, `IconResolver`, `IconRenderProps`, `ThemeProviderProps`, `Breakpoint`, `BreakpointValues` — Types
|
|
178
|
+
|
|
179
|
+
## Docs
|
|
180
|
+
|
|
181
|
+
https://rootnative.github.io/ui/
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// src/theme/topAppBar.ts
|
|
2
|
+
var defaultTopAppBarTokens = {
|
|
3
|
+
horizontalPadding: 4,
|
|
4
|
+
titleStartInset: 12,
|
|
5
|
+
smallContainerHeight: 64,
|
|
6
|
+
mediumContainerHeight: 112,
|
|
7
|
+
largeContainerHeight: 152,
|
|
8
|
+
topRowHeight: 64,
|
|
9
|
+
sideSlotMinHeight: 48,
|
|
10
|
+
iconFrameSize: 48,
|
|
11
|
+
mediumTitleBottomPadding: 24,
|
|
12
|
+
largeTitleBottomPadding: 28
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/theme/typography.ts
|
|
16
|
+
import { Platform } from "react-native";
|
|
17
|
+
var defaultFontFamily = Platform.select({
|
|
18
|
+
android: "Roboto",
|
|
19
|
+
ios: "System",
|
|
20
|
+
web: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
|
21
|
+
default: "System"
|
|
22
|
+
});
|
|
23
|
+
var defaultTypography = {
|
|
24
|
+
displayLarge: {
|
|
25
|
+
fontFamily: defaultFontFamily,
|
|
26
|
+
fontSize: 57,
|
|
27
|
+
fontWeight: "400",
|
|
28
|
+
lineHeight: 64,
|
|
29
|
+
letterSpacing: -0.25
|
|
30
|
+
},
|
|
31
|
+
displayMedium: {
|
|
32
|
+
fontFamily: defaultFontFamily,
|
|
33
|
+
fontSize: 45,
|
|
34
|
+
fontWeight: "400",
|
|
35
|
+
lineHeight: 52,
|
|
36
|
+
letterSpacing: 0
|
|
37
|
+
},
|
|
38
|
+
displaySmall: {
|
|
39
|
+
fontFamily: defaultFontFamily,
|
|
40
|
+
fontSize: 36,
|
|
41
|
+
fontWeight: "400",
|
|
42
|
+
lineHeight: 44,
|
|
43
|
+
letterSpacing: 0
|
|
44
|
+
},
|
|
45
|
+
headlineLarge: {
|
|
46
|
+
fontFamily: defaultFontFamily,
|
|
47
|
+
fontSize: 32,
|
|
48
|
+
fontWeight: "400",
|
|
49
|
+
lineHeight: 40,
|
|
50
|
+
letterSpacing: 0
|
|
51
|
+
},
|
|
52
|
+
headlineMedium: {
|
|
53
|
+
fontFamily: defaultFontFamily,
|
|
54
|
+
fontSize: 28,
|
|
55
|
+
fontWeight: "400",
|
|
56
|
+
lineHeight: 36,
|
|
57
|
+
letterSpacing: 0
|
|
58
|
+
},
|
|
59
|
+
headlineSmall: {
|
|
60
|
+
fontFamily: defaultFontFamily,
|
|
61
|
+
fontSize: 24,
|
|
62
|
+
fontWeight: "400",
|
|
63
|
+
lineHeight: 32,
|
|
64
|
+
letterSpacing: 0
|
|
65
|
+
},
|
|
66
|
+
titleLarge: {
|
|
67
|
+
fontFamily: defaultFontFamily,
|
|
68
|
+
fontSize: 22,
|
|
69
|
+
fontWeight: "400",
|
|
70
|
+
lineHeight: 28,
|
|
71
|
+
letterSpacing: 0
|
|
72
|
+
},
|
|
73
|
+
titleMedium: {
|
|
74
|
+
fontFamily: defaultFontFamily,
|
|
75
|
+
fontSize: 16,
|
|
76
|
+
fontWeight: "500",
|
|
77
|
+
lineHeight: 24,
|
|
78
|
+
letterSpacing: 0.15
|
|
79
|
+
},
|
|
80
|
+
titleSmall: {
|
|
81
|
+
fontFamily: defaultFontFamily,
|
|
82
|
+
fontSize: 14,
|
|
83
|
+
fontWeight: "500",
|
|
84
|
+
lineHeight: 20,
|
|
85
|
+
letterSpacing: 0.1
|
|
86
|
+
},
|
|
87
|
+
bodyLarge: {
|
|
88
|
+
fontFamily: defaultFontFamily,
|
|
89
|
+
fontSize: 16,
|
|
90
|
+
fontWeight: "400",
|
|
91
|
+
lineHeight: 24,
|
|
92
|
+
letterSpacing: 0.5
|
|
93
|
+
},
|
|
94
|
+
bodyMedium: {
|
|
95
|
+
fontFamily: defaultFontFamily,
|
|
96
|
+
fontSize: 14,
|
|
97
|
+
fontWeight: "400",
|
|
98
|
+
lineHeight: 20,
|
|
99
|
+
letterSpacing: 0.25
|
|
100
|
+
},
|
|
101
|
+
bodySmall: {
|
|
102
|
+
fontFamily: defaultFontFamily,
|
|
103
|
+
fontSize: 12,
|
|
104
|
+
fontWeight: "400",
|
|
105
|
+
lineHeight: 16,
|
|
106
|
+
letterSpacing: 0.4
|
|
107
|
+
},
|
|
108
|
+
labelLarge: {
|
|
109
|
+
fontFamily: defaultFontFamily,
|
|
110
|
+
fontSize: 14,
|
|
111
|
+
fontWeight: "500",
|
|
112
|
+
lineHeight: 20,
|
|
113
|
+
letterSpacing: 0.1
|
|
114
|
+
},
|
|
115
|
+
labelMedium: {
|
|
116
|
+
fontFamily: defaultFontFamily,
|
|
117
|
+
fontSize: 12,
|
|
118
|
+
fontWeight: "500",
|
|
119
|
+
lineHeight: 16,
|
|
120
|
+
letterSpacing: 0.5
|
|
121
|
+
},
|
|
122
|
+
labelSmall: {
|
|
123
|
+
fontFamily: defaultFontFamily,
|
|
124
|
+
fontSize: 11,
|
|
125
|
+
fontWeight: "500",
|
|
126
|
+
lineHeight: 16,
|
|
127
|
+
letterSpacing: 0.5
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/theme/light.ts
|
|
132
|
+
var lightTheme = {
|
|
133
|
+
colors: {
|
|
134
|
+
primary: "#6750A4",
|
|
135
|
+
onPrimary: "#FFFFFF",
|
|
136
|
+
primaryContainer: "#EADDFF",
|
|
137
|
+
onPrimaryContainer: "#4F378B",
|
|
138
|
+
primaryFixed: "#EADDFF",
|
|
139
|
+
onPrimaryFixed: "#21005D",
|
|
140
|
+
primaryFixedDim: "#D0BCFF",
|
|
141
|
+
onPrimaryFixedVariant: "#4F378B",
|
|
142
|
+
secondary: "#625B71",
|
|
143
|
+
onSecondary: "#FFFFFF",
|
|
144
|
+
secondaryContainer: "#E8DEF8",
|
|
145
|
+
onSecondaryContainer: "#4A4458",
|
|
146
|
+
secondaryFixed: "#E8DEF8",
|
|
147
|
+
onSecondaryFixed: "#1D192B",
|
|
148
|
+
secondaryFixedDim: "#CCC2DC",
|
|
149
|
+
onSecondaryFixedVariant: "#4A4458",
|
|
150
|
+
tertiary: "#7D5260",
|
|
151
|
+
onTertiary: "#FFFFFF",
|
|
152
|
+
tertiaryContainer: "#FFD8E4",
|
|
153
|
+
onTertiaryContainer: "#633B48",
|
|
154
|
+
tertiaryFixed: "#FFD8E4",
|
|
155
|
+
onTertiaryFixed: "#31111D",
|
|
156
|
+
tertiaryFixedDim: "#EFB8C8",
|
|
157
|
+
onTertiaryFixedVariant: "#633B48",
|
|
158
|
+
error: "#B3261E",
|
|
159
|
+
onError: "#FFFFFF",
|
|
160
|
+
errorContainer: "#F9DEDC",
|
|
161
|
+
onErrorContainer: "#852221",
|
|
162
|
+
background: "#FEF7FF",
|
|
163
|
+
onBackground: "#1D1B20",
|
|
164
|
+
surface: "#FEF7FF",
|
|
165
|
+
surfaceDim: "#DED8E1",
|
|
166
|
+
surfaceBright: "#FEF7FF",
|
|
167
|
+
surfaceContainerLowest: "#FFFFFF",
|
|
168
|
+
surfaceContainerLow: "#F7F2FA",
|
|
169
|
+
surfaceContainer: "#F3EDF7",
|
|
170
|
+
surfaceContainerHigh: "#ECE6F0",
|
|
171
|
+
surfaceContainerHighest: "#E6E0E9",
|
|
172
|
+
onSurface: "#1D1B20",
|
|
173
|
+
surfaceVariant: "#E7E0EC",
|
|
174
|
+
onSurfaceVariant: "#49454F",
|
|
175
|
+
outline: "#79747E",
|
|
176
|
+
outlineVariant: "#CAC4D0",
|
|
177
|
+
surfaceTint: "#6750A4",
|
|
178
|
+
shadow: "#000000",
|
|
179
|
+
scrim: "#000000",
|
|
180
|
+
inverseSurface: "#322F35",
|
|
181
|
+
inverseOnSurface: "#F5EFF7",
|
|
182
|
+
inversePrimary: "#D0BCFF"
|
|
183
|
+
},
|
|
184
|
+
typography: defaultTypography,
|
|
185
|
+
shape: {
|
|
186
|
+
roundness: 1,
|
|
187
|
+
cornerNone: 0,
|
|
188
|
+
cornerExtraSmall: 4,
|
|
189
|
+
cornerSmall: 8,
|
|
190
|
+
cornerMedium: 12,
|
|
191
|
+
cornerLarge: 16,
|
|
192
|
+
cornerExtraLarge: 28,
|
|
193
|
+
cornerFull: 999
|
|
194
|
+
},
|
|
195
|
+
spacing: {
|
|
196
|
+
xs: 4,
|
|
197
|
+
sm: 8,
|
|
198
|
+
md: 16,
|
|
199
|
+
lg: 24,
|
|
200
|
+
xl: 32
|
|
201
|
+
},
|
|
202
|
+
topAppBar: defaultTopAppBarTokens,
|
|
203
|
+
stateLayer: {
|
|
204
|
+
pressedOpacity: 0.1,
|
|
205
|
+
focusedOpacity: 0.1,
|
|
206
|
+
hoveredOpacity: 0.08,
|
|
207
|
+
draggedOpacity: 0.16,
|
|
208
|
+
disabledOpacity: 0.38,
|
|
209
|
+
disabledContainerOpacity: 0.12
|
|
210
|
+
},
|
|
211
|
+
elevation: {
|
|
212
|
+
level0: {
|
|
213
|
+
shadowColor: "#000000",
|
|
214
|
+
shadowOffset: {
|
|
215
|
+
width: 0,
|
|
216
|
+
height: 0
|
|
217
|
+
},
|
|
218
|
+
shadowOpacity: 0,
|
|
219
|
+
shadowRadius: 0,
|
|
220
|
+
elevation: 0
|
|
221
|
+
},
|
|
222
|
+
level1: {
|
|
223
|
+
shadowColor: "#000000",
|
|
224
|
+
shadowOffset: {
|
|
225
|
+
width: 0,
|
|
226
|
+
height: 1
|
|
227
|
+
},
|
|
228
|
+
shadowOpacity: 0.16,
|
|
229
|
+
shadowRadius: 2,
|
|
230
|
+
elevation: 1
|
|
231
|
+
},
|
|
232
|
+
level2: {
|
|
233
|
+
shadowColor: "#000000",
|
|
234
|
+
shadowOffset: {
|
|
235
|
+
width: 0,
|
|
236
|
+
height: 2
|
|
237
|
+
},
|
|
238
|
+
shadowOpacity: 0.2,
|
|
239
|
+
shadowRadius: 4,
|
|
240
|
+
elevation: 3
|
|
241
|
+
},
|
|
242
|
+
level3: {
|
|
243
|
+
shadowColor: "#000000",
|
|
244
|
+
shadowOffset: {
|
|
245
|
+
width: 0,
|
|
246
|
+
height: 4
|
|
247
|
+
},
|
|
248
|
+
shadowOpacity: 0.24,
|
|
249
|
+
shadowRadius: 8,
|
|
250
|
+
elevation: 6
|
|
251
|
+
},
|
|
252
|
+
level4: {
|
|
253
|
+
shadowColor: "#000000",
|
|
254
|
+
shadowOffset: {
|
|
255
|
+
width: 0,
|
|
256
|
+
height: 6
|
|
257
|
+
},
|
|
258
|
+
shadowOpacity: 0.26,
|
|
259
|
+
shadowRadius: 10,
|
|
260
|
+
elevation: 8
|
|
261
|
+
},
|
|
262
|
+
level5: {
|
|
263
|
+
shadowColor: "#000000",
|
|
264
|
+
shadowOffset: {
|
|
265
|
+
width: 0,
|
|
266
|
+
height: 8
|
|
267
|
+
},
|
|
268
|
+
shadowOpacity: 0.28,
|
|
269
|
+
shadowRadius: 12,
|
|
270
|
+
elevation: 12
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
motion: {
|
|
274
|
+
durationShort1: 50,
|
|
275
|
+
durationShort2: 100,
|
|
276
|
+
durationShort3: 150,
|
|
277
|
+
durationShort4: 200,
|
|
278
|
+
durationMedium1: 250,
|
|
279
|
+
durationMedium2: 300,
|
|
280
|
+
durationMedium3: 350,
|
|
281
|
+
durationMedium4: 400,
|
|
282
|
+
durationLong1: 450,
|
|
283
|
+
durationLong2: 500,
|
|
284
|
+
durationLong3: 550,
|
|
285
|
+
durationLong4: 600,
|
|
286
|
+
durationExtraLong1: 700,
|
|
287
|
+
durationExtraLong2: 800,
|
|
288
|
+
durationExtraLong3: 900,
|
|
289
|
+
durationExtraLong4: 1e3,
|
|
290
|
+
easingLinear: "cubic-bezier(0, 0, 1, 1)",
|
|
291
|
+
easingStandard: "cubic-bezier(0.2, 0, 0, 1)",
|
|
292
|
+
easingStandardAccelerate: "cubic-bezier(0.3, 0, 1, 1)",
|
|
293
|
+
easingStandardDecelerate: "cubic-bezier(0, 0, 0, 1)",
|
|
294
|
+
easingEmphasized: "cubic-bezier(0.2, 0, 0, 1)",
|
|
295
|
+
easingEmphasizedAccelerate: "cubic-bezier(0.3, 0, 0.8, 0.15)",
|
|
296
|
+
easingEmphasizedDecelerate: "cubic-bezier(0.05, 0.7, 0.1, 1)"
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/theme/applyRoundness.ts
|
|
301
|
+
var BASE_SHAPE = {
|
|
302
|
+
cornerNone: 0,
|
|
303
|
+
cornerExtraSmall: 4,
|
|
304
|
+
cornerSmall: 8,
|
|
305
|
+
cornerMedium: 12,
|
|
306
|
+
cornerLarge: 16,
|
|
307
|
+
cornerExtraLarge: 28,
|
|
308
|
+
cornerFull: 999
|
|
309
|
+
};
|
|
310
|
+
function applyRoundness(roundness) {
|
|
311
|
+
return {
|
|
312
|
+
roundness,
|
|
313
|
+
cornerNone: BASE_SHAPE.cornerNone,
|
|
314
|
+
cornerExtraSmall: Math.round(BASE_SHAPE.cornerExtraSmall * roundness),
|
|
315
|
+
cornerSmall: Math.round(BASE_SHAPE.cornerSmall * roundness),
|
|
316
|
+
cornerMedium: Math.round(BASE_SHAPE.cornerMedium * roundness),
|
|
317
|
+
cornerLarge: Math.round(BASE_SHAPE.cornerLarge * roundness),
|
|
318
|
+
cornerExtraLarge: Math.round(BASE_SHAPE.cornerExtraLarge * roundness),
|
|
319
|
+
cornerFull: BASE_SHAPE.cornerFull
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export {
|
|
324
|
+
defaultTopAppBarTokens,
|
|
325
|
+
defaultTypography,
|
|
326
|
+
lightTheme,
|
|
327
|
+
applyRoundness
|
|
328
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { T as Theme } from '../types-GiXhVyob.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MD3 scheme variant. Each is a spec-defined recipe for deriving the palette
|
|
5
|
+
* from the seed color. `'tonalSpot'` is the Material You default used on
|
|
6
|
+
* Android 12+.
|
|
7
|
+
*/
|
|
8
|
+
type ThemeVariant = 'tonalSpot' | 'neutral' | 'vibrant' | 'expressive' | 'fidelity' | 'content' | 'monochrome' | 'rainbow' | 'fruitSalad';
|
|
9
|
+
type ContrastLevel = 'standard' | 'medium' | 'high';
|
|
10
|
+
/**
|
|
11
|
+
* Custom override (NOT part of the MD3 spec). Forces neutral palettes to
|
|
12
|
+
* chroma 0 for pure-grey surfaces while keeping the variant's colorful
|
|
13
|
+
* primary/secondary/tertiary palettes. Use this for an OLED-near-black /
|
|
14
|
+
* carbon aesthetic. For a fully spec-legal monochrome theme prefer
|
|
15
|
+
* `variant: 'monochrome'`.
|
|
16
|
+
*/
|
|
17
|
+
type SurfaceTone = 'spec' | 'neutral';
|
|
18
|
+
interface SeedAdjustments {
|
|
19
|
+
/** Override HCT chroma for the primary palette. Variant defaults are spec-defined (TonalSpot uses `36`). Raise for richer container colors. NOT part of MD3 spec. */
|
|
20
|
+
primary?: number;
|
|
21
|
+
/** Override HCT chroma for the secondary palette. Variant defaults are spec-defined (TonalSpot uses `16`). Raise for more saturated secondary containers. NOT part of MD3 spec. */
|
|
22
|
+
secondary?: number;
|
|
23
|
+
}
|
|
24
|
+
interface CreateMaterialThemeOptions {
|
|
25
|
+
/** MD3 scheme variant. Each is a spec-defined recipe; pick the one whose colorfulness/hue-shifting matches your brand. @default 'tonalSpot' */
|
|
26
|
+
variant?: ThemeVariant;
|
|
27
|
+
/** Custom font family applied to all typography styles. When omitted, platform defaults are used (Roboto on Android, System on iOS). */
|
|
28
|
+
fontFamily?: string;
|
|
29
|
+
/** Global corner-radius multiplier. `0` = sharp, `1` = default MD3, `2` = double rounding. @default 1 */
|
|
30
|
+
roundness?: number;
|
|
31
|
+
/** MD3 contrast preset. `'standard'` matches the spec; `'medium'` and `'high'` boost on/container contrast for accessibility. @default 'standard' */
|
|
32
|
+
contrastLevel?: ContrastLevel;
|
|
33
|
+
/** **Custom override (deviates from MD3 spec).** `'spec'` keeps the variant's neutral palette as-is. `'neutral'` flattens neutral chroma to 0 for pure-grey / OLED-near-black surfaces. Prefer `variant: 'monochrome'` for spec-legal monochrome themes. @default 'spec' */
|
|
34
|
+
surfaceTone?: SurfaceTone;
|
|
35
|
+
/** **Custom override (deviates from MD3 spec).** Per-palette HCT chroma overrides for cases where the spec-defined variant chromas come out too pastel or too vivid for your brand. */
|
|
36
|
+
seedAdjustments?: SeedAdjustments;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generates a complete Material Design 3 light and dark theme from a single seed color.
|
|
40
|
+
* Uses Google's HCT color space and the official `material-color-utilities` schemes,
|
|
41
|
+
* so all defaults are byte-identical to the MD3 spec.
|
|
42
|
+
*
|
|
43
|
+
* Spec-aligned options (recommended):
|
|
44
|
+
* - `variant` — pick from the 9 MD3 schemes
|
|
45
|
+
* - `contrastLevel` — `'standard' | 'medium' | 'high'` (MD3 accessibility tiers)
|
|
46
|
+
* - `fontFamily`, `roundness` — local layering on top of MD3
|
|
47
|
+
*
|
|
48
|
+
* Explicit overrides (deviate from MD3, use only when the spec doesn't cover your case):
|
|
49
|
+
* - `surfaceTone: 'neutral'` — pure-grey / OLED-near-black surfaces
|
|
50
|
+
* - `seedAdjustments` — per-palette HCT chroma overrides
|
|
51
|
+
*
|
|
52
|
+
* @param seedColor - Hex color string (e.g. '#6750A4', '#FF0000')
|
|
53
|
+
* @returns Object with `lightTheme` and `darkTheme`, both typed as `Theme`
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* import { createMaterialTheme } from '@rootnative/core/create-theme'
|
|
57
|
+
*
|
|
58
|
+
* // Pure MD3 default (TonalSpot variant)
|
|
59
|
+
* const { lightTheme, darkTheme } = createMaterialTheme('#006A6A')
|
|
60
|
+
*
|
|
61
|
+
* // Switch to a different MD3 variant
|
|
62
|
+
* createMaterialTheme('#006A6A', { variant: 'vibrant' })
|
|
63
|
+
*
|
|
64
|
+
* // High-contrast accessibility preset
|
|
65
|
+
* createMaterialTheme('#006A6A', { contrastLevel: 'high' })
|
|
66
|
+
*
|
|
67
|
+
* // Spec-legal monochrome theme
|
|
68
|
+
* createMaterialTheme('#006A6A', { variant: 'monochrome' })
|
|
69
|
+
*
|
|
70
|
+
* // Explicit override: keep colorful primary/secondary, flatten surfaces
|
|
71
|
+
* createMaterialTheme('#006A6A', { surfaceTone: 'neutral' })
|
|
72
|
+
*
|
|
73
|
+
* // Explicit override: punchier container chroma
|
|
74
|
+
* createMaterialTheme('#006A6A', {
|
|
75
|
+
* seedAdjustments: { primary: 60, secondary: 32 },
|
|
76
|
+
* })
|
|
77
|
+
*
|
|
78
|
+
* <ThemeProvider theme={lightTheme}>
|
|
79
|
+
* <App />
|
|
80
|
+
* </ThemeProvider>
|
|
81
|
+
*/
|
|
82
|
+
declare function createMaterialTheme(seedColor: string, options?: CreateMaterialThemeOptions): {
|
|
83
|
+
lightTheme: Theme;
|
|
84
|
+
darkTheme: Theme;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export { createMaterialTheme };
|