react-native-mantine 0.9.0 → 0.10.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 (221) hide show
  1. package/lib/commonjs/components/Button/index.js +52 -17
  2. package/lib/commonjs/components/Button/index.js.map +1 -1
  3. package/lib/commonjs/components/Code/index.js +3 -1
  4. package/lib/commonjs/components/Code/index.js.map +1 -1
  5. package/lib/commonjs/components/Gradient/Gradient.js +70 -0
  6. package/lib/commonjs/components/Gradient/Gradient.js.map +1 -0
  7. package/lib/commonjs/components/Gradient/index.js +19 -0
  8. package/lib/commonjs/components/Gradient/index.js.map +1 -0
  9. package/lib/commonjs/components/Modal/index.js +33 -3
  10. package/lib/commonjs/components/Modal/index.js.map +1 -1
  11. package/lib/commonjs/components/Paper/index.js +1 -76
  12. package/lib/commonjs/components/Paper/index.js.map +1 -1
  13. package/lib/commonjs/components/Text/index.js +27 -8
  14. package/lib/commonjs/components/Text/index.js.map +1 -1
  15. package/lib/commonjs/components/ThemeIcon/index.js +6 -4
  16. package/lib/commonjs/components/ThemeIcon/index.js.map +1 -1
  17. package/lib/commonjs/components/Title/index.js +7 -3
  18. package/lib/commonjs/components/Title/index.js.map +1 -1
  19. package/lib/commonjs/components/index.js +33 -22
  20. package/lib/commonjs/components/index.js.map +1 -1
  21. package/lib/commonjs/theme/create-theme.js +3 -5
  22. package/lib/commonjs/theme/create-theme.js.map +1 -1
  23. package/lib/commonjs/theme/default-theme.js +168 -21
  24. package/lib/commonjs/theme/default-theme.js.map +1 -1
  25. package/lib/commonjs/theme/functions/attach-functions.js +7 -1
  26. package/lib/commonjs/theme/functions/attach-functions.js.map +1 -1
  27. package/lib/commonjs/theme/functions/fns/breakpoints.js +69 -0
  28. package/lib/commonjs/theme/functions/fns/breakpoints.js.map +1 -0
  29. package/lib/commonjs/theme/functions/fns/darken.js +25 -0
  30. package/lib/commonjs/theme/functions/fns/darken.js.map +1 -0
  31. package/lib/commonjs/theme/functions/fns/dimmed.js +19 -0
  32. package/lib/commonjs/theme/functions/fns/dimmed.js.map +1 -0
  33. package/lib/commonjs/theme/functions/fns/gradient/gradient.js +78 -0
  34. package/lib/commonjs/theme/functions/fns/gradient/gradient.js.map +1 -0
  35. package/lib/commonjs/theme/functions/fns/helpers.js +1 -2
  36. package/lib/commonjs/theme/functions/fns/helpers.js.map +1 -1
  37. package/lib/commonjs/theme/functions/fns/index.js +15 -0
  38. package/lib/commonjs/theme/functions/fns/index.js.map +1 -1
  39. package/lib/commonjs/theme/functions/fns/lighten.js +24 -0
  40. package/lib/commonjs/theme/functions/fns/lighten.js.map +1 -0
  41. package/lib/commonjs/theme/functions/fns/primary-shade.js +18 -0
  42. package/lib/commonjs/theme/functions/fns/primary-shade.js.map +1 -0
  43. package/lib/commonjs/theme/functions/fns/shadow.js +107 -0
  44. package/lib/commonjs/theme/functions/fns/shadow.js.map +1 -0
  45. package/lib/commonjs/theme/functions/fns/theme-color/theme-color.js +3 -2
  46. package/lib/commonjs/theme/functions/fns/theme-color/theme-color.js.map +1 -1
  47. package/lib/commonjs/theme/functions/fns/variant.js +7 -6
  48. package/lib/commonjs/theme/functions/fns/variant.js.map +1 -1
  49. package/lib/commonjs/theme/index.js +14 -0
  50. package/lib/commonjs/theme/index.js.map +1 -1
  51. package/lib/commonjs/theme/theme-provider.js +10 -3
  52. package/lib/commonjs/theme/theme-provider.js.map +1 -1
  53. package/lib/commonjs/theme/utils/to-rgba.js +57 -0
  54. package/lib/commonjs/theme/utils/to-rgba.js.map +1 -0
  55. package/lib/module/components/Button/index.js +53 -18
  56. package/lib/module/components/Button/index.js.map +1 -1
  57. package/lib/module/components/Code/index.js +3 -1
  58. package/lib/module/components/Code/index.js.map +1 -1
  59. package/lib/module/components/Gradient/Gradient.js +64 -0
  60. package/lib/module/components/Gradient/Gradient.js.map +1 -0
  61. package/lib/module/components/Gradient/index.js +4 -0
  62. package/lib/module/components/Gradient/index.js.map +1 -0
  63. package/lib/module/components/Modal/index.js +35 -5
  64. package/lib/module/components/Modal/index.js.map +1 -1
  65. package/lib/module/components/Paper/index.js +1 -76
  66. package/lib/module/components/Paper/index.js.map +1 -1
  67. package/lib/module/components/Text/index.js +27 -8
  68. package/lib/module/components/Text/index.js.map +1 -1
  69. package/lib/module/components/ThemeIcon/index.js +6 -4
  70. package/lib/module/components/ThemeIcon/index.js.map +1 -1
  71. package/lib/module/components/Title/index.js +7 -3
  72. package/lib/module/components/Title/index.js.map +1 -1
  73. package/lib/module/components/index.js +1 -0
  74. package/lib/module/components/index.js.map +1 -1
  75. package/lib/module/theme/create-theme.js +3 -5
  76. package/lib/module/theme/create-theme.js.map +1 -1
  77. package/lib/module/theme/default-theme.js +168 -21
  78. package/lib/module/theme/default-theme.js.map +1 -1
  79. package/lib/module/theme/functions/attach-functions.js +7 -1
  80. package/lib/module/theme/functions/attach-functions.js.map +1 -1
  81. package/lib/module/theme/functions/fns/breakpoints.js +64 -0
  82. package/lib/module/theme/functions/fns/breakpoints.js.map +1 -0
  83. package/lib/module/theme/functions/fns/darken.js +22 -0
  84. package/lib/module/theme/functions/fns/darken.js.map +1 -0
  85. package/lib/module/theme/functions/fns/dimmed.js +15 -0
  86. package/lib/module/theme/functions/fns/dimmed.js.map +1 -0
  87. package/lib/module/theme/functions/fns/gradient/gradient.js +74 -0
  88. package/lib/module/theme/functions/fns/gradient/gradient.js.map +1 -0
  89. package/lib/module/theme/functions/fns/helpers.js +1 -2
  90. package/lib/module/theme/functions/fns/helpers.js.map +1 -1
  91. package/lib/module/theme/functions/fns/index.js +15 -0
  92. package/lib/module/theme/functions/fns/index.js.map +1 -1
  93. package/lib/module/theme/functions/fns/lighten.js +21 -0
  94. package/lib/module/theme/functions/fns/lighten.js.map +1 -0
  95. package/lib/module/theme/functions/fns/primary-shade.js +14 -0
  96. package/lib/module/theme/functions/fns/primary-shade.js.map +1 -0
  97. package/lib/module/theme/functions/fns/shadow.js +103 -0
  98. package/lib/module/theme/functions/fns/shadow.js.map +1 -0
  99. package/lib/module/theme/functions/fns/theme-color/theme-color.js +3 -2
  100. package/lib/module/theme/functions/fns/theme-color/theme-color.js.map +1 -1
  101. package/lib/module/theme/functions/fns/variant.js +7 -6
  102. package/lib/module/theme/functions/fns/variant.js.map +1 -1
  103. package/lib/module/theme/index.js +2 -0
  104. package/lib/module/theme/index.js.map +1 -1
  105. package/lib/module/theme/theme-provider.js +10 -3
  106. package/lib/module/theme/theme-provider.js.map +1 -1
  107. package/lib/module/theme/utils/to-rgba.js +53 -0
  108. package/lib/module/theme/utils/to-rgba.js.map +1 -0
  109. package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/src/components/Code/index.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/src/components/Gradient/Gradient.d.ts +32 -0
  112. package/lib/typescript/commonjs/src/components/Gradient/Gradient.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/components/Gradient/index.d.ts +3 -0
  114. package/lib/typescript/commonjs/src/components/Gradient/index.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/components/Modal/index.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/components/Paper/index.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/Text/index.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/components/ThemeIcon/index.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/src/components/Title/index.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/components/index.d.ts +1 -0
  121. package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/theme/create-theme.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/src/theme/default-theme.d.ts +34 -3
  124. package/lib/typescript/commonjs/src/theme/default-theme.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/theme/functions/attach-functions.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/theme/functions/fns/breakpoints.d.ts +15 -0
  127. package/lib/typescript/commonjs/src/theme/functions/fns/breakpoints.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/src/theme/functions/fns/darken.d.ts +8 -0
  129. package/lib/typescript/commonjs/src/theme/functions/fns/darken.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/theme/functions/fns/dimmed.d.ts +9 -0
  131. package/lib/typescript/commonjs/src/theme/functions/fns/dimmed.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts +13 -0
  133. package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts +1 -2
  135. package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts +16 -1
  137. package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/theme/functions/fns/lighten.d.ts +8 -0
  139. package/lib/typescript/commonjs/src/theme/functions/fns/lighten.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/theme/functions/fns/primary-shade.d.ts +7 -0
  141. package/lib/typescript/commonjs/src/theme/functions/fns/primary-shade.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/src/theme/functions/fns/shadow.d.ts +24 -0
  143. package/lib/typescript/commonjs/src/theme/functions/fns/shadow.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/src/theme/functions/fns/theme-color/theme-color.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/theme/functions/fns/variant.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/theme/index.d.ts +4 -0
  147. package/lib/typescript/commonjs/src/theme/index.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/src/theme/theme-provider.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/theme/utils/to-rgba.d.ts +9 -0
  150. package/lib/typescript/commonjs/src/theme/utils/to-rgba.d.ts.map +1 -0
  151. package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
  152. package/lib/typescript/module/src/components/Code/index.d.ts.map +1 -1
  153. package/lib/typescript/module/src/components/Gradient/Gradient.d.ts +32 -0
  154. package/lib/typescript/module/src/components/Gradient/Gradient.d.ts.map +1 -0
  155. package/lib/typescript/module/src/components/Gradient/index.d.ts +3 -0
  156. package/lib/typescript/module/src/components/Gradient/index.d.ts.map +1 -0
  157. package/lib/typescript/module/src/components/Modal/index.d.ts.map +1 -1
  158. package/lib/typescript/module/src/components/Paper/index.d.ts.map +1 -1
  159. package/lib/typescript/module/src/components/Text/index.d.ts.map +1 -1
  160. package/lib/typescript/module/src/components/ThemeIcon/index.d.ts.map +1 -1
  161. package/lib/typescript/module/src/components/Title/index.d.ts.map +1 -1
  162. package/lib/typescript/module/src/components/index.d.ts +1 -0
  163. package/lib/typescript/module/src/components/index.d.ts.map +1 -1
  164. package/lib/typescript/module/src/theme/create-theme.d.ts.map +1 -1
  165. package/lib/typescript/module/src/theme/default-theme.d.ts +34 -3
  166. package/lib/typescript/module/src/theme/default-theme.d.ts.map +1 -1
  167. package/lib/typescript/module/src/theme/functions/attach-functions.d.ts.map +1 -1
  168. package/lib/typescript/module/src/theme/functions/fns/breakpoints.d.ts +15 -0
  169. package/lib/typescript/module/src/theme/functions/fns/breakpoints.d.ts.map +1 -0
  170. package/lib/typescript/module/src/theme/functions/fns/darken.d.ts +8 -0
  171. package/lib/typescript/module/src/theme/functions/fns/darken.d.ts.map +1 -0
  172. package/lib/typescript/module/src/theme/functions/fns/dimmed.d.ts +9 -0
  173. package/lib/typescript/module/src/theme/functions/fns/dimmed.d.ts.map +1 -0
  174. package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts +13 -0
  175. package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -0
  176. package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts +1 -2
  177. package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts.map +1 -1
  178. package/lib/typescript/module/src/theme/functions/fns/index.d.ts +16 -1
  179. package/lib/typescript/module/src/theme/functions/fns/index.d.ts.map +1 -1
  180. package/lib/typescript/module/src/theme/functions/fns/lighten.d.ts +8 -0
  181. package/lib/typescript/module/src/theme/functions/fns/lighten.d.ts.map +1 -0
  182. package/lib/typescript/module/src/theme/functions/fns/primary-shade.d.ts +7 -0
  183. package/lib/typescript/module/src/theme/functions/fns/primary-shade.d.ts.map +1 -0
  184. package/lib/typescript/module/src/theme/functions/fns/shadow.d.ts +24 -0
  185. package/lib/typescript/module/src/theme/functions/fns/shadow.d.ts.map +1 -0
  186. package/lib/typescript/module/src/theme/functions/fns/theme-color/theme-color.d.ts.map +1 -1
  187. package/lib/typescript/module/src/theme/functions/fns/variant.d.ts.map +1 -1
  188. package/lib/typescript/module/src/theme/index.d.ts +4 -0
  189. package/lib/typescript/module/src/theme/index.d.ts.map +1 -1
  190. package/lib/typescript/module/src/theme/theme-provider.d.ts.map +1 -1
  191. package/lib/typescript/module/src/theme/utils/to-rgba.d.ts +9 -0
  192. package/lib/typescript/module/src/theme/utils/to-rgba.d.ts.map +1 -0
  193. package/package.json +1 -1
  194. package/src/components/Button/index.tsx +61 -21
  195. package/src/components/Code/index.tsx +3 -1
  196. package/src/components/Gradient/Gradient.tsx +71 -0
  197. package/src/components/Gradient/index.tsx +2 -0
  198. package/src/components/Modal/index.tsx +33 -3
  199. package/src/components/Paper/index.tsx +1 -63
  200. package/src/components/Text/index.tsx +28 -16
  201. package/src/components/ThemeIcon/index.tsx +6 -4
  202. package/src/components/Title/index.tsx +7 -3
  203. package/src/components/index.tsx +1 -0
  204. package/src/theme/create-theme.ts +3 -5
  205. package/src/theme/default-theme.ts +179 -91
  206. package/src/theme/functions/attach-functions.ts +6 -0
  207. package/src/theme/functions/fns/breakpoints.ts +62 -0
  208. package/src/theme/functions/fns/darken.ts +16 -0
  209. package/src/theme/functions/fns/dimmed.ts +16 -0
  210. package/src/theme/functions/fns/gradient/gradient.ts +63 -0
  211. package/src/theme/functions/fns/helpers.ts +1 -2
  212. package/src/theme/functions/fns/index.ts +15 -0
  213. package/src/theme/functions/fns/lighten.ts +15 -0
  214. package/src/theme/functions/fns/primary-shade.ts +17 -0
  215. package/src/theme/functions/fns/shadow.ts +100 -0
  216. package/src/theme/functions/fns/theme-color/theme-color.ts +3 -2
  217. package/src/theme/functions/fns/variant.ts +6 -5
  218. package/src/theme/index.tsx +4 -0
  219. package/src/theme/theme-provider.tsx +8 -3
  220. package/src/theme/theme.d.ts +11 -1
  221. package/src/theme/utils/to-rgba.ts +69 -0
