@rific/auto-paper 0.4.0 → 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 +51 -39
- package/dist/index.d.ts +51 -39
- package/dist/index.js +80 -1580
- package/dist/index.mjs +83 -1580
- 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
|
|
|
@@ -46,8 +43,11 @@ type BlurViewProps = BlurViewProps$1 & {
|
|
|
46
43
|
children?: ReactNode;
|
|
47
44
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
48
45
|
style?: StyleProp<ViewStyle>;
|
|
46
|
+
tintColor?: string;
|
|
47
|
+
tintOpacity?: number;
|
|
48
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
49
49
|
};
|
|
50
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
|
|
50
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
51
51
|
|
|
52
52
|
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
53
53
|
declare namespace BottomNavigationComponent {
|
|
@@ -137,45 +137,53 @@ type ThemeState = {
|
|
|
137
137
|
color: string;
|
|
138
138
|
harmony: ColorHarmony;
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
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>>;
|
|
152
151
|
};
|
|
153
|
-
setAppearance:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
setAppearance: {
|
|
153
|
+
(payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
|
|
154
|
+
type: string;
|
|
155
|
+
match(action: {
|
|
156
|
+
type: string;
|
|
157
|
+
}): action is PayloadAction<ThemeAppearance>;
|
|
158
158
|
};
|
|
159
|
-
setBlur:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
setBlur: {
|
|
160
|
+
(payload: boolean): PayloadAction<boolean>;
|
|
161
|
+
type: string;
|
|
162
|
+
match(action: {
|
|
163
|
+
type: string;
|
|
164
|
+
}): action is PayloadAction<boolean>;
|
|
164
165
|
};
|
|
165
|
-
setColor:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
setColor: {
|
|
167
|
+
(payload: string): PayloadAction<string>;
|
|
168
|
+
type: string;
|
|
169
|
+
match(action: {
|
|
170
|
+
type: string;
|
|
171
|
+
}): action is PayloadAction<string>;
|
|
170
172
|
};
|
|
171
|
-
setHarmony:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
setHarmony: {
|
|
174
|
+
(payload: ColorHarmony): PayloadAction<ColorHarmony>;
|
|
175
|
+
type: string;
|
|
176
|
+
match(action: {
|
|
177
|
+
type: string;
|
|
178
|
+
}): action is PayloadAction<ColorHarmony>;
|
|
176
179
|
};
|
|
177
|
-
}
|
|
178
|
-
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;
|
|
179
187
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
180
188
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
181
189
|
declare const selectThemeColor: (state: ThemeState) => string;
|
|
@@ -221,6 +229,10 @@ type RGB = {
|
|
|
221
229
|
};
|
|
222
230
|
declare const getRgb: (value: string) => RGB | null;
|
|
223
231
|
|
|
232
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
233
|
+
|
|
234
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
235
|
+
|
|
224
236
|
declare const isDarkColor: (value: string) => boolean;
|
|
225
237
|
|
|
226
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
238
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
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
|
|
|
@@ -46,8 +43,11 @@ type BlurViewProps = BlurViewProps$1 & {
|
|
|
46
43
|
children?: ReactNode;
|
|
47
44
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
48
45
|
style?: StyleProp<ViewStyle>;
|
|
46
|
+
tintColor?: string;
|
|
47
|
+
tintOpacity?: number;
|
|
48
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
49
49
|
};
|
|
50
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
|
|
50
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
51
51
|
|
|
52
52
|
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
53
53
|
declare namespace BottomNavigationComponent {
|
|
@@ -137,45 +137,53 @@ type ThemeState = {
|
|
|
137
137
|
color: string;
|
|
138
138
|
harmony: ColorHarmony;
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
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>>;
|
|
152
151
|
};
|
|
153
|
-
setAppearance:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
setAppearance: {
|
|
153
|
+
(payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
|
|
154
|
+
type: string;
|
|
155
|
+
match(action: {
|
|
156
|
+
type: string;
|
|
157
|
+
}): action is PayloadAction<ThemeAppearance>;
|
|
158
158
|
};
|
|
159
|
-
setBlur:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
setBlur: {
|
|
160
|
+
(payload: boolean): PayloadAction<boolean>;
|
|
161
|
+
type: string;
|
|
162
|
+
match(action: {
|
|
163
|
+
type: string;
|
|
164
|
+
}): action is PayloadAction<boolean>;
|
|
164
165
|
};
|
|
165
|
-
setColor:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
setColor: {
|
|
167
|
+
(payload: string): PayloadAction<string>;
|
|
168
|
+
type: string;
|
|
169
|
+
match(action: {
|
|
170
|
+
type: string;
|
|
171
|
+
}): action is PayloadAction<string>;
|
|
170
172
|
};
|
|
171
|
-
setHarmony:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
setHarmony: {
|
|
174
|
+
(payload: ColorHarmony): PayloadAction<ColorHarmony>;
|
|
175
|
+
type: string;
|
|
176
|
+
match(action: {
|
|
177
|
+
type: string;
|
|
178
|
+
}): action is PayloadAction<ColorHarmony>;
|
|
176
179
|
};
|
|
177
|
-
}
|
|
178
|
-
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;
|
|
179
187
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
180
188
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
181
189
|
declare const selectThemeColor: (state: ThemeState) => string;
|
|
@@ -221,6 +229,10 @@ type RGB = {
|
|
|
221
229
|
};
|
|
222
230
|
declare const getRgb: (value: string) => RGB | null;
|
|
223
231
|
|
|
232
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
233
|
+
|
|
234
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
235
|
+
|
|
224
236
|
declare const isDarkColor: (value: string) => boolean;
|
|
225
237
|
|
|
226
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
238
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|