@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.
Files changed (67) hide show
  1. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js +44 -45
  2. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
  3. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js +10 -3
  4. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  5. package/lib/commonjs/components/ErrorBoundary/index.js +34 -0
  6. package/lib/commonjs/components/ErrorBoundary/index.js.map +1 -0
  7. package/lib/commonjs/components/Layouts/HeadlineWithDescriptionCard/index.js.map +1 -1
  8. package/lib/commonjs/components/Modal/AllOffersModal.js +14 -7
  9. package/lib/commonjs/components/Modal/AllOffersModal.js.map +1 -1
  10. package/lib/commonjs/components/Modal/OfferDetailsModal.js +13 -6
  11. package/lib/commonjs/components/Modal/OfferDetailsModal.js.map +1 -1
  12. package/lib/commonjs/components/MoneyLionOfferCarousel.js +23 -7
  13. package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
  14. package/lib/commonjs/config/mocks/cnfContext.js +151 -44
  15. package/lib/commonjs/config/mocks/cnfContext.js.map +1 -1
  16. package/lib/commonjs/context/ThemeProvider.js +8 -2
  17. package/lib/commonjs/context/ThemeProvider.js.map +1 -1
  18. package/lib/commonjs/utils/getThemeColors.js +24 -0
  19. package/lib/commonjs/utils/getThemeColors.js.map +1 -0
  20. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js +44 -45
  21. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
  22. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js +10 -3
  23. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  24. package/lib/module/components/ErrorBoundary/index.js +28 -0
  25. package/lib/module/components/ErrorBoundary/index.js.map +1 -0
  26. package/lib/module/components/Layouts/HeadlineWithDescriptionCard/index.js.map +1 -1
  27. package/lib/module/components/Modal/AllOffersModal.js +14 -7
  28. package/lib/module/components/Modal/AllOffersModal.js.map +1 -1
  29. package/lib/module/components/Modal/OfferDetailsModal.js +13 -6
  30. package/lib/module/components/Modal/OfferDetailsModal.js.map +1 -1
  31. package/lib/module/components/MoneyLionOfferCarousel.js +23 -8
  32. package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
  33. package/lib/module/config/mocks/cnfContext.js +151 -44
  34. package/lib/module/config/mocks/cnfContext.js.map +1 -1
  35. package/lib/module/context/ThemeProvider.js +8 -2
  36. package/lib/module/context/ThemeProvider.js.map +1 -1
  37. package/lib/module/utils/getThemeColors.js +17 -0
  38. package/lib/module/utils/getThemeColors.js.map +1 -0
  39. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts +312 -89
  40. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts.map +1 -1
  41. package/lib/typescript/src/capabilities/ui/elements/src/components/MarkdownText/components.d.ts +2 -2
  42. package/lib/typescript/src/capabilities/ui/elements/src/components/MarkdownText/components.d.ts.map +1 -1
  43. package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts.map +1 -1
  44. package/lib/typescript/src/components/ErrorBoundary/index.d.ts +20 -0
  45. package/lib/typescript/src/components/ErrorBoundary/index.d.ts.map +1 -0
  46. package/lib/typescript/src/components/Layouts/HeadlineWithDescriptionCard/index.d.ts.map +1 -1
  47. package/lib/typescript/src/components/Modal/AllOffersModal.d.ts.map +1 -1
  48. package/lib/typescript/src/components/Modal/OfferDetailsModal.d.ts.map +1 -1
  49. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +8 -5
  50. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
  51. package/lib/typescript/src/config/mocks/cnfContext.d.ts.map +1 -1
  52. package/lib/typescript/src/context/ThemeProvider.d.ts +3 -0
  53. package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
  54. package/lib/typescript/src/utils/getThemeColors.d.ts +8 -0
  55. package/lib/typescript/src/utils/getThemeColors.d.ts.map +1 -0
  56. package/package.json +1 -1
  57. package/src/capabilities/core/src/system/cnfContext/schemas/Brand.ts +51 -46
  58. package/src/capabilities/ui/elements/src/components/MarkdownText/components.tsx +1 -1
  59. package/src/components/DynamicOffers/Render/DynamicOffersRender.tsx +10 -3
  60. package/src/components/ErrorBoundary/index.tsx +40 -0
  61. package/src/components/Layouts/HeadlineWithDescriptionCard/index.tsx +1 -0
  62. package/src/components/Modal/AllOffersModal.tsx +19 -5
  63. package/src/components/Modal/OfferDetailsModal.tsx +12 -5
  64. package/src/components/MoneyLionOfferCarousel.tsx +49 -13
  65. package/src/config/mocks/cnfContext.ts +40 -44
  66. package/src/context/ThemeProvider.tsx +12 -1
  67. 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, // should be safe to assert as ThemePalette since the fallback colors are already handled by the consumers of ThemeProvider
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
+ };