@@ -0,0 +1,100 @@
1
+ import { Platform } from 'react-native';
2
+ import type { MantineSize } from '../../types';
3
+
4
+ export interface ShadowStyles {
5
+ shadowColor?: string;
6
+ shadowOffset?: { width: number; height: number };
7
+ shadowOpacity?: number;
8
+ shadowRadius?: number;
9
+ elevation?: number;
10
+ }
11
+
12
+ export type MantineShadow = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
13
+
14
+ /**
15
+ * Platform-specific shadow configurations
16
+ * iOS uses shadowColor, shadowOffset, shadowOpacity, shadowRadius
17
+ * Android uses elevation
18
+ */
19
+ const SHADOW_CONFIG: Record<MantineShadow, { ios: ShadowStyles; android: ShadowStyles }> = {
20
+ xs: {
21
+ ios: {
22
+ shadowColor: '#000',
23
+ shadowOffset: { width: 0, height: 1 },
24
+ shadowOpacity: 0.05,
25
+ shadowRadius: 1,
26
+ },
27
+ android: {
28
+ elevation: 1,
29
+ },
30
+ },
31
+ sm: {
32
+ ios: {
33
+ shadowColor: '#000',
34
+ shadowOffset: { width: 0, height: 1 },
35
+ shadowOpacity: 0.1,
36
+ shadowRadius: 2,
37
+ },
38
+ android: {
39
+ elevation: 2,
40
+ },
41
+ },
42
+ md: {
43
+ ios: {
44
+ shadowColor: '#000',
45
+ shadowOffset: { width: 0, height: 2 },
46
+ shadowOpacity: 0.15,
47
+ shadowRadius: 4,
48
+ },
49
+ android: {
50
+ elevation: 4,
51
+ },
52
+ },
53
+ lg: {
54
+ ios: {
55
+ shadowColor: '#000',
56
+ shadowOffset: { width: 0, height: 4 },
57
+ shadowOpacity: 0.2,
58
+ shadowRadius: 8,
59
+ },
60
+ android: {
61
+ elevation: 8,
62
+ },
63
+ },
64
+ xl: {
65
+ ios: {
66
+ shadowColor: '#000',
67
+ shadowOffset: { width: 0, height: 8 },
68
+ shadowOpacity: 0.25,
69
+ shadowRadius: 16,
70
+ },
71
+ android: {
72
+ elevation: 12,
73
+ },
74
+ },
75
+ };
76
+
77
+ /**
78
+ * Returns platform-specific shadow styles for React Native
79
+ * @param size - Shadow size (xs, sm, md, lg, xl)
80
+ * @returns Object with shadow properties for the current platform
81
+ *
82
+ * @example
83
+ * // iOS will get: { shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.15, shadowRadius: 4 }
84
+ * // Android will get: { elevation: 4 }
85
+ * const shadowStyles = shadow('md');
86
+ */
87
+ export function shadow(size?: MantineShadow | MantineSize): ShadowStyles {
88
+ if (!size) {
89
+ return {};
90
+ }
91
+
92
+ const shadowSize = size as MantineShadow;
93
+ const shadowConfig = SHADOW_CONFIG[shadowSize];
94
+
95
+ if (!shadowConfig) {
96
+ return {};
97
+ }
98
+
99
+ return Platform.OS === 'ios' ? shadowConfig.ios : shadowConfig.android;
100
+ }
@@ -1,5 +1,6 @@
1
1
  import type { MantineTheme } from '../../../default-theme';
