@momo-kits/foundation 0.89.5 → 0.89.6-rc.2
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/Application/BottomSheet.tsx +216 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +42 -18
- package/Application/Components.tsx +350 -86
- package/Application/Localize.ts +44 -0
- package/Application/ModalScreen.tsx +14 -185
- package/Application/Navigation.ts +5 -19
- package/Application/NavigationContainer.tsx +62 -72
- package/Application/Navigator.ts +53 -35
- package/Application/StackScreen.tsx +289 -32
- package/Application/index.ts +13 -15
- package/Application/types.ts +64 -35
- package/Application/utils.tsx +76 -30
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/BadgeDotAnimation.tsx +95 -0
- package/Badge/index.tsx +2 -1
- package/Badge/styles.ts +50 -6
- package/Button/index.tsx +44 -26
- package/CheckBox/index.tsx +37 -26
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +14 -0
- package/Icon/index.tsx +9 -8
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +24 -14
- package/Image/index.tsx +23 -8
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +116 -26
- package/Input/InputDropDown.tsx +66 -51
- package/Input/InputMoney.tsx +106 -15
- package/Input/InputOTP.tsx +49 -26
- package/Input/InputSearch.tsx +252 -99
- package/Input/InputTextArea.tsx +26 -6
- package/Input/TextTyping.tsx +113 -0
- package/Input/common.tsx +48 -22
- package/Input/index.tsx +112 -77
- package/Input/styles.ts +48 -11
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +4 -3
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +3 -2
- package/Layout/Screen.tsx +242 -121
- package/Layout/Section.tsx +4 -3
- package/Layout/styles.ts +11 -13
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +56 -45
- package/Popup/PopupPromotion.tsx +5 -7
- package/Popup/types.ts +1 -7
- package/Radio/index.tsx +35 -20
- package/Radio/types.ts +5 -3
- package/Switch/index.tsx +32 -18
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +9 -2
- package/Tag/styles.ts +3 -2
- package/Tag/types.ts +12 -0
- package/Text/index.tsx +24 -5
- package/Text/styles.ts +8 -8
- package/Text/types.ts +19 -1
- package/Title/index.tsx +170 -103
- package/Title/styles.ts +36 -9
- package/Title/types.ts +16 -48
- package/code-scanner.js +125 -16
- package/index.ts +7 -0
- package/migrate_typo.js +56 -0
- package/package.json +11 -10
- package/publish.sh +16 -21
- package/tsconfig.json +1 -1
- package/verify.js +37 -40
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {ScrollView, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {PopupNotifyProps} from './types';
|
|
4
|
-
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
|
-
import {Image} from '../Image';
|
|
6
|
-
import {Text} from '../Text';
|
|
7
3
|
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
8
4
|
import {Button} from '../Button';
|
|
5
|
+
import {Radius, Spacing, Styles} from '../Consts';
|
|
9
6
|
import {Icon} from '../Icon';
|
|
7
|
+
import {Image} from '../Image';
|
|
8
|
+
import {scaleSize, Text} from '../Text';
|
|
9
|
+
import {PopupNotifyProps} from './types';
|
|
10
10
|
|
|
11
11
|
const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
12
12
|
id,
|
|
@@ -19,18 +19,16 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
19
19
|
buttonDirection = 'row',
|
|
20
20
|
onIconClose,
|
|
21
21
|
}) => {
|
|
22
|
-
const context = useContext(MiniAppContext);
|
|
22
|
+
const context = useContext<any>(MiniAppContext);
|
|
23
23
|
const {theme, navigator, translate} = useContext(ApplicationContext);
|
|
24
24
|
const [scrollContent, setScrollContent] = useState(false);
|
|
25
25
|
const closeAction = useRef('touch_outside');
|
|
26
|
-
|
|
27
26
|
let descriptionStyle = {};
|
|
28
27
|
let Description: any = View;
|
|
29
28
|
if (scrollContent) {
|
|
30
29
|
Description = ScrollView;
|
|
31
|
-
descriptionStyle = {
|
|
30
|
+
descriptionStyle = {maxHeight: scaleSize(172)};
|
|
32
31
|
}
|
|
33
|
-
|
|
34
32
|
/**
|
|
35
33
|
* tracking
|
|
36
34
|
*/
|
|
@@ -42,7 +40,8 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
42
40
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
43
41
|
}
|
|
44
42
|
const tracking = {
|
|
45
|
-
|
|
43
|
+
appId: context.appId,
|
|
44
|
+
code: context.code,
|
|
46
45
|
screen_name,
|
|
47
46
|
component_type: 'popup',
|
|
48
47
|
component_name: id,
|
|
@@ -89,6 +88,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
89
88
|
closeAction.current = 'button_action';
|
|
90
89
|
onAction(secondary?.onPress);
|
|
91
90
|
}}
|
|
91
|
+
accessibilityLabel={'btn_popup_cancel'}
|
|
92
92
|
/>
|
|
93
93
|
</View>
|
|
94
94
|
<View style={styles.buttonSpace} />
|
|
@@ -102,6 +102,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
102
102
|
closeAction.current = 'button_action';
|
|
103
103
|
onAction(primary.onPress);
|
|
104
104
|
}}
|
|
105
|
+
accessibilityLabel={'btn_popup_allow'}
|
|
105
106
|
/>
|
|
106
107
|
</View>
|
|
107
108
|
</View>
|
|
@@ -111,6 +112,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
111
112
|
return (
|
|
112
113
|
<View style={Styles.columnCenter}>
|
|
113
114
|
<Button
|
|
115
|
+
accessibilityLabel={'btn_popup_allow'}
|
|
114
116
|
title={primary.title}
|
|
115
117
|
size="medium"
|
|
116
118
|
onPress={() => {
|
|
@@ -122,6 +124,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
122
124
|
<>
|
|
123
125
|
<View style={styles.buttonSpace} />
|
|
124
126
|
<Button
|
|
127
|
+
accessibilityLabel={'btn_popup_cancel'}
|
|
125
128
|
title={secondary?.title}
|
|
126
129
|
type="text"
|
|
127
130
|
size="medium"
|
|
@@ -136,7 +139,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
136
139
|
);
|
|
137
140
|
};
|
|
138
141
|
|
|
139
|
-
if (buttonDirection
|
|
142
|
+
if (buttonDirection === 'auto') {
|
|
140
143
|
if (
|
|
141
144
|
secondary?.title &&
|
|
142
145
|
(secondary.title.length > 12 || primary.title.length > 12)
|
|
@@ -145,7 +148,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
145
148
|
}
|
|
146
149
|
return renderRow();
|
|
147
150
|
}
|
|
148
|
-
if (buttonDirection
|
|
151
|
+
if (buttonDirection === 'row') {
|
|
149
152
|
return renderRow();
|
|
150
153
|
}
|
|
151
154
|
return renderColumn();
|
|
@@ -155,53 +158,61 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
155
158
|
* build close action
|
|
156
159
|
*/
|
|
157
160
|
const buildCloseIcon = () => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
161
|
+
if (typeof onIconClose === 'function') {
|
|
162
|
+
return (
|
|
163
|
+
<TouchableOpacity
|
|
164
|
+
accessibilityLabel={'ic_popup_close'}
|
|
165
|
+
style={styles.iconCloseContainer}
|
|
166
|
+
onPress={() => {
|
|
167
|
+
closeAction.current = 'icon_close';
|
|
168
|
+
onAction(onIconClose);
|
|
169
|
+
}}>
|
|
170
|
+
<View
|
|
171
|
+
style={[
|
|
172
|
+
styles.iconClose,
|
|
173
|
+
{
|
|
174
|
+
backgroundColor: theme.colors.text.default,
|
|
175
|
+
borderColor: theme.colors.background.surface,
|
|
176
|
+
},
|
|
177
|
+
]}>
|
|
178
|
+
<Icon
|
|
179
|
+
source="navigation_close"
|
|
180
|
+
color={theme.colors.background.surface}
|
|
181
|
+
size={14}
|
|
182
|
+
/>
|
|
183
|
+
</View>
|
|
184
|
+
</TouchableOpacity>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
181
187
|
};
|
|
182
188
|
|
|
183
189
|
return (
|
|
184
190
|
<View
|
|
191
|
+
accessibilityLabel={'popup_notify'}
|
|
185
192
|
style={[
|
|
186
193
|
styles.container,
|
|
187
194
|
{backgroundColor: theme.colors.background.surface},
|
|
188
195
|
]}>
|
|
189
196
|
{!!image && <Image source={{uri: image}} style={styles.image} />}
|
|
190
197
|
<View style={styles.content}>
|
|
191
|
-
<Text typography={'header_default_bold'} numberOfLines={
|
|
198
|
+
<Text typography={'header_default_bold'} numberOfLines={3}>
|
|
192
199
|
{title}
|
|
193
200
|
</Text>
|
|
194
201
|
<Description style={[styles.description, descriptionStyle]}>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
{typeof description === 'string' ? (
|
|
203
|
+
<Text
|
|
204
|
+
typography={'body_default_regular'}
|
|
205
|
+
onTextLayout={({nativeEvent: {lines}}) => {
|
|
206
|
+
const enableScroll = lines.length > 3;
|
|
207
|
+
if (enableScroll !== scrollContent) {
|
|
208
|
+
setScrollContent(enableScroll);
|
|
209
|
+
}
|
|
210
|
+
}}>
|
|
211
|
+
{description}
|
|
212
|
+
</Text>
|
|
213
|
+
) : (
|
|
214
|
+
description
|
|
215
|
+
)}
|
|
205
216
|
</Description>
|
|
206
217
|
{!!error && (
|
|
207
218
|
<View style={styles.information}>
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -11,7 +11,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
11
11
|
image,
|
|
12
12
|
onIconClose,
|
|
13
13
|
}) => {
|
|
14
|
-
const context = useContext(MiniAppContext);
|
|
14
|
+
const context = useContext<any>(MiniAppContext);
|
|
15
15
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
16
16
|
const closeAction = useRef('touch_outside');
|
|
17
17
|
|
|
@@ -26,7 +26,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
26
26
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
27
27
|
}
|
|
28
28
|
const tracking = {
|
|
29
|
-
|
|
29
|
+
appId: context.appId,
|
|
30
|
+
code: context.code,
|
|
30
31
|
screen_name,
|
|
31
32
|
component_type: 'popup',
|
|
32
33
|
component_name: id,
|
|
@@ -51,6 +52,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
51
52
|
return (
|
|
52
53
|
<View style={styles.iconCloseContainer}>
|
|
53
54
|
<TouchableOpacity
|
|
55
|
+
accessibilityLabel={'ic_popup_close'}
|
|
54
56
|
onPress={() => {
|
|
55
57
|
closeAction.current = 'icon_close';
|
|
56
58
|
navigator?.pop();
|
|
@@ -77,7 +79,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
return (
|
|
80
|
-
<View>
|
|
82
|
+
<View accessibilityLabel={'popup_promotion'}>
|
|
81
83
|
<Image
|
|
82
84
|
source={{
|
|
83
85
|
uri: image,
|
|
@@ -113,8 +115,4 @@ const styles = StyleSheet.create({
|
|
|
113
115
|
},
|
|
114
116
|
});
|
|
115
117
|
|
|
116
|
-
PopupPromotion.defaultProps = {
|
|
117
|
-
image: 'https://google.com',
|
|
118
|
-
};
|
|
119
|
-
|
|
120
118
|
export default PopupPromotion;
|
package/Popup/types.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {TextStyle} from 'react-native';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
3
|
export type PopupNotifyProps = {
|
|
@@ -19,7 +18,7 @@ export type PopupNotifyProps = {
|
|
|
19
18
|
/**
|
|
20
19
|
* `description`: Represents the description text to be displayed in the PopupNotify component.
|
|
21
20
|
*/
|
|
22
|
-
description
|
|
21
|
+
description?: string | React.ReactNode;
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* `error`: Optional. Represents additional error text to be displayed in the PopupNotify component.
|
|
@@ -79,9 +78,4 @@ type PopupAction = {
|
|
|
79
78
|
onPress: () => void;
|
|
80
79
|
};
|
|
81
80
|
|
|
82
|
-
export type HighlightText = {
|
|
83
|
-
text: string;
|
|
84
|
-
style: TextStyle;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
81
|
type PopupActionDirection = 'row' | 'column' | 'auto';
|
package/Radio/index.tsx
CHANGED
|
@@ -4,8 +4,9 @@ import {TouchableOpacity, View} from 'react-native';
|
|
|
4
4
|
import {RadioProps} from './types';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
6
|
import styles from './styles';
|
|
7
|
-
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
|
+
import {formatNameLength} from '../Application/utils';
|
|
9
10
|
|
|
10
11
|
const Radio: FC<RadioProps> = ({
|
|
11
12
|
value,
|
|
@@ -14,6 +15,8 @@ const Radio: FC<RadioProps> = ({
|
|
|
14
15
|
onChange,
|
|
15
16
|
label,
|
|
16
17
|
style,
|
|
18
|
+
params,
|
|
19
|
+
accessibilityLabel,
|
|
17
20
|
}) => {
|
|
18
21
|
const {theme} = useContext(ApplicationContext);
|
|
19
22
|
const selected = value === groupValue;
|
|
@@ -38,26 +41,38 @@ const Radio: FC<RadioProps> = ({
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
return (
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<
|
|
44
|
+
<ComponentContext.Provider
|
|
45
|
+
value={{
|
|
46
|
+
componentName: 'Radio',
|
|
47
|
+
params,
|
|
48
|
+
state: disabled ? 'disabled' : 'enabled',
|
|
49
|
+
componentId: accessibilityLabel,
|
|
50
|
+
componentLabel: formatNameLength(label || ''),
|
|
51
|
+
componentValue: selected,
|
|
52
|
+
action: 'click',
|
|
53
|
+
}}>
|
|
54
|
+
<TouchableOpacity
|
|
55
|
+
accessibilityLabel={accessibilityLabel}
|
|
56
|
+
onPress={onChange}
|
|
57
|
+
disabled={disabled}
|
|
52
58
|
style={[
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
style,
|
|
60
|
+
{
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
},
|
|
64
|
+
]}>
|
|
65
|
+
<View
|
|
66
|
+
style={[
|
|
67
|
+
styles.radio,
|
|
68
|
+
checkBoxStyle,
|
|
69
|
+
disabledStyle,
|
|
70
|
+
{marginRight: label ? Spacing.XS : 0},
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
</ComponentContext.Provider>
|
|
61
76
|
);
|
|
62
77
|
};
|
|
63
78
|
|
package/Radio/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
1
|
+
import {TouchableOpacityProps, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface RadioProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* `value`: Represents the value associated with the Radio component.
|
|
6
6
|
* It is used to determine whether the Radio component is selected or not in comparison with the `groupValue`.
|
|
@@ -35,4 +35,6 @@ export type RadioProps = {
|
|
|
35
35
|
* Accepts an object of style properties.
|
|
36
36
|
*/
|
|
37
37
|
style?: ViewStyle;
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
params?: any;
|
|
40
|
+
}
|
package/Switch/index.tsx
CHANGED
|
@@ -3,9 +3,16 @@ import {TouchableOpacity, View} from 'react-native';
|
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Colors} from '../Consts';
|
|
6
|
+
import {ComponentContext} from '../Application';
|
|
6
7
|
|
|
7
|
-
const Switch: FC<SwitchProps> =
|
|
8
|
-
|
|
8
|
+
const Switch: FC<SwitchProps> = ({
|
|
9
|
+
value = false,
|
|
10
|
+
onChange,
|
|
11
|
+
disabled = false,
|
|
12
|
+
style,
|
|
13
|
+
params,
|
|
14
|
+
accessibilityLabel,
|
|
15
|
+
}) => {
|
|
9
16
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
10
17
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
11
18
|
|
|
@@ -15,23 +22,30 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
<ComponentContext.Provider
|
|
26
|
+
value={{
|
|
27
|
+
componentName: 'Switch',
|
|
28
|
+
params,
|
|
29
|
+
state: disabled ? 'disabled' : 'enabled',
|
|
30
|
+
componentId: accessibilityLabel,
|
|
31
|
+
componentValue: value,
|
|
32
|
+
action: 'click',
|
|
33
|
+
}}>
|
|
34
|
+
<TouchableOpacity
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
accessibilityLabel={accessibilityLabel}
|
|
37
|
+
onPress={() => onChange?.(!value)}
|
|
38
|
+
style={[
|
|
39
|
+
style,
|
|
40
|
+
styles.container,
|
|
41
|
+
{backgroundColor, alignItems: circleAlign},
|
|
42
|
+
]}>
|
|
43
|
+
<View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
|
|
44
|
+
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
45
|
+
</View>
|
|
46
|
+
</TouchableOpacity>
|
|
47
|
+
</ComponentContext.Provider>
|
|
30
48
|
);
|
|
31
49
|
};
|
|
32
50
|
|
|
33
|
-
Switch.defaultProps = {
|
|
34
|
-
value: false,
|
|
35
|
-
disabled: false,
|
|
36
|
-
};
|
|
37
51
|
export {Switch};
|
package/Switch/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
1
|
+
import {TouchableOpacityProps, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface SwitchProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* `value`: Represents whether the Switch component is currently in the 'on' (`true`) or 'off' (`false`) state.
|
|
6
6
|
*/
|
|
@@ -23,4 +23,6 @@ export type SwitchProps = {
|
|
|
23
23
|
* Accepts an object of style properties.
|
|
24
24
|
*/
|
|
25
25
|
style?: ViewStyle;
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
params?: any;
|
|
28
|
+
}
|
package/Tag/index.tsx
CHANGED
|
@@ -31,6 +31,8 @@ const Tag: FC<TagProps> = ({
|
|
|
31
31
|
size = 'large',
|
|
32
32
|
style,
|
|
33
33
|
customColor,
|
|
34
|
+
accessibilityLabelContainer,
|
|
35
|
+
accessibilityLabelText,
|
|
34
36
|
}) => {
|
|
35
37
|
let labelColor = textColor[color];
|
|
36
38
|
let tagColor = backgroundColor[color];
|
|
@@ -60,7 +62,9 @@ const Tag: FC<TagProps> = ({
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
return (
|
|
63
|
-
<View
|
|
65
|
+
<View
|
|
66
|
+
style={[style, sizeStyle, {backgroundColor: tagColor}]}
|
|
67
|
+
accessibilityLabel={accessibilityLabelContainer}>
|
|
64
68
|
{!!icon && (
|
|
65
69
|
<Icon
|
|
66
70
|
style={styles.icon}
|
|
@@ -69,7 +73,10 @@ const Tag: FC<TagProps> = ({
|
|
|
69
73
|
color={labelColor}
|
|
70
74
|
/>
|
|
71
75
|
)}
|
|
72
|
-
<Text
|
|
76
|
+
<Text
|
|
77
|
+
color={labelColor}
|
|
78
|
+
typography={'label_s_medium'}
|
|
79
|
+
accessibilityLabel={accessibilityLabelText}>
|
|
73
80
|
{label}
|
|
74
81
|
</Text>
|
|
75
82
|
</View>
|
package/Tag/styles.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
2
|
import {Radius, Spacing} from '../Consts';
|
|
3
|
+
import {scaleSize} from '../Text';
|
|
3
4
|
|
|
4
5
|
export default StyleSheet.create({
|
|
5
6
|
container: {
|
|
6
7
|
paddingHorizontal: Spacing.S,
|
|
7
8
|
borderRadius: Radius.S,
|
|
8
9
|
flexDirection: 'row',
|
|
9
|
-
height: 24,
|
|
10
|
+
height: scaleSize(24),
|
|
10
11
|
alignItems: 'center',
|
|
11
12
|
justifyContent: 'center',
|
|
12
13
|
},
|
|
13
14
|
mediumContainer: {
|
|
14
15
|
paddingHorizontal: Spacing.S,
|
|
15
16
|
borderRadius: Radius.S,
|
|
16
|
-
height: 18,
|
|
17
|
+
height: scaleSize(18),
|
|
17
18
|
alignItems: 'center',
|
|
18
19
|
flexDirection: 'row',
|
|
19
20
|
justifyContent: 'center',
|
package/Tag/types.ts
CHANGED
|
@@ -33,4 +33,16 @@ export type TagProps = {
|
|
|
33
33
|
* that can be applied to the Tag component.
|
|
34
34
|
*/
|
|
35
35
|
customColor?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
|
|
39
|
+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
|
|
40
|
+
*/
|
|
41
|
+
accessibilityLabelContainer?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
|
|
45
|
+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
|
|
46
|
+
*/
|
|
47
|
+
accessibilityLabelText?: string;
|
|
36
48
|
};
|
package/Text/index.tsx
CHANGED
|
@@ -51,8 +51,24 @@ export interface TextProps extends RNTextProps {
|
|
|
51
51
|
*/
|
|
52
52
|
color?: string;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
const deprecatedValues: Typography[] = [
|
|
56
|
+
'headline_default',
|
|
57
|
+
'headline_l',
|
|
58
|
+
'headline_xl',
|
|
59
|
+
'title_default',
|
|
60
|
+
'title_xs',
|
|
61
|
+
'title_s',
|
|
62
|
+
'header_default',
|
|
63
|
+
'paragraph_default',
|
|
64
|
+
'paragraph_bold',
|
|
65
|
+
'paragraph_italic',
|
|
66
|
+
'label_xxs',
|
|
67
|
+
'action_s',
|
|
68
|
+
];
|
|
69
|
+
|
|
54
70
|
const Text: React.FC<TextProps> = ({
|
|
55
|
-
typography,
|
|
71
|
+
typography = 'body_default_regular',
|
|
56
72
|
color,
|
|
57
73
|
children,
|
|
58
74
|
style,
|
|
@@ -94,6 +110,13 @@ const Text: React.FC<TextProps> = ({
|
|
|
94
110
|
};
|
|
95
111
|
|
|
96
112
|
const textStyle = getTypoStyle(typography);
|
|
113
|
+
|
|
114
|
+
if (deprecatedValues.includes(typography)) {
|
|
115
|
+
console.warn(
|
|
116
|
+
`Warning: The typography value "${typography}" is deprecated.`,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
97
120
|
return (
|
|
98
121
|
<RNText
|
|
99
122
|
{...rest}
|
|
@@ -103,8 +126,4 @@ const Text: React.FC<TextProps> = ({
|
|
|
103
126
|
);
|
|
104
127
|
};
|
|
105
128
|
|
|
106
|
-
Text.defaultProps = {
|
|
107
|
-
typography: 'body_default_regular',
|
|
108
|
-
};
|
|
109
|
-
|
|
110
129
|
export {Text, scaleSize};
|
package/Text/styles.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
headline_default_bold: {fontSize: 24, lineHeight:
|
|
3
|
-
header_m_bold: {fontSize: 18, lineHeight:
|
|
2
|
+
headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
|
|
3
|
+
header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
|
|
4
4
|
header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
5
5
|
header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
|
|
6
|
-
header_xs_semibold: {fontSize: 12, lineHeight:
|
|
6
|
+
header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
|
|
7
7
|
body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
|
|
8
|
-
|
|
8
|
+
body_default_regularstrikethrought: {
|
|
9
9
|
fontSize: 14,
|
|
10
10
|
lineHeight: 20,
|
|
11
11
|
fontWeight: '400',
|
|
@@ -13,12 +13,12 @@ export default {
|
|
|
13
13
|
},
|
|
14
14
|
description_default_regular: {
|
|
15
15
|
fontSize: 12,
|
|
16
|
-
lineHeight:
|
|
16
|
+
lineHeight: 18,
|
|
17
17
|
fontWeight: '400',
|
|
18
18
|
},
|
|
19
19
|
description_default_regularstrikethrought: {
|
|
20
20
|
fontSize: 12,
|
|
21
|
-
lineHeight:
|
|
21
|
+
lineHeight: 18,
|
|
22
22
|
fontWeight: '400',
|
|
23
23
|
textDecorationLine: 'line-through',
|
|
24
24
|
},
|
|
@@ -30,11 +30,11 @@ export default {
|
|
|
30
30
|
textDecorationLine: 'line-through',
|
|
31
31
|
},
|
|
32
32
|
label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
|
|
33
|
-
label_s_medium: {fontSize: 12, lineHeight:
|
|
33
|
+
label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
|
|
34
34
|
label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
|
|
35
35
|
action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
36
36
|
action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
|
|
37
|
-
action_xs_bold: {fontSize: 12, lineHeight:
|
|
37
|
+
action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
|
|
38
38
|
action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
|
|
39
39
|
/**non-support**/
|
|
40
40
|
headline_default: {
|
package/Text/types.ts
CHANGED
|
@@ -14,13 +14,31 @@ export type TypographyWeight = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type Typography =
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
**/
|
|
20
|
+
| 'headline_default'
|
|
21
|
+
| 'headline_l'
|
|
22
|
+
| 'headline_xl'
|
|
23
|
+
| 'title_default'
|
|
24
|
+
| 'title_xs'
|
|
25
|
+
| 'title_s'
|
|
26
|
+
| 'header_default'
|
|
27
|
+
| 'paragraph_default'
|
|
28
|
+
| 'paragraph_bold'
|
|
29
|
+
| 'paragraph_italic'
|
|
30
|
+
| 'label_xxs'
|
|
31
|
+
| 'action_s'
|
|
32
|
+
/**
|
|
33
|
+
* end
|
|
34
|
+
**/
|
|
17
35
|
| 'headline_default_bold'
|
|
18
36
|
| 'header_m_bold'
|
|
19
37
|
| 'header_default_bold'
|
|
20
38
|
| 'header_s_semibold'
|
|
21
39
|
| 'header_xs_semibold'
|
|
22
40
|
| 'body_default_regular'
|
|
23
|
-
| '
|
|
41
|
+
| 'body_default_regularstrikethrought'
|
|
24
42
|
| 'description_default_regular'
|
|
25
43
|
| 'description_default_regularstrikethrought'
|
|
26
44
|
| 'description_xs_regular'
|