@alveole/theme 0.27.0 → 0.29.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/dist/ThemeProvider.d.ts.map +1 -1
- package/dist/ThemeProvider.js +35 -3
- package/dist/helpers/injectVariableCSS.d.ts +2 -2
- package/dist/helpers/injectVariableCSS.d.ts.map +1 -1
- package/dist/helpers/useThemeBuilder.d.ts +2 -2
- package/dist/helpers/useThemeBuilder.d.ts.map +1 -1
- package/dist/type/Theme.d.ts +11 -1
- package/dist/type/Theme.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AACA,OAAc,EAA6B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,aAAa,EAAmB,MAAM,2BAA2B,CAAC;AAE3E,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AACA,OAAc,EAA6B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,aAAa,EAAmB,MAAM,2BAA2B,CAAC;AAE3E,OAAO,KAAK,EAAE,KAAK,EAAyB,MAAM,QAAQ,CAAC;AAkB3D,eAAO,MAAM,aAAa,GAAI,OAAO,iBAAiB,CAAC,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,4CA4C3F,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,KAI3B,CAAC"}
|
package/dist/ThemeProvider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as SystemUI from 'expo-system-ui';
|
|
3
3
|
import React, { createContext, useContext } from 'react';
|
|
4
4
|
import { Platform, StatusBar } from 'react-native';
|
|
@@ -7,22 +7,54 @@ import { useThemeBuilder } from './helpers/useThemeBuilder';
|
|
|
7
7
|
import { ThemeProviderLoader } from './ThemeProviderLoader';
|
|
8
8
|
const ThemeContext = createContext(null);
|
|
9
9
|
const MIN_LOADING_DELAY = 0;
|
|
10
|
+
const DEFAULT_STATUS_BAR = {
|
|
11
|
+
barStyle: 'dark-content',
|
|
12
|
+
backgroundColor: 'white',
|
|
13
|
+
};
|
|
14
|
+
const applyStatusBar = (options) => {
|
|
15
|
+
if (Platform.OS !== 'web') {
|
|
16
|
+
StatusBar.setBarStyle(options.barStyle);
|
|
17
|
+
if (Platform.OS === 'android')
|
|
18
|
+
StatusBar.setBackgroundColor(options.backgroundColor);
|
|
19
|
+
}
|
|
20
|
+
void SystemUI.setBackgroundColorAsync(options.backgroundColor);
|
|
21
|
+
};
|
|
10
22
|
export const ThemeProvider = (props) => {
|
|
11
23
|
const { loader = true, ...builder } = props;
|
|
12
24
|
const theme = useThemeBuilder(builder);
|
|
13
25
|
const [showLoader, setShowLoader] = React.useState(true);
|
|
26
|
+
const currentStatusBarRef = React.useRef(DEFAULT_STATUS_BAR);
|
|
27
|
+
const statusBarStackRef = React.useRef([]);
|
|
28
|
+
const setStatusBar = React.useCallback((options) => {
|
|
29
|
+
const nextStatusBar = { ...currentStatusBarRef.current, ...options };
|
|
30
|
+
statusBarStackRef.current.push(currentStatusBarRef.current);
|
|
31
|
+
currentStatusBarRef.current = nextStatusBar;
|
|
32
|
+
applyStatusBar(nextStatusBar);
|
|
33
|
+
}, []);
|
|
34
|
+
const resetStatusBar = React.useCallback(() => {
|
|
35
|
+
const nextStatusBar = statusBarStackRef.current.pop() ?? DEFAULT_STATUS_BAR;
|
|
36
|
+
currentStatusBarRef.current = nextStatusBar;
|
|
37
|
+
applyStatusBar(nextStatusBar);
|
|
38
|
+
}, []);
|
|
14
39
|
React.useEffect(() => {
|
|
15
40
|
const timeout = setTimeout(() => setShowLoader(false), MIN_LOADING_DELAY);
|
|
16
41
|
return () => clearTimeout(timeout);
|
|
17
42
|
}, []);
|
|
18
43
|
React.useEffect(() => {
|
|
19
|
-
void SystemUI.setBackgroundColorAsync('white');
|
|
20
44
|
if (Platform.OS === 'web')
|
|
21
45
|
injectVariableCSS(theme);
|
|
22
46
|
}, []);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
applyStatusBar(DEFAULT_STATUS_BAR);
|
|
49
|
+
}, []);
|
|
50
|
+
const contextValue = React.useMemo(() => ({
|
|
51
|
+
...theme,
|
|
52
|
+
setStatusBar,
|
|
53
|
+
resetStatusBar,
|
|
54
|
+
}), [resetStatusBar, setStatusBar, theme]);
|
|
23
55
|
if ((!theme.isReady || showLoader) && loader !== false)
|
|
24
56
|
return _jsx(ThemeProviderLoader, {});
|
|
25
|
-
return (
|
|
57
|
+
return _jsx(ThemeContext.Provider, { value: contextValue, children: props.children });
|
|
26
58
|
};
|
|
27
59
|
export const useTheme = () => {
|
|
28
60
|
const ctx = useContext(ThemeContext);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const injectVariableCSS: (theme:
|
|
1
|
+
import type { ThemeBase } from '../type';
|
|
2
|
+
export declare const injectVariableCSS: (theme: ThemeBase) => void;
|
|
3
3
|
//# sourceMappingURL=injectVariableCSS.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectVariableCSS.d.ts","sourceRoot":"","sources":["../../src/helpers/injectVariableCSS.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"injectVariableCSS.d.ts","sourceRoot":"","sources":["../../src/helpers/injectVariableCSS.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAoBzC,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,SAYjD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThemeBase } from '../type';
|
|
2
2
|
import { DeepPartial, Palette } from '../constants';
|
|
3
3
|
export type CustomBuilder = {
|
|
4
4
|
color?: DeepPartial<Palette>;
|
|
5
5
|
};
|
|
6
|
-
export declare function useThemeBuilder(params: CustomBuilder):
|
|
6
|
+
export declare function useThemeBuilder(params: CustomBuilder): ThemeBase & {
|
|
7
7
|
isReady: boolean;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=useThemeBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeBuilder.d.ts","sourceRoot":"","sources":["../../src/helpers/useThemeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useThemeBuilder.d.ts","sourceRoot":"","sources":["../../src/helpers/useThemeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,OAAO,EAKL,WAAW,EAKX,OAAO,EAGR,MAAM,cAAc,CAAC;AAMtB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAkDvF"}
|
package/dist/type/Theme.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import type { StatusBarStyle } from 'react-native';
|
|
1
2
|
import type { Colors, CustomPalette, CustomTypography, Fonts, Grilles, Spacing, SpacingKey, Variant } from '../constants';
|
|
2
3
|
import { Radius, RadiusKey } from '../constants/Radius';
|
|
3
4
|
import { alpha } from '../helpers/alphaColor';
|
|
4
5
|
import { elevationStyle } from '../helpers/elevationStyle';
|
|
5
6
|
import type { Typography } from './Typography';
|
|
6
|
-
export
|
|
7
|
+
export type ThemeStatusBarOptions = {
|
|
8
|
+
barStyle: StatusBarStyle;
|
|
9
|
+
backgroundColor: string;
|
|
10
|
+
};
|
|
11
|
+
export type ThemeStatusBarApi = {
|
|
12
|
+
setStatusBar: (options: Partial<ThemeStatusBarOptions>) => void;
|
|
13
|
+
resetStatusBar: () => void;
|
|
14
|
+
};
|
|
15
|
+
export interface ThemeBase {
|
|
7
16
|
spacing: (key: SpacingKey) => Spacing;
|
|
8
17
|
/** Padding externe responsive : 100 sur mobile, 150 sur desktop */
|
|
9
18
|
externalPadding: () => Spacing;
|
|
@@ -21,4 +30,5 @@ export interface Theme {
|
|
|
21
30
|
alpha: typeof alpha;
|
|
22
31
|
};
|
|
23
32
|
}
|
|
33
|
+
export type Theme = ThemeBase & ThemeStatusBarApi;
|
|
24
34
|
//# sourceMappingURL=Theme.d.ts.map
|
package/dist/type/Theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/type/Theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,OAAO,EACP,UAAU,EACV,OAAO,EACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,
|
|
1
|
+
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/type/Theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,OA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