2
2
  import type { MantineColor } from '../../../types';
3
+ import { getPrimaryShade } from '../primary-shade';
3
4
 
4
5
  export interface ThemeColorInput {
5
6
  theme: MantineTheme;
@@ -29,8 +30,8 @@ export function themeColor({ theme, color, shade }: ThemeColorInput): string {
29
30
  return color;
30
31
  }
31
32
 
32
- // Use provided shade or default to primaryShade
33
- const colorShade = shade !== undefined ? shade : theme.primaryShade;
33
+ // Use provided shade or get from theme based on color scheme
34
+ const colorShade = shade !== undefined ? shade : getPrimaryShade(theme);
34
35
 
35
36
  // Return the color at the specified shade
36
37
  return colorPalette[colorShade] || colorPalette[0] || color;
@@ -1,6 +1,7 @@
1
1
  import type { MantineTheme } from '../../default-theme';
2
2
  import type { MantineColor } from '../../types';
3
3
  import { themeColor } from './theme-color/theme-color';
4
+ import { getPrimaryShade } from './primary-shade';
4
5
 
5
6
  export interface VariantInput {
6
7
  variant:
@@ -27,10 +28,9 @@ export const variant = (theme: MantineTheme) => (input: VariantInput): VariantOu
27
28
  const {
28
29
  variant,
29
30
  color = theme.primaryColor,
30
- gradient,
31
31
  } = input;
32
32
 
33
- const primaryShade = theme.primaryShade;
33
+ const primaryShade = getPrimaryShade(theme);
34
34
  const getColor = (c: string, shade: number) => themeColor({ theme, color: c, shade });
35
35
 
36
36
  switch (variant) {
@@ -91,10 +91,11 @@ export const variant = (theme: MantineTheme) => (input: VariantInput): VariantOu
91
91
  }
92
92
 
93
93
  case 'gradient': {
94
- const from = gradient?.from || theme.primaryColor;
95
- const to = gradient?.to || theme.primaryColor;
94
+ // For gradient variant, return transparent background
95
+ // The actual gradient rendering is handled by LinearGradient component
96
+ // We just need to provide the text color and border
96
97
  return {
97
- background: `linear-gradient(${gradient?.deg || 45}deg, ${getColor(from, primaryShade)}, ${getColor(to, primaryShade)})`,
98
+ background: 'transparent',
98
99
  color: '#fff',
99
100
  border: 'transparent',
100
101
  };
@@ -3,3 +3,7 @@ export { createStyles } from './create-styles';
3
3
  export { filterProps } from './filter-props';
4
4
  export { getSize } from './get-size';
5
5
  export { createTheme } from './create-theme';
6
+ export { shadow } from './functions/fns/shadow';
7
+ export type { ShadowStyles, MantineShadow } from './functions/fns/shadow';
8
+ export { gradient } from './functions/fns/gradient/gradient';
9
+ export type { MantineGradient, GradientConfig } from './theme.d';
@@ -15,6 +15,7 @@ import type { ReactNode } from 'react';
15
15
  import { Layout } from './constants';
16
16
  import type { MantineTheme } from './default-theme';
17
17
  import { createTheme } from './create-theme';
18
+ import { getPrimaryShade } from './functions/fns/primary-shade';
18
19
 
19
20
  import { filterProps } from './filter-props';
20
21
  import useCachedResources from '../hooks/useCachedResources';
@@ -36,7 +37,7 @@ export const ThemeProvider = ({
36
37
  theme: MantineTheme;
37
38
  forceMode?: 'light' | 'dark';
38
39
  }): React.ReactElement => {
39
- const { colors, primaryShade, primaryColor, secondaryColor } = theme;
40
+ const { colors, primaryColor, secondaryColor } = theme;
40
41
  const systemDarkMode = Appearance.getColorScheme();
41
42
  const [currentMode, setCurrentMode] = useState<'light' | 'dark'>(
42
43
  forceMode || systemDarkMode || 'light'
@@ -64,10 +65,14 @@ export const ThemeProvider = ({
64
65
  dark: theme.light,
65
66
  };
66
67
 
68
+ // Get the primary shade for the current mode
69
+ const themeWithMode = { ...theme, currentMode };
70
+ const shade = getPrimaryShade(themeWithMode);
71
+
67
72
  return {
68
73
  ...theme,
69
- primaryTextColor: get(colors, `${primaryColor}.${primaryShade}`, 'black'),
70
- primaryBgColor: get(colors, `${primaryColor}.${primaryShade}`),
74
+ primaryTextColor: get(colors, `${primaryColor}.${shade}`, 'black'),
75
+ primaryBgColor: get(colors, `${primaryColor}.${shade}`),
71
76
  secondaryBgColor: get(colors, `${secondaryColor}.0`),
72
77
  ...(currentMode === 'dark' ? darkTheme : {}),
73
78
  window: Layout.window,
@@ -12,4 +12,14 @@ export type Palette = [
12
12
  string,
13
13
  ];
14
14
 
15
- export type MantineGradient = any;
15
+ export interface MantineGradient {
16
+ from: string;
17
+ to: string;
18
+ deg?: number;
19
+ }
20
+
21
+ export interface GradientConfig {
22
+ colors: [string, string];
23
+ start: { x: number; y: number };
24
+ end: { x: number; y: number };
25
+ }
@@ -0,0 +1,69 @@
1
+ /* eslint-disable no-bitwise */
2
+
3
+ interface RGBA {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ a: number;
8
+ }
9
+
10
+ function isHexColor(hex: string): boolean {
11
+ const HEX_REGEXP = /^#?([0-9A-F]{3}){1,2}$/i;
12
+
13
+ return HEX_REGEXP.test(hex);
14
+ }
15
+
16
+ function hexToRgba(color: string): RGBA {
17
+ let hexString = color.replace('#', '');
18
+
19
+ if (hexString.length === 3) {
20
+ const shorthandHex = hexString.split('');
21
+ hexString = [
22
+ shorthandHex[0],
23
+ shorthandHex[0],
24
+ shorthandHex[1],
25
+ shorthandHex[1],
26
+ shorthandHex[2],
27
+ shorthandHex[2],
28
+ ].join('');
29
+ }
30
+
31
+ const parsed = parseInt(hexString, 16);
32
+ const r = (parsed >> 16) & 255;
33
+ const g = (parsed >> 8) & 255;
34
+ const b = parsed & 255;
35
+
36
+ return {
37
+ r,
38
+ g,
39
+ b,
40
+ a: 1,
41
+ };
42
+ }
43
+
44
+ function rgbStringToRgba(color: string): RGBA {
45
+ const parts = color.replace(/[^0-9,.]/g, '').split(',').map(Number);
46
+ const r = parts[0] || 0;
47
+ const g = parts[1] || 0;
48
+ const b = parts[2] || 0;
49
+ const a = parts[3] || 1;
50
+
51
+ return { r, g, b, a };
52
+ }
53
+
54
+ export function toRgba(color: string): RGBA {
55
+ if (isHexColor(color)) {
56
+ return hexToRgba(color);
57
+ }
58
+
59
+ if (color.startsWith('rgb')) {
60
+ return rgbStringToRgba(color);
61
+ }
62
+
63
+ return {
64
+ r: 0,
65
+ g: 0,
66
+ b: 0,
67
+ a: 1,
68
+ };
69
+ }