react-native-shared-components 0.3.3 → 0.3.5
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/module/assets/theme.js +227 -0
- package/lib/module/assets/theme.js.map +1 -0
- package/lib/module/components/BaseButton/index.js +15 -34
- package/lib/module/components/BaseButton/index.js.map +1 -1
- package/lib/module/components/BaseContainer/index.js +3 -6
- package/lib/module/components/BaseContainer/index.js.map +1 -1
- package/lib/module/components/BaseText/index.js +53 -23
- package/lib/module/components/BaseText/index.js.map +1 -1
- package/lib/module/core/KadoProvider/index.js +27 -0
- package/lib/module/core/KadoProvider/index.js.map +1 -0
- package/lib/module/core/index.js +4 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/assets/theme.d.ts +225 -0
- package/lib/typescript/src/assets/theme.d.ts.map +1 -0
- package/lib/typescript/src/components/BaseButton/index.d.ts.map +1 -1
- package/lib/typescript/src/components/BaseContainer/index.d.ts +1 -3
- package/lib/typescript/src/components/BaseContainer/index.d.ts.map +1 -1
- package/lib/typescript/src/components/BaseText/index.d.ts +43 -8
- package/lib/typescript/src/components/BaseText/index.d.ts.map +1 -1
- package/lib/typescript/src/core/KadoProvider/index.d.ts +19 -0
- package/lib/typescript/src/core/KadoProvider/index.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/assets/theme.ts +285 -0
- package/src/components/BaseButton/index.tsx +12 -35
- package/src/components/BaseContainer/index.tsx +2 -6
- package/src/components/BaseText/index.tsx +56 -34
- package/src/core/KadoProvider/index.tsx +41 -0
- package/src/core/index.tsx +1 -0
- package/src/index.tsx +1 -0
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
type ViewStyle,
|
|
7
7
|
type TextStyle,
|
|
8
8
|
type TouchableOpacityProps,
|
|
9
|
+
Text,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import { Colors } from '../../constants/Colors';
|
|
11
|
-
import {
|
|
12
|
+
import { useTheme } from '../../core';
|
|
12
13
|
|
|
13
14
|
export type ButtonVariant = 'primary' | 'link-subtle' | 'red' | 'brand-subtle';
|
|
14
15
|
export type ButtonSize = 'small' | 'regular' | 'large';
|
|
@@ -40,37 +41,24 @@ export const BaseButton: React.FC<BaseButtonProps> = ({
|
|
|
40
41
|
...props
|
|
41
42
|
}) => {
|
|
42
43
|
const sizeStyle = styles[`size_${size}`];
|
|
43
|
-
const textSizeStyle = styles[`text_${size}`];
|
|
44
44
|
const variantStyle = disabled
|
|
45
45
|
? styles.variant_disabled
|
|
46
46
|
: styles[`variant_${variant}`];
|
|
47
47
|
const textVariantStyle = disabled
|
|
48
48
|
? styles.text_disabled
|
|
49
49
|
: styles[`text_variant_${variant}`];
|
|
50
|
+
const { typography } = useTheme();
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
+
const getFontSize = () => {
|
|
52
53
|
switch (size) {
|
|
53
|
-
case 'small':
|
|
54
|
-
return 'Medium';
|
|
55
|
-
case 'regular':
|
|
56
|
-
return 'SemiBold';
|
|
57
54
|
case 'large':
|
|
58
|
-
return '
|
|
59
|
-
default:
|
|
60
|
-
return 'SemiBold';
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const getTextSize = (): number => {
|
|
65
|
-
switch (size) {
|
|
66
|
-
case 'small':
|
|
67
|
-
return 14;
|
|
55
|
+
return typography['fontSize/fs16'];
|
|
68
56
|
case 'regular':
|
|
69
|
-
return
|
|
70
|
-
case '
|
|
71
|
-
return
|
|
57
|
+
return typography['fontSize/fs14'];
|
|
58
|
+
case 'small':
|
|
59
|
+
return typography['fontSize/fs12'];
|
|
72
60
|
default:
|
|
73
|
-
return
|
|
61
|
+
return typography['fontSize/fs14'];
|
|
74
62
|
}
|
|
75
63
|
};
|
|
76
64
|
|
|
@@ -129,13 +117,11 @@ export const BaseButton: React.FC<BaseButtonProps> = ({
|
|
|
129
117
|
<>
|
|
130
118
|
{icon && iconPosition === 'left' && icon}
|
|
131
119
|
{label && (
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
size={getTextSize()}
|
|
135
|
-
style={[textSizeStyle, textVariantStyle, textStyle]}
|
|
120
|
+
<Text
|
|
121
|
+
style={[textVariantStyle, textStyle, { fontSize: getFontSize() }]}
|
|
136
122
|
>
|
|
137
123
|
{label}
|
|
138
|
-
</
|
|
124
|
+
</Text>
|
|
139
125
|
)}
|
|
140
126
|
{icon && iconPosition === 'right' && icon}
|
|
141
127
|
</>
|
|
@@ -213,13 +199,4 @@ const styles = StyleSheet.create({
|
|
|
213
199
|
'text_disabled': {
|
|
214
200
|
color: Colors.text_disabled_tertiary_light,
|
|
215
201
|
},
|
|
216
|
-
'text_small': {
|
|
217
|
-
fontSize: 14,
|
|
218
|
-
},
|
|
219
|
-
'text_regular': {
|
|
220
|
-
fontSize: 16,
|
|
221
|
-
},
|
|
222
|
-
'text_large': {
|
|
223
|
-
fontSize: 20,
|
|
224
|
-
},
|
|
225
202
|
});
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
type TextStyle,
|
|
9
9
|
type ViewStyle,
|
|
10
10
|
type KeyboardAvoidingViewProps,
|
|
11
|
+
Text,
|
|
11
12
|
} from 'react-native';
|
|
12
13
|
import { type ReactNode } from 'react';
|
|
13
14
|
import { styles } from './styles';
|
|
14
15
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
15
|
-
import { BaseText, type BaseTextType } from '../BaseText';
|
|
16
16
|
|
|
17
17
|
export interface IBaseContainer {
|
|
18
18
|
title?: string;
|
|
@@ -31,7 +31,6 @@ export interface IBaseContainer {
|
|
|
31
31
|
backgroundColorStatusBar?: ColorValue | undefined;
|
|
32
32
|
edges?: Array<'top' | 'bottom' | 'left' | 'right'>;
|
|
33
33
|
keyboardAvoidingViewProps?: Omit<KeyboardAvoidingViewProps, 'children'>;
|
|
34
|
-
type?: BaseTextType;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
export const BaseContainer = ({
|
|
@@ -51,7 +50,6 @@ export const BaseContainer = ({
|
|
|
51
50
|
styleHeader,
|
|
52
51
|
edges,
|
|
53
52
|
keyboardAvoidingViewProps,
|
|
54
|
-
type = 'Medium',
|
|
55
53
|
}: IBaseContainer) => {
|
|
56
54
|
return (
|
|
57
55
|
<KeyboardAvoidingView
|
|
@@ -82,9 +80,7 @@ export const BaseContainer = ({
|
|
|
82
80
|
{center}
|
|
83
81
|
</TouchableOpacity>
|
|
84
82
|
) : title ? (
|
|
85
|
-
<
|
|
86
|
-
{title}
|
|
87
|
-
</BaseText>
|
|
83
|
+
<Text style={styleTitle}>{title}</Text>
|
|
88
84
|
) : (
|
|
89
85
|
<View />
|
|
90
86
|
)}
|
|
@@ -1,43 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Text, type TextProps, type TextStyle } from 'react-native';
|
|
2
|
+
import { useMemo, type ReactNode } from 'react';
|
|
3
|
+
import { useTheme } from '../../core';
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const BaseTextTypes = {
|
|
6
|
+
'text12/normal': 'text12/normal',
|
|
7
|
+
'text12/medium': 'text12/medium',
|
|
8
|
+
'text12/semiBold': 'text12/semiBold',
|
|
9
|
+
'text12/bold': 'text12/bold',
|
|
10
|
+
'text14/normal': 'text14/normal',
|
|
11
|
+
'text14/medium': 'text14/medium',
|
|
12
|
+
'text14/semiBold': 'text14/semiBold',
|
|
13
|
+
'text14/bold': 'text14/bold',
|
|
14
|
+
'text16/normal': 'text16/normal',
|
|
15
|
+
'text16/medium': 'text16/medium',
|
|
16
|
+
'text16/semiBold': 'text16/semiBold',
|
|
17
|
+
'text16/bold': 'text16/bold',
|
|
18
|
+
'text18/normal': 'text18/normal',
|
|
19
|
+
'text18/medium': 'text18/medium',
|
|
20
|
+
'text18/semiBold': 'text18/semiBold',
|
|
21
|
+
'text18/bold': 'text18/bold',
|
|
22
|
+
'text20/normal': 'text20/normal',
|
|
23
|
+
'text20/medium': 'text20/medium',
|
|
24
|
+
'text20/semiBold': 'text20/semiBold',
|
|
25
|
+
'text20/bold': 'text20/bold',
|
|
26
|
+
'text24/normal': 'text24/normal',
|
|
27
|
+
'text24/medium': 'text24/medium',
|
|
28
|
+
'text24/semiBold': 'text24/semiBold',
|
|
29
|
+
'text24/bold': 'text24/bold',
|
|
30
|
+
'text30/normal': 'text30/normal',
|
|
31
|
+
'text30/medium': 'text30/medium',
|
|
32
|
+
'text30/semiBold': 'text30/semiBold',
|
|
33
|
+
'text30/bold': 'text30/bold',
|
|
34
|
+
'text36/normal': 'text36/normal',
|
|
35
|
+
'text36/medium': 'text36/medium',
|
|
36
|
+
'text36/semiBold': 'text36/semiBold',
|
|
37
|
+
'text36/bold': 'text36/bold',
|
|
38
|
+
};
|
|
39
|
+
export type EBaseTextType = keyof typeof BaseTextTypes;
|
|
40
|
+
interface IBaseText extends TextProps {
|
|
41
|
+
type: string | EBaseTextType;
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
styleText?: TextStyle;
|
|
10
44
|
}
|
|
11
|
-
|
|
12
|
-
export const BaseText: React.FC<BaseTextProps> = ({
|
|
13
|
-
type = 'Medium',
|
|
14
|
-
size,
|
|
15
|
-
style,
|
|
45
|
+
export const BaseText = ({
|
|
16
46
|
children,
|
|
47
|
+
type,
|
|
48
|
+
styleText,
|
|
17
49
|
...props
|
|
18
|
-
}) => {
|
|
50
|
+
}: IBaseText) => {
|
|
51
|
+
const { typography } = useTheme();
|
|
52
|
+
const textStyle = useMemo(() => {
|
|
53
|
+
return {
|
|
54
|
+
fontSize: typography[typography[type].fontSize],
|
|
55
|
+
fontWeight: typography[typography[type].fontWeight],
|
|
56
|
+
fontFamily: typography[typography[type].fontFamily],
|
|
57
|
+
};
|
|
58
|
+
}, [type, typography]);
|
|
59
|
+
|
|
19
60
|
return (
|
|
20
|
-
<Text
|
|
21
|
-
allowFontScaling={false}
|
|
22
|
-
style={[styles[type], { fontSize: size }, style]}
|
|
23
|
-
{...props}
|
|
24
|
-
>
|
|
61
|
+
<Text style={{ ...textStyle, ...styleText }} {...props}>
|
|
25
62
|
{children}
|
|
26
63
|
</Text>
|
|
27
64
|
);
|
|
28
65
|
};
|
|
29
|
-
|
|
30
|
-
const styles = StyleSheet.create({
|
|
31
|
-
ExtraBold: {
|
|
32
|
-
fontWeight: '700',
|
|
33
|
-
},
|
|
34
|
-
Bold: {
|
|
35
|
-
fontWeight: '600',
|
|
36
|
-
},
|
|
37
|
-
SemiBold: {
|
|
38
|
-
fontWeight: '500',
|
|
39
|
-
},
|
|
40
|
-
Medium: {
|
|
41
|
-
fontWeight: '400',
|
|
42
|
-
},
|
|
43
|
-
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { typographyDefault } from '../../assets/theme';
|
|
3
|
+
|
|
4
|
+
type dynamicType = {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
interface ThemeDynamicPart {
|
|
8
|
+
[key: string]: dynamicType;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ThemeContextType extends ThemeDynamicPart {
|
|
12
|
+
typography: dynamicType;
|
|
13
|
+
}
|
|
14
|
+
export interface IThemeProvider {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
value: ThemeContextType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DefaultTheme = {
|
|
20
|
+
typography: typographyDefault,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ThemeContext = createContext<ThemeContextType | undefined>(
|
|
24
|
+
DefaultTheme
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const ThemeProvider = ({ children, value }: IThemeProvider) => {
|
|
28
|
+
if (!value) return null;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const useTheme = (): ThemeContextType => {
|
|
36
|
+
const context = useContext(ThemeContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error('useTheme must be used within a ThemeProvider');
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './KadoProvider';
|
package/src/index.tsx
CHANGED