@moneylion/react-native-offer-carousel 1.3.0 → 1.4.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/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js +44 -45
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
- package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js +10 -3
- package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
- package/lib/commonjs/components/ErrorBoundary/index.js +34 -0
- package/lib/commonjs/components/ErrorBoundary/index.js.map +1 -0
- package/lib/commonjs/components/Layouts/HeadlineWithDescriptionCard/index.js.map +1 -1
- package/lib/commonjs/components/Modal/AllOffersModal.js +14 -7
- package/lib/commonjs/components/Modal/AllOffersModal.js.map +1 -1
- package/lib/commonjs/components/Modal/OfferDetailsModal.js +13 -6
- package/lib/commonjs/components/Modal/OfferDetailsModal.js.map +1 -1
- package/lib/commonjs/components/MoneyLionOfferCarousel.js +23 -7
- package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
- package/lib/commonjs/config/mocks/cnfContext.js +151 -44
- package/lib/commonjs/config/mocks/cnfContext.js.map +1 -1
- package/lib/commonjs/context/ThemeProvider.js +8 -2
- package/lib/commonjs/context/ThemeProvider.js.map +1 -1
- package/lib/commonjs/utils/getThemeColors.js +24 -0
- package/lib/commonjs/utils/getThemeColors.js.map +1 -0
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js +44 -45
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
- package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js +10 -3
- package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
- package/lib/module/components/ErrorBoundary/index.js +28 -0
- package/lib/module/components/ErrorBoundary/index.js.map +1 -0
- package/lib/module/components/Layouts/HeadlineWithDescriptionCard/index.js.map +1 -1
- package/lib/module/components/Modal/AllOffersModal.js +14 -7
- package/lib/module/components/Modal/AllOffersModal.js.map +1 -1
- package/lib/module/components/Modal/OfferDetailsModal.js +13 -6
- package/lib/module/components/Modal/OfferDetailsModal.js.map +1 -1
- package/lib/module/components/MoneyLionOfferCarousel.js +23 -8
- package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
- package/lib/module/config/mocks/cnfContext.js +151 -44
- package/lib/module/config/mocks/cnfContext.js.map +1 -1
- package/lib/module/context/ThemeProvider.js +8 -2
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/utils/getThemeColors.js +17 -0
- package/lib/module/utils/getThemeColors.js.map +1 -0
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts +312 -89
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/ui/elements/src/components/MarkdownText/components.d.ts +2 -2
- package/lib/typescript/src/capabilities/ui/elements/src/components/MarkdownText/components.d.ts.map +1 -1
- package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts.map +1 -1
- package/lib/typescript/src/components/ErrorBoundary/index.d.ts +20 -0
- package/lib/typescript/src/components/ErrorBoundary/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Layouts/HeadlineWithDescriptionCard/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Modal/AllOffersModal.d.ts.map +1 -1
- package/lib/typescript/src/components/Modal/OfferDetailsModal.d.ts.map +1 -1
- package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +8 -5
- package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
- package/lib/typescript/src/config/mocks/cnfContext.d.ts.map +1 -1
- package/lib/typescript/src/context/ThemeProvider.d.ts +3 -0
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/utils/getThemeColors.d.ts +8 -0
- package/lib/typescript/src/utils/getThemeColors.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/capabilities/core/src/system/cnfContext/schemas/Brand.ts +51 -46
- package/src/capabilities/ui/elements/src/components/MarkdownText/components.tsx +1 -1
- package/src/components/DynamicOffers/Render/DynamicOffersRender.tsx +10 -3
- package/src/components/ErrorBoundary/index.tsx +40 -0
- package/src/components/Layouts/HeadlineWithDescriptionCard/index.tsx +1 -0
- package/src/components/Modal/AllOffersModal.tsx +19 -5
- package/src/components/Modal/OfferDetailsModal.tsx +12 -5
- package/src/components/MoneyLionOfferCarousel.tsx +49 -13
- package/src/config/mocks/cnfContext.ts +40 -44
- package/src/context/ThemeProvider.tsx +12 -1
- package/src/utils/getThemeColors.ts +29 -0
|
@@ -68,8 +68,10 @@ const defaultFontFamily: FontFamily = {
|
|
|
68
68
|
interface ThemeContextType {
|
|
69
69
|
theme: ThemeColors;
|
|
70
70
|
fontFamily: FontFamily;
|
|
71
|
+
isDarkTheme: boolean;
|
|
71
72
|
updateTheme: (newTheme: Partial<ThemeColors>) => void;
|
|
72
73
|
updateFontFamily: (newFontFamily: Partial<FontFamily>) => void;
|
|
74
|
+
setIsDarkTheme: (isDark: boolean) => void;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
export const ThemeContext = createContext<ThemeContextType | null>(null);
|
|
@@ -85,12 +87,14 @@ export const useTheme = () => {
|
|
|
85
87
|
interface ThemeProviderProps {
|
|
86
88
|
themeColors?: ThemeColors;
|
|
87
89
|
fontFamily?: Partial<FontFamily>;
|
|
90
|
+
isDarkTheme?: boolean;
|
|
88
91
|
children: ReactNode;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
export const ThemeProvider: FC<ThemeProviderProps> = ({
|
|
92
|
-
themeColors = {} as ThemeColors,
|
|
95
|
+
themeColors = {} as ThemeColors,
|
|
93
96
|
fontFamily = {},
|
|
97
|
+
isDarkTheme = false,
|
|
94
98
|
children,
|
|
95
99
|
}) => {
|
|
96
100
|
const [theme, setTheme] = useState<ThemeColors>(themeColors);
|
|
@@ -98,6 +102,7 @@ export const ThemeProvider: FC<ThemeProviderProps> = ({
|
|
|
98
102
|
...defaultFontFamily,
|
|
99
103
|
...fontFamily,
|
|
100
104
|
});
|
|
105
|
+
const [darkTheme, setDarkTheme] = useState<boolean>(isDarkTheme);
|
|
101
106
|
|
|
102
107
|
const updateTheme = (newTheme: Partial<ThemeColors>) => {
|
|
103
108
|
setTheme((prevTheme) => ({
|
|
@@ -113,11 +118,17 @@ export const ThemeProvider: FC<ThemeProviderProps> = ({
|
|
|
113
118
|
}));
|
|
114
119
|
};
|
|
115
120
|
|
|
121
|
+
const setIsDarkTheme = (isDark: boolean) => {
|
|
122
|
+
setDarkTheme(isDark);
|
|
123
|
+
};
|
|
124
|
+
|
|
116
125
|
const contextValue = {
|
|
117
126
|
theme,
|
|
118
127
|
fontFamily: fonts,
|
|
128
|
+
isDarkTheme: darkTheme,
|
|
119
129
|
updateTheme,
|
|
120
130
|
updateFontFamily,
|
|
131
|
+
setIsDarkTheme,
|
|
121
132
|
};
|
|
122
133
|
|
|
123
134
|
return (
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReshapedThemeColors } from "../capabilities/core/src/system/cnfContext/schemas/Brand";
|
|
2
|
+
import { localCnfContext } from "../config/mocks/cnfContext";
|
|
3
|
+
import type { ThemeColors } from "../context/ThemeProvider";
|
|
4
|
+
|
|
5
|
+
/** This util checks for missing theme colors from reshapedThemeColors in the API response
|
|
6
|
+
* and merges them with fallback theme colors.
|
|
7
|
+
* It returns a ThemeColors object with the appropriate colors based on the isDarkTheme flag.
|
|
8
|
+
*/
|
|
9
|
+
export const getThemeColors = (
|
|
10
|
+
reshapedThemeColors: ReshapedThemeColors,
|
|
11
|
+
isDarkTheme: boolean = false
|
|
12
|
+
): ThemeColors => {
|
|
13
|
+
const defaultThemeColors = localCnfContext.brand.reshapedThemeColors;
|
|
14
|
+
|
|
15
|
+
const themeColors = Object.keys(defaultThemeColors).reduce((acc, key) => {
|
|
16
|
+
const reshapedColor = reshapedThemeColors[key as keyof ReshapedThemeColors];
|
|
17
|
+
const defaultColor = defaultThemeColors[key as keyof ReshapedThemeColors];
|
|
18
|
+
|
|
19
|
+
const themeColor = reshapedColor ?? defaultColor;
|
|
20
|
+
|
|
21
|
+
acc[key as keyof ThemeColors] = isDarkTheme
|
|
22
|
+
? (themeColor.hexDark ?? themeColor.hex)
|
|
23
|
+
: themeColor.hex;
|
|
24
|
+
|
|
25
|
+
return acc;
|
|
26
|
+
}, {} as ThemeColors);
|
|
27
|
+
|
|
28
|
+
return themeColors;
|
|
29
|
+
};
|