@rific/auto-paper 0.5.1 → 0.6.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 +12 -6
- package/dist/index.d.mts +42 -37
- package/dist/index.d.ts +42 -37
- package/dist/index.js +49 -1565
- package/dist/index.mjs +54 -1565
- package/package.json +16 -3
- package/src/BlurContext.tsx +8 -0
- package/src/PaperDefaultsContext.tsx +18 -0
- package/src/ThemeProvider.tsx +69 -0
- package/src/ThemeSettingsContext.ts +30 -0
- package/src/components/Appbar.tsx +22 -0
- package/src/components/AppearancePicker.tsx +16 -0
- package/src/components/BlurView.tsx +52 -0
- package/src/components/BottomNavigation.tsx +38 -0
- package/src/components/Button.tsx +8 -0
- package/src/components/Chip.tsx +15 -0
- package/src/components/ColorPicker.tsx +75 -0
- package/src/components/Dialog.tsx +61 -0
- package/src/components/FAB.tsx +8 -0
- package/src/components/HarmonyPicker.tsx +52 -0
- package/src/components/IconButton.tsx +15 -0
- package/src/components/Menu.tsx +27 -0
- package/src/components/TextInput.tsx +10 -0
- package/src/index.ts +50 -0
- package/src/navigation-bar.ts +13 -0
- package/src/redux/themeSlice.ts +59 -0
- package/src/useComputedTheme.ts +79 -0
- package/src/useThemeSettings.ts +5 -0
- package/src/utils/colorNames.ts +151 -0
- package/src/utils/getBlendedColor.ts +15 -0
- package/src/utils/getHex.ts +21 -0
- package/src/utils/getRgb.ts +65 -0
- package/src/utils/getTintTextColor.ts +13 -0
- package/src/utils/getTonalColor.ts +67 -0
- package/src/utils/getTriadicPalette.ts +103 -0
- package/src/utils/isDarkColor.ts +14 -0
package/README.md
CHANGED
|
@@ -17,18 +17,21 @@ Adaptive theming for [`react-native-paper`](https://callstack.github.io/react-na
|
|
|
17
17
|
npm install @rific/auto-paper
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Required peer dependency:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install react-native
|
|
23
|
+
npm install react-native-paper
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Optional
|
|
26
|
+
Optional peer dependencies:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npm install expo-
|
|
29
|
+
npm install expo-blur # frosted-glass BlurView; without it BlurView renders its solid (non-blur) fallback
|
|
30
|
+
npm install expo-navigation-bar # (>= 56.0.0, SDK 54+) auto-syncs Android nav bar icon style to the theme when BottomNavigation is mounted
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
The exported Redux slice has no dependency on `@reduxjs/toolkit` — it works with RTK stores, vanilla Redux, or no Redux at all.
|
|
34
|
+
|
|
32
35
|
## Usage
|
|
33
36
|
|
|
34
37
|
### Provider (simplest)
|
|
@@ -194,6 +197,7 @@ export default function App() {
|
|
|
194
197
|
| `onChange` | `(settings: ThemeSettings) => void` | Called whenever settings change via `useThemeSettings().set()` |
|
|
195
198
|
| `children` | `ReactNode` | |
|
|
196
199
|
| `defaults` | `PaperDefaults` | Prop defaults for wrapper components (see below) |
|
|
200
|
+
| `onNavBarChange` | `(color: string, dark: boolean) => void` | Overrides the built-in nav bar sync: called on Android when the theme changes while a `BottomNavigation` is mounted, instead of the automatic `expo-navigation-bar` icon-style sync |
|
|
197
201
|
| `onReady` | `() => void` | Called once when the theme first resolves |
|
|
198
202
|
| `statusBarProps` | `StatusBarProps` | Spread over the auto-derived `StatusBar` defaults |
|
|
199
203
|
| `style` | `StyleProp<ViewStyle>` | Applied to the wrapper `View` |
|
|
@@ -249,7 +253,7 @@ import { Appbar } from '@rific/auto-paper'
|
|
|
249
253
|
|
|
250
254
|
### `BottomNavigation`
|
|
251
255
|
|
|
252
|
-
A thin wrapper around `react-native-paper`'s `BottomNavigation` that
|
|
256
|
+
A thin wrapper around `react-native-paper`'s `BottomNavigation` that keeps the Android system navigation bar icons readable: when the optional `expo-navigation-bar` peer is installed, the icon style automatically follows the theme's darkness (edge-to-edge safe — no background color calls). Pass `onNavBarChange` to the `Provider` to take full control instead; with neither, it silently no-ops.
|
|
253
257
|
|
|
254
258
|
```tsx
|
|
255
259
|
import { BottomNavigation } from '@rific/auto-paper'
|
|
@@ -340,7 +344,7 @@ createThemeReducer({ color: '#4caf50' })
|
|
|
340
344
|
### Redux exports
|
|
341
345
|
|
|
342
346
|
```ts
|
|
343
|
-
import { themeReducer, themeActions, selectThemeAppearance, selectThemeColor } from '@rific/auto-paper'
|
|
347
|
+
import { themeReducer, themeActions, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony } from '@rific/auto-paper'
|
|
344
348
|
import type { ThemeState, ThemeAppearance } from '@rific/auto-paper'
|
|
345
349
|
```
|
|
346
350
|
|
|
@@ -348,7 +352,9 @@ import type { ThemeState, ThemeAppearance } from '@rific/auto-paper'
|
|
|
348
352
|
|---|---|
|
|
349
353
|
| `initialize` | `Partial<ThemeState>` |
|
|
350
354
|
| `setAppearance` | `ThemeAppearance` |
|
|
355
|
+
| `setBlur` | `boolean` |
|
|
351
356
|
| `setColor` | `string` |
|
|
357
|
+
| `setHarmony` | `ColorHarmony` |
|
|
352
358
|
|
|
353
359
|
Selectors accept `ThemeState` directly — compose them with your root state selector:
|
|
354
360
|
|
package/dist/index.d.mts
CHANGED
|
@@ -7,9 +7,6 @@ export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, Button
|
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default, { ReactNode } from 'react';
|
|
9
9
|
import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
|
|
10
|
-
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
11
|
-
import { PayloadAction } from '@reduxjs/toolkit';
|
|
12
|
-
import * as redux from 'redux';
|
|
13
10
|
|
|
14
11
|
declare function useBlur(override?: boolean): boolean;
|
|
15
12
|
|
|
@@ -140,45 +137,53 @@ type ThemeState = {
|
|
|
140
137
|
color: string;
|
|
141
138
|
harmony: ColorHarmony;
|
|
142
139
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
harmony: ColorHarmony;
|
|
140
|
+
type PayloadAction<P> = {
|
|
141
|
+
payload: P;
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
declare const themeActions: {
|
|
145
|
+
initialize: {
|
|
146
|
+
(payload: Partial<ThemeState>): PayloadAction<Partial<ThemeState>>;
|
|
147
|
+
type: string;
|
|
148
|
+
match(action: {
|
|
149
|
+
type: string;
|
|
150
|
+
}): action is PayloadAction<Partial<ThemeState>>;
|
|
155
151
|
};
|
|
156
|
-
setAppearance:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
setAppearance: {
|
|
153
|
+
(payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
|
|
154
|
+
type: string;
|
|
155
|
+
match(action: {
|
|
156
|
+
type: string;
|
|
157
|
+
}): action is PayloadAction<ThemeAppearance>;
|
|
161
158
|
};
|
|
162
|
-
setBlur:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
setBlur: {
|
|
160
|
+
(payload: boolean): PayloadAction<boolean>;
|
|
161
|
+
type: string;
|
|
162
|
+
match(action: {
|
|
163
|
+
type: string;
|
|
164
|
+
}): action is PayloadAction<boolean>;
|
|
167
165
|
};
|
|
168
|
-
setColor:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
setColor: {
|
|
167
|
+
(payload: string): PayloadAction<string>;
|
|
168
|
+
type: string;
|
|
169
|
+
match(action: {
|
|
170
|
+
type: string;
|
|
171
|
+
}): action is PayloadAction<string>;
|
|
173
172
|
};
|
|
174
|
-
setHarmony:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
setHarmony: {
|
|
174
|
+
(payload: ColorHarmony): PayloadAction<ColorHarmony>;
|
|
175
|
+
type: string;
|
|
176
|
+
match(action: {
|
|
177
|
+
type: string;
|
|
178
|
+
}): action is PayloadAction<ColorHarmony>;
|
|
179
179
|
};
|
|
180
|
-
}
|
|
181
|
-
declare
|
|
180
|
+
};
|
|
181
|
+
declare function createThemeReducer(initialState?: Partial<ThemeState>): (state: ThemeState | undefined, action: {
|
|
182
|
+
type: string;
|
|
183
|
+
}) => ThemeState;
|
|
184
|
+
declare const themeReducer: (state: ThemeState | undefined, action: {
|
|
185
|
+
type: string;
|
|
186
|
+
}) => ThemeState;
|
|
182
187
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
183
188
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
184
189
|
declare const selectThemeColor: (state: ThemeState) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, Button
|
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default, { ReactNode } from 'react';
|
|
9
9
|
import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
|
|
10
|
-
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
11
|
-
import { PayloadAction } from '@reduxjs/toolkit';
|
|
12
|
-
import * as redux from 'redux';
|
|
13
10
|
|
|
14
11
|
declare function useBlur(override?: boolean): boolean;
|
|
15
12
|
|
|
@@ -140,45 +137,53 @@ type ThemeState = {
|
|
|
140
137
|
color: string;
|
|
141
138
|
harmony: ColorHarmony;
|
|
142
139
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
harmony: ColorHarmony;
|
|
140
|
+
type PayloadAction<P> = {
|
|
141
|
+
payload: P;
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
declare const themeActions: {
|
|
145
|
+
initialize: {
|
|
146
|
+
(payload: Partial<ThemeState>): PayloadAction<Partial<ThemeState>>;
|
|
147
|
+
type: string;
|
|
148
|
+
match(action: {
|
|
149
|
+
type: string;
|
|
150
|
+
}): action is PayloadAction<Partial<ThemeState>>;
|
|
155
151
|
};
|
|
156
|
-
setAppearance:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
setAppearance: {
|
|
153
|
+
(payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
|
|
154
|
+
type: string;
|
|
155
|
+
match(action: {
|
|
156
|
+
type: string;
|
|
157
|
+
}): action is PayloadAction<ThemeAppearance>;
|
|
161
158
|
};
|
|
162
|
-
setBlur:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
setBlur: {
|
|
160
|
+
(payload: boolean): PayloadAction<boolean>;
|
|
161
|
+
type: string;
|
|
162
|
+
match(action: {
|
|
163
|
+
type: string;
|
|
164
|
+
}): action is PayloadAction<boolean>;
|
|
167
165
|
};
|
|
168
|
-
setColor:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
setColor: {
|
|
167
|
+
(payload: string): PayloadAction<string>;
|
|
168
|
+
type: string;
|
|
169
|
+
match(action: {
|
|
170
|
+
type: string;
|
|
171
|
+
}): action is PayloadAction<string>;
|
|
173
172
|
};
|
|
174
|
-
setHarmony:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
setHarmony: {
|
|
174
|
+
(payload: ColorHarmony): PayloadAction<ColorHarmony>;
|
|
175
|
+
type: string;
|
|
176
|
+
match(action: {
|
|
177
|
+
type: string;
|
|
178
|
+
}): action is PayloadAction<ColorHarmony>;
|
|
179
179
|
};
|
|
180
|
-
}
|
|
181
|
-
declare
|
|
180
|
+
};
|
|
181
|
+
declare function createThemeReducer(initialState?: Partial<ThemeState>): (state: ThemeState | undefined, action: {
|
|
182
|
+
type: string;
|
|
183
|
+
}) => ThemeState;
|
|
184
|
+
declare const themeReducer: (state: ThemeState | undefined, action: {
|
|
185
|
+
type: string;
|
|
186
|
+
}) => ThemeState;
|
|
182
187
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
183
188
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
184
189
|
declare const selectThemeColor: (state: ThemeState) => string;
|