react-native-mantine 0.8.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.
- package/lib/commonjs/components/Button/index.js +52 -17
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Code/index.js +3 -1
- package/lib/commonjs/components/Code/index.js.map +1 -1
- package/lib/commonjs/components/Gradient/Gradient.js +70 -0
- package/lib/commonjs/components/Gradient/Gradient.js.map +1 -0
- package/lib/commonjs/components/Gradient/index.js +19 -0
- package/lib/commonjs/components/Gradient/index.js.map +1 -0
- package/lib/commonjs/components/Modal/index.js +33 -3
- package/lib/commonjs/components/Modal/index.js.map +1 -1
- package/lib/commonjs/components/Paper/index.js +1 -76
- package/lib/commonjs/components/Paper/index.js.map +1 -1
- package/lib/commonjs/components/Switch/index.js +6 -2
- package/lib/commonjs/components/Switch/index.js.map +1 -1
- package/lib/commonjs/components/Text/index.js +27 -8
- package/lib/commonjs/components/Text/index.js.map +1 -1
- package/lib/commonjs/components/ThemeIcon/index.js +6 -4
- package/lib/commonjs/components/ThemeIcon/index.js.map +1 -1
- package/lib/commonjs/components/Title/index.js +7 -3
- package/lib/commonjs/components/Title/index.js.map +1 -1
- package/lib/commonjs/components/index.js +33 -22
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/theme/create-theme.js +3 -5
- package/lib/commonjs/theme/create-theme.js.map +1 -1
- package/lib/commonjs/theme/default-theme.js +168 -21
- package/lib/commonjs/theme/default-theme.js.map +1 -1
- package/lib/commonjs/theme/functions/attach-functions.js +7 -1
- package/lib/commonjs/theme/functions/attach-functions.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/breakpoints.js +69 -0
- package/lib/commonjs/theme/functions/fns/breakpoints.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/darken.js +25 -0
- package/lib/commonjs/theme/functions/fns/darken.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/dimmed.js +19 -0
- package/lib/commonjs/theme/functions/fns/dimmed.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/gradient/gradient.js +78 -0
- package/lib/commonjs/theme/functions/fns/gradient/gradient.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/helpers.js +1 -2
- package/lib/commonjs/theme/functions/fns/helpers.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/index.js +15 -0
- package/lib/commonjs/theme/functions/fns/index.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/lighten.js +24 -0
- package/lib/commonjs/theme/functions/fns/lighten.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/primary-shade.js +18 -0
- package/lib/commonjs/theme/functions/fns/primary-shade.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/shadow.js +107 -0
- package/lib/commonjs/theme/functions/fns/shadow.js.map +1 -0
- package/lib/commonjs/theme/functions/fns/theme-color/theme-color.js +3 -2
- package/lib/commonjs/theme/functions/fns/theme-color/theme-color.js.map +1 -1
- package/lib/commonjs/theme/functions/fns/variant.js +7 -6
- package/lib/commonjs/theme/functions/fns/variant.js.map +1 -1
- package/lib/commonjs/theme/index.js +14 -0
- package/lib/commonjs/theme/index.js.map +1 -1
- package/lib/commonjs/theme/theme-provider.js +10 -3
- package/lib/commonjs/theme/theme-provider.js.map +1 -1
- package/lib/commonjs/theme/utils/to-rgba.js +57 -0
- package/lib/commonjs/theme/utils/to-rgba.js.map +1 -0
- package/lib/module/components/Button/index.js +53 -18
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Code/index.js +3 -1
- package/lib/module/components/Code/index.js.map +1 -1
- package/lib/module/components/Gradient/Gradient.js +64 -0
- package/lib/module/components/Gradient/Gradient.js.map +1 -0
- package/lib/module/components/Gradient/index.js +4 -0
- package/lib/module/components/Gradient/index.js.map +1 -0
- package/lib/module/components/Modal/index.js +35 -5
- package/lib/module/components/Modal/index.js.map +1 -1
- package/lib/module/components/Paper/index.js +1 -76
- package/lib/module/components/Paper/index.js.map +1 -1
- package/lib/module/components/Switch/index.js +6 -2
- package/lib/module/components/Switch/index.js.map +1 -1
- package/lib/module/components/Text/index.js +27 -8
- package/lib/module/components/Text/index.js.map +1 -1
- package/lib/module/components/ThemeIcon/index.js +6 -4
- package/lib/module/components/ThemeIcon/index.js.map +1 -1
- package/lib/module/components/Title/index.js +7 -3
- package/lib/module/components/Title/index.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/theme/create-theme.js +3 -5
- package/lib/module/theme/create-theme.js.map +1 -1
- package/lib/module/theme/default-theme.js +168 -21
- package/lib/module/theme/default-theme.js.map +1 -1
- package/lib/module/theme/functions/attach-functions.js +7 -1
- package/lib/module/theme/functions/attach-functions.js.map +1 -1
- package/lib/module/theme/functions/fns/breakpoints.js +64 -0
- package/lib/module/theme/functions/fns/breakpoints.js.map +1 -0
- package/lib/module/theme/functions/fns/darken.js +22 -0
- package/lib/module/theme/functions/fns/darken.js.map +1 -0
- package/lib/module/theme/functions/fns/dimmed.js +15 -0
- package/lib/module/theme/functions/fns/dimmed.js.map +1 -0
- package/lib/module/theme/functions/fns/gradient/gradient.js +74 -0
- package/lib/module/theme/functions/fns/gradient/gradient.js.map +1 -0
- package/lib/module/theme/functions/fns/helpers.js +1 -2
- package/lib/module/theme/functions/fns/helpers.js.map +1 -1
- package/lib/module/theme/functions/fns/index.js +15 -0
- package/lib/module/theme/functions/fns/index.js.map +1 -1
- package/lib/module/theme/functions/fns/lighten.js +21 -0
- package/lib/module/theme/functions/fns/lighten.js.map +1 -0
- package/lib/module/theme/functions/fns/primary-shade.js +14 -0
- package/lib/module/theme/functions/fns/primary-shade.js.map +1 -0
- package/lib/module/theme/functions/fns/shadow.js +103 -0
- package/lib/module/theme/functions/fns/shadow.js.map +1 -0
- package/lib/module/theme/functions/fns/theme-color/theme-color.js +3 -2
- package/lib/module/theme/functions/fns/theme-color/theme-color.js.map +1 -1
- package/lib/module/theme/functions/fns/variant.js +7 -6
- package/lib/module/theme/functions/fns/variant.js.map +1 -1
- package/lib/module/theme/index.js +2 -0
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/theme-provider.js +10 -3
- package/lib/module/theme/theme-provider.js.map +1 -1
- package/lib/module/theme/utils/to-rgba.js +53 -0
- package/lib/module/theme/utils/to-rgba.js.map +1 -0
- package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Code/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Gradient/Gradient.d.ts +32 -0
- package/lib/typescript/commonjs/src/components/Gradient/Gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Gradient/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/components/Gradient/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Modal/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Paper/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Switch/index.d.ts +3 -3
- package/lib/typescript/commonjs/src/components/Switch/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/ThemeIcon/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Title/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/create-theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/default-theme.d.ts +34 -3
- package/lib/typescript/commonjs/src/theme/default-theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/attach-functions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/breakpoints.d.ts +15 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/breakpoints.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/darken.d.ts +8 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/darken.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/dimmed.d.ts +9 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/dimmed.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts +13 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts +1 -2
- package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts +16 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/lighten.d.ts +8 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/lighten.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/primary-shade.d.ts +7 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/primary-shade.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/shadow.d.ts +24 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/shadow.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme/functions/fns/theme-color/theme-color.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/functions/fns/variant.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/theme-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/utils/to-rgba.d.ts +9 -0
- package/lib/typescript/commonjs/src/theme/utils/to-rgba.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Code/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Gradient/Gradient.d.ts +32 -0
- package/lib/typescript/module/src/components/Gradient/Gradient.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Gradient/index.d.ts +3 -0
- package/lib/typescript/module/src/components/Gradient/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Modal/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Paper/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Switch/index.d.ts +3 -3
- package/lib/typescript/module/src/components/Switch/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ThemeIcon/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Title/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/index.d.ts +1 -0
- package/lib/typescript/module/src/components/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/create-theme.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/default-theme.d.ts +34 -3
- package/lib/typescript/module/src/theme/default-theme.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/attach-functions.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/breakpoints.d.ts +15 -0
- package/lib/typescript/module/src/theme/functions/fns/breakpoints.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/darken.d.ts +8 -0
- package/lib/typescript/module/src/theme/functions/fns/darken.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/dimmed.d.ts +9 -0
- package/lib/typescript/module/src/theme/functions/fns/dimmed.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts +13 -0
- package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts +1 -2
- package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/index.d.ts +16 -1
- package/lib/typescript/module/src/theme/functions/fns/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/lighten.d.ts +8 -0
- package/lib/typescript/module/src/theme/functions/fns/lighten.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/primary-shade.d.ts +7 -0
- package/lib/typescript/module/src/theme/functions/fns/primary-shade.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/shadow.d.ts +24 -0
- package/lib/typescript/module/src/theme/functions/fns/shadow.d.ts.map +1 -0
- package/lib/typescript/module/src/theme/functions/fns/theme-color/theme-color.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/functions/fns/variant.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/index.d.ts +4 -0
- package/lib/typescript/module/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/theme-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/utils/to-rgba.d.ts +9 -0
- package/lib/typescript/module/src/theme/utils/to-rgba.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/Button/index.tsx +61 -21
- package/src/components/Code/index.tsx +3 -1
- package/src/components/Gradient/Gradient.tsx +71 -0
- package/src/components/Gradient/index.tsx +2 -0
- package/src/components/Modal/index.tsx +33 -3
- package/src/components/Paper/index.tsx +1 -63
- package/src/components/Switch/index.tsx +10 -6
- package/src/components/Text/index.tsx +28 -16
- package/src/components/ThemeIcon/index.tsx +6 -4
- package/src/components/Title/index.tsx +7 -3
- package/src/components/index.tsx +1 -0
- package/src/theme/create-theme.ts +3 -5
- package/src/theme/default-theme.ts +179 -91
- package/src/theme/functions/attach-functions.ts +6 -0
- package/src/theme/functions/fns/breakpoints.ts +62 -0
- package/src/theme/functions/fns/darken.ts +16 -0
- package/src/theme/functions/fns/dimmed.ts +16 -0
- package/src/theme/functions/fns/gradient/gradient.ts +63 -0
- package/src/theme/functions/fns/helpers.ts +1 -2
- package/src/theme/functions/fns/index.ts +15 -0
- package/src/theme/functions/fns/lighten.ts +15 -0
- package/src/theme/functions/fns/primary-shade.ts +17 -0
- package/src/theme/functions/fns/shadow.ts +100 -0
- package/src/theme/functions/fns/theme-color/theme-color.ts +3 -2
- package/src/theme/functions/fns/variant.ts +6 -5
- package/src/theme/index.tsx +4 -0
- package/src/theme/theme-provider.tsx +8 -3
- package/src/theme/theme.d.ts +11 -1
- 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
|
|
33
|
-
const colorShade = shade !== undefined ? shade : theme
|
|
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
|
|
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
|
-
|
|
95
|
-
|
|
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:
|
|
98
|
+
background: 'transparent',
|
|
98
99
|
color: '#fff',
|
|
99
100
|
border: 'transparent',
|
|
100
101
|
};
|
package/src/theme/index.tsx
CHANGED
|
@@ -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,
|
|
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}.${
|
|
70
|
-
primaryBgColor: get(colors, `${primaryColor}.${
|
|
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,
|
package/src/theme/theme.d.ts
CHANGED
|
@@ -12,4 +12,14 @@ export type Palette = [
|
|
|
12
12
|
string,
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
-
export
|
|
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
|
+
}
|