dhre-ui-kit 0.0.68 → 0.0.70
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/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -52,6 +52,4 @@ export {
|
|
|
52
52
|
export {copyToClipboard} from './utils/deviceUtils';
|
|
53
53
|
|
|
54
54
|
export {default} from './theme/themes';
|
|
55
|
-
export {useToast} from './components/toast/ToastProvider';
|
|
56
|
-
export {default as ToastProvider} from './components/toast/ToastProvider';
|
|
57
55
|
export {default as CustomTextTest} from '../__mocks__/custom-text.mock';
|
package/src/theme/themes.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {Theme} from '../utils/appEnum';
|
|
|
3
3
|
const theme = {
|
|
4
4
|
[Theme.SURFACE_PRIMARY]: {
|
|
5
5
|
light: '#FFFFFF',
|
|
6
|
-
dark: '#
|
|
6
|
+
dark: '#000000',
|
|
7
7
|
},
|
|
8
8
|
[Theme.SURFACE_SECONDARY]: {
|
|
9
9
|
light: '#F5F5F5',
|
|
@@ -87,6 +87,23 @@ const theme = {
|
|
|
87
87
|
light: '#282828',
|
|
88
88
|
dark: '#FFFFFF',
|
|
89
89
|
},
|
|
90
|
+
|
|
91
|
+
[Theme.WARNING]: {
|
|
92
|
+
light: '#B65E01',
|
|
93
|
+
dark: '#EB8425',
|
|
94
|
+
},
|
|
95
|
+
[Theme.SUCCESS]: {
|
|
96
|
+
light: '#008256',
|
|
97
|
+
dark: '#00B578',
|
|
98
|
+
},
|
|
99
|
+
[Theme.INFO]: {
|
|
100
|
+
light: '#0569C2',
|
|
101
|
+
dark: '#339ECF',
|
|
102
|
+
},
|
|
103
|
+
[Theme.ERROR]: {
|
|
104
|
+
light: '#EB0542',
|
|
105
|
+
dark: '#EB0542',
|
|
106
|
+
},
|
|
90
107
|
};
|
|
91
108
|
|
|
92
109
|
export default theme;
|
package/src/utils/appEnum.ts
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
createContext,
|
|
3
|
-
useRef,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useContext,
|
|
6
|
-
forwardRef,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import Toast from './Toast';
|
|
9
|
-
import {ShowToast, ToastRef} from './Toast.interface';
|
|
10
|
-
|
|
11
|
-
const ToastContext = createContext<{showToast: ShowToast} | undefined>(
|
|
12
|
-
undefined,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const ToastProvider = forwardRef<ToastRef, React.PropsWithChildren<object>>(
|
|
16
|
-
(props, ref) => {
|
|
17
|
-
const toastRef = useRef<ToastRef>(null);
|
|
18
|
-
|
|
19
|
-
useImperativeHandle(ref, () => ({
|
|
20
|
-
showToast: (message, duration, isSuccess, btnText, onBtnPress) => {
|
|
21
|
-
toastRef.current?.showToast(
|
|
22
|
-
message,
|
|
23
|
-
duration,
|
|
24
|
-
isSuccess,
|
|
25
|
-
btnText,
|
|
26
|
-
onBtnPress,
|
|
27
|
-
);
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<ToastContext.Provider
|
|
33
|
-
value={{
|
|
34
|
-
showToast: (message, duration, isSuccess, btnText, onBtnPress) => {
|
|
35
|
-
toastRef.current?.showToast(
|
|
36
|
-
message,
|
|
37
|
-
duration,
|
|
38
|
-
isSuccess,
|
|
39
|
-
btnText,
|
|
40
|
-
onBtnPress,
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
}}>
|
|
44
|
-
{props.children}
|
|
45
|
-
<Toast ref={toastRef} />
|
|
46
|
-
</ToastContext.Provider>
|
|
47
|
-
);
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
ToastProvider.displayName = 'ToastProvider';
|
|
52
|
-
|
|
53
|
-
export const useToast = () => {
|
|
54
|
-
const context = useContext(ToastContext);
|
|
55
|
-
if (!context) {
|
|
56
|
-
throw new Error('useToast must be used within a ToastProvider');
|
|
57
|
-
}
|
|
58
|
-
return context;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default ToastProvider;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
|
|
3
|
-
export type ShowToast = (text: string, duration?: number) => void;
|
|
4
|
-
|
|
5
|
-
export type Provider = React.FunctionComponent & {
|
|
6
|
-
ref: ToastRef | null;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type RegisterRef = (ref: ToastRef) => void;
|
|
10
|
-
|
|
11
|
-
export interface ToastRef {
|
|
12
|
-
showToast: ShowToast;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ToastProps {
|
|
16
|
-
ref: (ref: ToastRef) => void;
|
|
17
|
-
}
|