@rific/auto-paper 0.9.3 → 0.9.4
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 +29 -2
- package/dist/index.d.mts +49 -34
- package/dist/index.d.ts +49 -34
- package/dist/index.js +320 -295
- package/dist/index.mjs +291 -269
- package/package.json +1 -1
- package/src/components/AutoAppearancePicker.tsx +17 -0
- package/src/components/AutoPalettePicker.tsx +21 -0
- package/src/index.ts +3 -0
- package/src/utils/resolveSeedColor.ts +8 -0
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useThemeSettings } from '../useThemeSettings'
|
|
2
|
+
import { type AppearanceIcons, AppearancePicker } from './AppearancePicker'
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
showLabels?: boolean
|
|
6
|
+
icons?: AppearanceIcons
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// AppearancePicker wired straight to the Provider's own ThemeSettings, for the common case where
|
|
10
|
+
// the appearance being edited IS the whole app's own theme. Takes neither `value` nor `onChange`
|
|
11
|
+
// — reads/writes useThemeSettings() itself, so there's nothing for a consumer to wire up. Reach
|
|
12
|
+
// for the plain AppearancePicker instead when it needs to be controlled by something other than
|
|
13
|
+
// the global theme (a local preview before committing, one-off UI unrelated to Provider).
|
|
14
|
+
export const AutoAppearancePicker = (props: Props) => {
|
|
15
|
+
const { settings, set } = useThemeSettings()
|
|
16
|
+
return <AppearancePicker {...props} value={settings.appearance} onChange={(appearance) => set({ appearance })} />
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useThemeSettings } from '../useThemeSettings'
|
|
2
|
+
import { resolveSeedColor } from '../utils/resolveSeedColor'
|
|
3
|
+
import type { SeedColor } from './ColorPicker'
|
|
4
|
+
import { PalettePicker, type PaletteWeights } from './PalettePicker'
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
weights?: PaletteWeights
|
|
8
|
+
colors?: SeedColor[]
|
|
9
|
+
blur?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// PalettePicker wired straight to the Provider's own ThemeSettings — both color AND harmony —
|
|
13
|
+
// for the common case where the palette being edited IS the whole app's own theme. Takes none of
|
|
14
|
+
// `value`/`onChange`/`harmony`/`onHarmonyChange` — reads/writes useThemeSettings() itself
|
|
15
|
+
// (resolveSeedColor narrows ThemeSettings.color's `string | TriadicPalette` down to the plain
|
|
16
|
+
// string PalettePicker's own `value` wants). Reach for the plain PalettePicker instead when it
|
|
17
|
+
// needs to be controlled by something other than the global theme.
|
|
18
|
+
export const AutoPalettePicker = (props: Props) => {
|
|
19
|
+
const { settings, set } = useThemeSettings()
|
|
20
|
+
return <PalettePicker {...props} value={resolveSeedColor(settings.color)} onChange={(color) => set({ color })} harmony={settings.harmony} onHarmonyChange={(harmony) => set({ harmony })} />
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { useBlur } from './BlurContext'
|
|
|
2
2
|
export { Appbar } from './components/Appbar'
|
|
3
3
|
export type { AppearanceIcons } from './components/AppearancePicker'
|
|
4
4
|
export { AppearancePicker } from './components/AppearancePicker'
|
|
5
|
+
export { AutoAppearancePicker } from './components/AutoAppearancePicker'
|
|
6
|
+
export { AutoPalettePicker } from './components/AutoPalettePicker'
|
|
5
7
|
export type { BlurViewProps, ExpoBlurModule } from './components/BlurView'
|
|
6
8
|
export { BlurView } from './components/BlurView'
|
|
7
9
|
export { BottomNavigation } from './components/BottomNavigation'
|
|
@@ -47,6 +49,7 @@ export { getTonalColor } from './utils/getTonalColor'
|
|
|
47
49
|
export type { ColorHarmony, TriadicPalette } from './utils/getTriadicPalette'
|
|
48
50
|
export { getTriadicPalette } from './utils/getTriadicPalette'
|
|
49
51
|
export { isDarkColor } from './utils/isDarkColor'
|
|
52
|
+
export { resolveSeedColor } from './utils/resolveSeedColor'
|
|
50
53
|
export type { AppbarHeaderProps } from 'react-native-paper'
|
|
51
54
|
export type { BottomNavigationProps } from 'react-native-paper'
|
|
52
55
|
export type { BottomNavigationRoute } from 'react-native-paper'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TriadicPalette } from './getTriadicPalette'
|
|
2
|
+
|
|
3
|
+
// ThemeSettings.color is `string | TriadicPalette` — a plain seed hex normally, or an explicit
|
|
4
|
+
// triad when a consumer bypassed harmony math entirely (see the README's own "Explicit triad"
|
|
5
|
+
// section). Anything that needs a single representative color from it — a picker's own `value`,
|
|
6
|
+
// a card's accent — narrows via this: `.primary` is that triad's own seed, so it's the
|
|
7
|
+
// representative color on the rare path where this branch is actually hit.
|
|
8
|
+
export const resolveSeedColor = (color: string | TriadicPalette): string => (typeof color === 'string' ? color : color.primary)
|