dhre-ui-kit 0.0.37 → 0.0.38
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
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {ReactElement} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {ViewStyle} from 'react-native';
|
|
2
|
+
import {StyleProp, TextStyle, ViewStyle} from 'react-native';
|
|
4
3
|
import {SvgProps} from 'react-native-svg';
|
|
5
4
|
|
|
6
|
-
export interface
|
|
7
|
-
onPress: () => void;
|
|
5
|
+
export interface CustomButtonProps {
|
|
8
6
|
title: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
onPress: () => void;
|
|
8
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
textStyle?: TextStyle;
|
|
10
|
+
leftIcon?: ReactElement<SvgProps>;
|
|
11
|
+
rightIcon?: ReactElement<SvgProps>;
|
|
12
|
+
iconStyle?: ViewStyle;
|
|
13
|
+
titleColor?: string;
|
|
14
|
+
titleVariant?: string;
|
|
15
|
+
imagePosition?: 'left' | 'right';
|
|
14
16
|
testID?: string;
|
|
15
|
-
|
|
16
|
-
variant: keyof typeof FONT_STYLES | string;
|
|
17
|
-
iconName?: ReactElement<SvgProps>;
|
|
17
|
+
disabled?: boolean;
|
|
18
18
|
}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
TouchableOpacity,
|
|
4
|
-
StyleSheet,
|
|
5
|
-
View,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
StyleProp,
|
|
8
|
-
TextStyle,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import {SvgProps} from 'react-native-svg';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {StyleSheet, View, Pressable} from 'react-native';
|
|
11
3
|
import CustomText from '../customText';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onPress: () => void;
|
|
16
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
17
|
-
textStyle?: TextStyle;
|
|
18
|
-
leftIcon?: ReactElement<SvgProps>;
|
|
19
|
-
rightIcon?: ReactElement<SvgProps>;
|
|
20
|
-
iconStyle?: ViewStyle;
|
|
21
|
-
titleColor?: string;
|
|
22
|
-
titleVariant?: string;
|
|
23
|
-
imagePosition?: 'left' | 'right';
|
|
24
|
-
testID?: string;
|
|
25
|
-
}
|
|
4
|
+
import {useTheme} from '../../theme/ThemeContext';
|
|
5
|
+
import {withThemeProvider} from '../../theme/withThemeProvider';
|
|
6
|
+
import {CustomButtonProps} from './Button.interface';
|
|
26
7
|
|
|
27
8
|
const CustomButton = ({
|
|
28
9
|
title,
|
|
@@ -36,12 +17,19 @@ const CustomButton = ({
|
|
|
36
17
|
titleColor,
|
|
37
18
|
titleVariant = 'L2_REGULAR',
|
|
38
19
|
imagePosition = 'right',
|
|
20
|
+
disabled = false,
|
|
39
21
|
}: CustomButtonProps) => {
|
|
22
|
+
const {theme} = useTheme();
|
|
40
23
|
return (
|
|
41
|
-
<
|
|
24
|
+
<Pressable
|
|
42
25
|
testID={testID}
|
|
43
|
-
style={[
|
|
44
|
-
|
|
26
|
+
style={[
|
|
27
|
+
styles.buttonContainer,
|
|
28
|
+
containerStyle,
|
|
29
|
+
disabled ? {backgroundColor: theme.SURFACE_DISABLE} : {},
|
|
30
|
+
]}
|
|
31
|
+
onPress={onPress}
|
|
32
|
+
disabled={disabled}>
|
|
45
33
|
{imagePosition === 'left' && leftIcon && (
|
|
46
34
|
<View style={iconStyle}>
|
|
47
35
|
{React.cloneElement(leftIcon, {width: 20, height: 20})}
|
|
@@ -50,7 +38,11 @@ const CustomButton = ({
|
|
|
50
38
|
<CustomText
|
|
51
39
|
text={title}
|
|
52
40
|
variant={titleVariant}
|
|
53
|
-
style={[
|
|
41
|
+
style={[
|
|
42
|
+
{color: '#A7A7A7'},
|
|
43
|
+
textStyle,
|
|
44
|
+
disabled ? {color: theme.CONTENT_DISABLE} : {},
|
|
45
|
+
]}
|
|
54
46
|
textColor={titleColor}
|
|
55
47
|
/>
|
|
56
48
|
|
|
@@ -59,7 +51,7 @@ const CustomButton = ({
|
|
|
59
51
|
{React.cloneElement(rightIcon, {width: 20, height: 20})}
|
|
60
52
|
</View>
|
|
61
53
|
)}
|
|
62
|
-
</
|
|
54
|
+
</Pressable>
|
|
63
55
|
);
|
|
64
56
|
};
|
|
65
57
|
|
|
@@ -74,4 +66,4 @@ const styles = StyleSheet.create({
|
|
|
74
66
|
},
|
|
75
67
|
});
|
|
76
68
|
|
|
77
|
-
export default CustomButton;
|
|
69
|
+
export default withThemeProvider(CustomButton);
|