react-native-shared-components 0.3.3 → 0.3.4
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 +5 -28
- 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 +7 -31
- 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
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type TouchableOpacityProps,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { Colors } from '../../constants/Colors';
|
|
11
|
-
import { BaseText, type
|
|
11
|
+
import { BaseText, type EBaseTextType } from '../BaseText';
|
|
12
12
|
|
|
13
13
|
export type ButtonVariant = 'primary' | 'link-subtle' | 'red' | 'brand-subtle';
|
|
14
14
|
export type ButtonSize = 'small' | 'regular' | 'large';
|
|
@@ -40,7 +40,6 @@ export const BaseButton: React.FC<BaseButtonProps> = ({
|
|
|
40
40
|
...props
|
|
41
41
|
}) => {
|
|
42
42
|
const sizeStyle = styles[`size_${size}`];
|
|
43
|
-
const textSizeStyle = styles[`text_${size}`];
|
|
44
43
|
const variantStyle = disabled
|
|
45
44
|
? styles.variant_disabled
|
|
46
45
|
: styles[`variant_${variant}`];
|
|
@@ -48,29 +47,16 @@ export const BaseButton: React.FC<BaseButtonProps> = ({
|
|
|
48
47
|
? styles.text_disabled
|
|
49
48
|
: styles[`text_variant_${variant}`];
|
|
50
49
|
|
|
51
|
-
const getTextType = ():
|
|
50
|
+
const getTextType = (): EBaseTextType => {
|
|
52
51
|
switch (size) {
|
|
53
52
|
case 'small':
|
|
54
|
-
return '
|
|
53
|
+
return 'tex14/medium';
|
|
55
54
|
case 'regular':
|
|
56
|
-
return '
|
|
55
|
+
return 'text16/semiBold';
|
|
57
56
|
case 'large':
|
|
58
|
-
return '
|
|
57
|
+
return 'text20/semiBold';
|
|
59
58
|
default:
|
|
60
|
-
return '
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const getTextSize = (): number => {
|
|
65
|
-
switch (size) {
|
|
66
|
-
case 'small':
|
|
67
|
-
return 14;
|
|
68
|
-
case 'regular':
|
|
69
|
-
return 16;
|
|
70
|
-
case 'large':
|
|
71
|
-
return 20;
|
|
72
|
-
default:
|
|
73
|
-
return 16;
|
|
59
|
+
return 'text16/semiBold';
|
|
74
60
|
}
|
|
75
61
|
};
|
|
76
62
|
|
|
@@ -131,8 +117,7 @@ export const BaseButton: React.FC<BaseButtonProps> = ({
|
|
|
131
117
|
{label && (
|
|
132
118
|
<BaseText
|
|
133
119
|
type={getTextType()}
|
|
134
|
-
|
|
135
|
-
style={[textSizeStyle, textVariantStyle, textStyle]}
|
|
120
|
+
style={[textVariantStyle, textStyle]}
|
|
136
121
|
>
|
|
137
122
|
{label}
|
|
138
123
|
</BaseText>
|
|
@@ -213,13 +198,4 @@ const styles = StyleSheet.create({
|
|
|
213
198
|
'text_disabled': {
|
|
214
199
|
color: Colors.text_disabled_tertiary_light,
|
|
215
200
|
},
|
|
216
|
-
'text_small': {
|
|
217
|
-
fontSize: 14,
|
|
218
|
-
},
|
|
219
|
-
'text_regular': {
|
|
220
|
-
fontSize: 16,
|
|
221
|
-
},
|
|
222
|
-
'text_large': {
|
|
223
|
-
fontSize: 20,
|
|
224
|
-
},
|
|
225
201
|
});
|
|
@@ -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
|
+
'tex14/normal': 'tex14/normal',
|
|
11
|
+
'tex14/medium': 'tex14/medium',
|
|
12
|
+
'tex14/semiBold': 'tex14/semiBold',
|
|
13
|
+
'tex14/bold': 'tex14/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
|
+
'tex36/normal': 'tex36/normal',
|
|
35
|
+
'tex36/medium': 'tex36/medium',
|
|
36
|
+
'tex36/semiBold': 'tex36/semiBold',
|
|
37
|
+
'tex36/bold': 'tex36/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