@sudobility/building_blocks_rn 0.0.3 → 0.0.6
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.
|
@@ -107,7 +107,7 @@ const useStyles = createThemedStyles(colors => ({
|
|
|
107
107
|
paddingVertical: 4,
|
|
108
108
|
},
|
|
109
109
|
statusBadgeActive: {
|
|
110
|
-
backgroundColor:
|
|
110
|
+
backgroundColor: colors.successBg,
|
|
111
111
|
},
|
|
112
112
|
statusBadgeInactive: {
|
|
113
113
|
backgroundColor: colors.surfaceSecondary,
|
|
@@ -117,7 +117,7 @@ const useStyles = createThemedStyles(colors => ({
|
|
|
117
117
|
fontWeight: '600',
|
|
118
118
|
},
|
|
119
119
|
statusBadgeTextActive: {
|
|
120
|
-
color:
|
|
120
|
+
color: colors.successText,
|
|
121
121
|
},
|
|
122
122
|
statusBadgeTextInactive: {
|
|
123
123
|
color: colors.textSecondary,
|
|
@@ -88,7 +88,7 @@ const useStyles = createThemedStyles(colors => ({
|
|
|
88
88
|
marginBottom: 20,
|
|
89
89
|
},
|
|
90
90
|
errorBox: {
|
|
91
|
-
backgroundColor:
|
|
91
|
+
backgroundColor: colors.errorBg,
|
|
92
92
|
borderRadius: 8,
|
|
93
93
|
padding: 12,
|
|
94
94
|
marginBottom: 16,
|
|
@@ -166,11 +166,11 @@ const useStyles = createThemedStyles(colors => ({
|
|
|
166
166
|
color: colors.text,
|
|
167
167
|
},
|
|
168
168
|
appleButton: {
|
|
169
|
-
backgroundColor:
|
|
170
|
-
borderColor:
|
|
169
|
+
backgroundColor: colors.invertedBackground,
|
|
170
|
+
borderColor: colors.invertedBackground,
|
|
171
171
|
},
|
|
172
172
|
appleButtonText: {
|
|
173
|
-
color:
|
|
173
|
+
color: colors.invertedText,
|
|
174
174
|
},
|
|
175
175
|
toggleLink: {
|
|
176
176
|
marginTop: 16,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { createContext, useCallback, useContext, useRef, useState, } from 'react';
|
|
3
|
-
import { View, Text, Animated, Pressable
|
|
3
|
+
import { View, Text, Animated, Pressable } from 'react-native';
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
|
+
import { useTheme } from '../../theme/ThemeContext';
|
|
6
|
+
import { createThemedStyles } from '../../utils/styles';
|
|
5
7
|
const ToastContext = createContext(null);
|
|
6
8
|
let toastCounter = 0;
|
|
7
9
|
export function ToastProvider({ children }) {
|
|
8
10
|
const [toasts, setToasts] = useState([]);
|
|
9
11
|
const insets = useSafeAreaInsets();
|
|
12
|
+
const styles = useToastStyles();
|
|
10
13
|
const removeToast = useCallback((id) => {
|
|
11
14
|
setToasts(prev => prev.filter(t => t.id !== id));
|
|
12
15
|
}, []);
|
|
@@ -20,6 +23,8 @@ export function ToastProvider({ children }) {
|
|
|
20
23
|
return (_jsxs(ToastContext.Provider, { value: { addToast, removeToast }, children: [children, _jsx(View, { style: [styles.toastContainer, { top: insets.top + 8 }], pointerEvents: 'box-none', children: toasts.map(toast => (_jsx(ToastItem, { toast: toast, onDismiss: () => removeToast(toast.id) }, toast.id))) })] }));
|
|
21
24
|
}
|
|
22
25
|
function ToastItem({ toast, onDismiss, }) {
|
|
26
|
+
const { colors } = useTheme();
|
|
27
|
+
const styles = useToastStyles();
|
|
23
28
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
24
29
|
const translateY = useRef(new Animated.Value(-20)).current;
|
|
25
30
|
React.useEffect(() => {
|
|
@@ -37,10 +42,10 @@ function ToastItem({ toast, onDismiss, }) {
|
|
|
37
42
|
]).start();
|
|
38
43
|
}, [opacity, translateY]);
|
|
39
44
|
const bgColor = {
|
|
40
|
-
success:
|
|
41
|
-
error:
|
|
42
|
-
warning:
|
|
43
|
-
info:
|
|
45
|
+
success: colors.success,
|
|
46
|
+
error: colors.error,
|
|
47
|
+
warning: colors.warning,
|
|
48
|
+
info: colors.info,
|
|
44
49
|
}[toast.type];
|
|
45
50
|
return (_jsx(Animated.View, { style: [
|
|
46
51
|
styles.toast,
|
|
@@ -57,7 +62,7 @@ export function useToast() {
|
|
|
57
62
|
}
|
|
58
63
|
return context;
|
|
59
64
|
}
|
|
60
|
-
const
|
|
65
|
+
const useToastStyles = createThemedStyles(_colors => ({
|
|
61
66
|
toastContainer: {
|
|
62
67
|
position: 'absolute',
|
|
63
68
|
left: 16,
|
|
@@ -84,4 +89,4 @@ const styles = StyleSheet.create({
|
|
|
84
89
|
fontSize: 15,
|
|
85
90
|
fontWeight: '500',
|
|
86
91
|
},
|
|
87
|
-
});
|
|
92
|
+
}));
|
|
@@ -47,9 +47,14 @@ export interface ThemeColors {
|
|
|
47
47
|
surface: string;
|
|
48
48
|
surfaceSecondary: string;
|
|
49
49
|
error: string;
|
|
50
|
+
errorBg: string;
|
|
50
51
|
success: string;
|
|
52
|
+
successBg: string;
|
|
53
|
+
successText: string;
|
|
51
54
|
warning: string;
|
|
52
55
|
info: string;
|
|
56
|
+
invertedText: string;
|
|
57
|
+
invertedBackground: string;
|
|
53
58
|
}
|
|
54
59
|
export declare const lightColors: ThemeColors;
|
|
55
60
|
export declare const darkColors: ThemeColors;
|
package/dist/src/theme/colors.js
CHANGED
|
@@ -47,9 +47,14 @@ export const lightColors = {
|
|
|
47
47
|
surface: palette.white,
|
|
48
48
|
surfaceSecondary: palette.gray[100],
|
|
49
49
|
error: palette.error,
|
|
50
|
+
errorBg: '#fef2f2',
|
|
50
51
|
success: palette.success,
|
|
52
|
+
successBg: '#dcfce7',
|
|
53
|
+
successText: '#16a34a',
|
|
51
54
|
warning: palette.warning,
|
|
52
55
|
info: palette.info,
|
|
56
|
+
invertedText: palette.white,
|
|
57
|
+
invertedBackground: palette.black,
|
|
53
58
|
};
|
|
54
59
|
export const darkColors = {
|
|
55
60
|
primary: palette.primary[400],
|
|
@@ -63,7 +68,12 @@ export const darkColors = {
|
|
|
63
68
|
surface: palette.gray[800],
|
|
64
69
|
surfaceSecondary: palette.gray[700],
|
|
65
70
|
error: palette.error,
|
|
71
|
+
errorBg: '#451a1a',
|
|
66
72
|
success: palette.success,
|
|
73
|
+
successBg: '#052e16',
|
|
74
|
+
successText: '#86efac',
|
|
67
75
|
warning: palette.warning,
|
|
68
76
|
info: palette.info,
|
|
77
|
+
invertedText: palette.black,
|
|
78
|
+
invertedBackground: palette.white,
|
|
69
79
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/building_blocks_rn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Higher-level shared UI building blocks for Sudobility React Native apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"i18next": "^25.8.0",
|
|
86
86
|
"react-i18next": "^16.5.3",
|
|
87
87
|
"@tanstack/react-query": "^5.90.19",
|
|
88
|
-
"@sudobility/types": "^1.9.
|
|
88
|
+
"@sudobility/types": "^1.9.51"
|
|
89
89
|
},
|
|
90
90
|
"publishConfig": {
|
|
91
91
|
"access": "public"
|