@momo-kits/foundation 0.109.1-optimize.17 → 0.109.1-optimize.17-beta.19

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.
@@ -7,7 +7,7 @@ import {EventArg} from '@react-navigation/core';
7
7
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
8
8
  import {Colors} from '../../Consts';
9
9
  import {Icon} from '../../Icon';
10
- import {Text} from '../../Text';
10
+ import {exportFontFamily, Text} from '../../Text';
11
11
  import {ApplicationContext} from '../index';
12
12
  import StackScreen from '../StackScreen';
13
13
  import {BottomTabProps, NavigationScreenProps} from '../types';
@@ -146,7 +146,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
146
146
  lineHeight: Platform.OS === 'android' ? 17 : 14,
147
147
  fontWeight: 'bold',
148
148
  alignSelf: 'center',
149
- fontFamily: `${theme.font}-Bold`,
149
+ fontFamily: exportFontFamily('bold'),
150
150
  left: isDot ? 8 : 4,
151
151
  top: isDot ? -2 : -6,
152
152
  backgroundColor: isNum ? Colors.red_03 : Colors.orange_03,
@@ -7,7 +7,7 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import {ApplicationContext, MiniAppContext} from '../index';
10
- import {scaleSize, Text} from '../../Text';
10
+ import {exportFontFamily, scaleSize, Text} from '../../Text';
11
11
  import {Colors, Spacing, Styles} from '../../Consts';
12
12
  import {TitleJourneyProps, TitleLocationProps, TitleUserProps} from '../types';
13
13
  import {Image} from '../../Image';
@@ -17,7 +17,6 @@ import {Icon} from '../../Icon';
17
17
  * default header title used for nav
18
18
  */
19
19
  const HeaderTitle: React.FC<any> = props => {
20
- const {theme} = useContext(ApplicationContext);
21
20
  const opacity = props.animatedValue?.interpolate(
22
21
  props.interpolate ?? {
23
22
  inputRange: [0, 200],
@@ -33,7 +32,11 @@ const HeaderTitle: React.FC<any> = props => {
33
32
  accessibilityLabel={'title_navigation_header'}
34
33
  style={[
35
34
  styles.title,
36
- {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
35
+ {
36
+ fontFamily: exportFontFamily('bold', 'action_xs_bold'),
37
+ opacity,
38
+ color: props.tintColor,
39
+ },
37
40
  ]}
38
41
  numberOfLines={1}
39
42
  />
@@ -191,13 +194,18 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
191
194
  tintColor,
192
195
  onPress,
193
196
  }) => {
197
+ const {width} = Dimensions.get('screen');
198
+ const startWidth = width * 0.25;
199
+ const endWidth = width * 0.75 - 212;
194
200
  return (
195
- <TouchableOpacity
196
- style={[styles.headerTitleContainer, {overflow: 'hidden'}]}
197
- onPress={onPress}>
201
+ <TouchableOpacity style={styles.headerTitleContainer} onPress={onPress}>
198
202
  <View style={styles.rowJourney}>
199
203
  <View style={Styles.row}>
200
- <Text typography="action_xs_bold" color={tintColor} numberOfLines={1}>
204
+ <Text
205
+ typography="action_xs_bold"
206
+ style={{maxWidth: startWidth}}
207
+ color={tintColor}
208
+ numberOfLines={1}>
201
209
  {start}
202
210
  </Text>
203
211
  <Icon
@@ -208,6 +216,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
208
216
  />
209
217
  {!!end && (
210
218
  <Text
219
+ style={{maxWidth: endWidth}}
211
220
  typography="action_xs_bold"
212
221
  color={tintColor}
213
222
  numberOfLines={1}>
package/Input/Input.tsx CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  import {ApplicationContext, ComponentContext} from '../Application';
18
18
  import {Icon} from '../Icon';
19
19
  import {Loader} from '../Loader';
20
- import {Text} from '../Text';
20
+ import {exportFontFamily, Text} from '../Text';
21
21
  import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
22
22
  import {InputProps} from './index';
23
23
  import styles from './styles';
@@ -51,7 +51,7 @@ const Input = forwardRef(
51
51
  loading = false,
52
52
  leadingIcon,
53
53
  leadingIconColor,
54
- fontWeight = 'Regular',
54
+ fontWeight,
55
55
  secureTextEntry,
56
56
  keyboardType,
57
57
  style,
@@ -223,7 +223,7 @@ const Input = forwardRef(
223
223
  styles.input,
224
224
  {
225
225
  color: textColor,
226
- fontFamily: `${theme.font}-${fontWeight}`,
226
+ fontFamily: exportFontFamily(fontWeight ?? 'regular'),
227
227
  },
228
228
  secure && haveValue && {fontSize: size === 'small' ? 18 : 22},
229
229
  ]}
package/Input/index.tsx CHANGED
@@ -110,7 +110,7 @@ export interface InputProps extends TextInputProps {
110
110
  /**
111
111
  * Optional. Represents the font weight of the text in the Input component.
112
112
  */
113
- fontWeight?: 'Regular' | 'Bold';
113
+ fontWeight?: string;
114
114
 
115
115
  /**
116
116
  * Optional. params for element tracking.
package/Radio/index.tsx CHANGED
@@ -64,10 +64,10 @@ const Radio: FC<RadioProps> = ({
64
64
  styles.radio,
65
65
  checkBoxStyle,
66
66
  disabledStyle,
67
- {marginRight: label ? Spacing.XS : 0},
67
+ {marginRight: label ? Spacing.S : 0},
68
68
  ]}
69
69
  />
70
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
70
+ {!!label && <Text typography={'body_default_regular'} style={styles.radioText}>{label}</Text>}
71
71
  </TouchableOpacity>
72
72
  </ComponentContext.Provider>
73
73
  );
package/Radio/styles.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {StyleSheet} from 'react-native';
2
- import {Radius} from '../Consts';
2
+ import {Radius, Spacing} from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  radio: {
@@ -8,4 +8,7 @@ export default StyleSheet.create({
8
8
  borderRadius: Radius.M,
9
9
  },
10
10
  container: {flex: 1},
11
+ radioText: {
12
+ marginRight: Spacing.M,
13
+ }
11
14
  });
package/Text/index.tsx CHANGED
@@ -33,6 +33,20 @@ const AlegreyaSans: TypographyWeight = {
33
33
  bold: 'Bold',
34
34
  };
35
35
 
36
+ const MomoTrustSans: TypographyWeight = {
37
+ 100: 'Light',
38
+ 200: 'Light',
39
+ 300: 'Light',
40
+ 400: 'Regular',
41
+ 500: 'Medium',
42
+ 600: 'Medium',
43
+ 700: 'Medium',
44
+ 800: 'Medium',
45
+ 900: 'Medium',
46
+ normal: 'Regular',
47
+ bold: 'Medium',
48
+ };
49
+
36
50
  const FontStyle: {[key: string]: string} = {
37
51
  italic: 'Italic',
38
52
  normal: '',
@@ -50,6 +64,12 @@ export interface TextProps extends RNTextProps {
50
64
  * It can be any valid color string (e.g., hex, rgb, rgba, etc.).
51
65
  */
52
66
  color?: string;
67
+
68
+ /**
69
+ * Optional. Represents the font-family of the text in the Text component.
70
+ * Ex: MomoSignature, MomoTrustDisplay
71
+ */
72
+ fontFamily?: string;
53
73
  }
54
74
 
55
75
  const deprecatedValues: Typography[] = [
@@ -67,49 +87,61 @@ const deprecatedValues: Typography[] = [
67
87
  'action_s',
68
88
  ];
69
89
 
90
+ const getTypoStyle = (typo: Typography, newFontFamily?: string) => {
91
+ const {theme} = useContext(ApplicationContext);
92
+ const styleSheet: {
93
+ [key: string]: any;
94
+ } = styles;
95
+ const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
96
+ const {fontWeight, fontSize, fontStyle, lineHeight} = typoStyle;
97
+ const style = FontStyle[fontStyle ?? 'normal'];
98
+ const font = newFontFamily ?? theme.font;
99
+ let fontFamily: string;
100
+
101
+ switch (font) {
102
+ case 'SFProText': {
103
+ fontFamily = `${font}-${SFProText[fontWeight]}${style}`;
104
+ break;
105
+ }
106
+ case 'AlegreyaSans': {
107
+ fontFamily = `${font}-${AlegreyaSans[fontWeight]}${style}`;
108
+ break;
109
+ }
110
+ case 'MomoTrustSans': {
111
+ fontFamily = `${font}-${MomoTrustSans[fontWeight]}${style}`;
112
+ break;
113
+ }
114
+ case 'MomoTrustDisplay':
115
+ case 'MomoSignature': {
116
+ fontFamily = font;
117
+ break;
118
+ }
119
+ default: {
120
+ fontFamily = `SFProText-${SFProText[fontWeight]}${style}`;
121
+ }
122
+ }
123
+
124
+ return {
125
+ ...typoStyle,
126
+ fontFamily,
127
+ fontSize: scaleSize(fontSize),
128
+ lineHeight: scaleSize(lineHeight),
129
+ fontStyle,
130
+ fontWeight,
131
+ };
132
+ };
133
+
70
134
  const Text: React.FC<TextProps> = ({
71
135
  typography = 'body_default_regular',
72
136
  color,
73
137
  children,
74
138
  style,
139
+ fontFamily,
75
140
  ...rest
76
141
  }) => {
77
142
  const {theme} = useContext(ApplicationContext);
78
143
 
79
- const getTypoStyle = (typo: Typography) => {
80
- const styleSheet: {
81
- [key: string]: any;
82
- } = styles;
83
- const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
84
- const {fontWeight, fontSize, fontStyle, lineHeight} = typoStyle;
85
- const style = FontStyle[fontStyle ?? 'normal'];
86
- let fontFamily: string;
87
-
88
- switch (theme.font) {
89
- case 'SFProText': {
90
- fontFamily = `${theme.font}-${SFProText[fontWeight]}${style}`;
91
- break;
92
- }
93
- case 'AlegreyaSans': {
94
- fontFamily = `${theme.font}-${AlegreyaSans[fontWeight]}${style}`;
95
- break;
96
- }
97
- default: {
98
- fontFamily = `SFProText-${SFProText[fontWeight]}${style}`;
99
- }
100
- }
101
-
102
- return {
103
- ...typoStyle,
104
- fontFamily,
105
- fontSize: scaleSize(fontSize),
106
- lineHeight: scaleSize(lineHeight),
107
- fontStyle,
108
- fontWeight,
109
- };
110
- };
111
-
112
- const textStyle = getTypoStyle(typography);
144
+ const textStyle = getTypoStyle(typography, fontFamily);
113
145
 
114
146
  if (deprecatedValues.includes(typography)) {
115
147
  console.warn(
@@ -121,10 +153,42 @@ const Text: React.FC<TextProps> = ({
121
153
  <RNText
122
154
  {...rest}
123
155
  {...getAccessibilityID(rest.accessibilityLabel)}
124
- style={[style, textStyle, {color: color ?? theme.colors.text.default}]}>
156
+ style={[
157
+ style,
158
+ textStyle,
159
+ {
160
+ color: color ?? theme.colors.text.default,
161
+ },
162
+ ]}>
125
163
  {children ?? ''}
126
164
  </RNText>
127
165
  );
128
166
  };
129
167
 
130
- export {Text, scaleSize};
168
+ const exportFontFamily = (
169
+ fontWeight: string,
170
+ typography?: Typography,
171
+ fontFamily?: string
172
+ ): string => {
173
+ let newFontFamily;
174
+
175
+ switch (fontWeight) {
176
+ case 'bold': {
177
+ typography = 'action_xs_bold';
178
+ break;
179
+ }
180
+ case 'regular': {
181
+ typography = 'body_default_regular';
182
+ break;
183
+ }
184
+ default: {
185
+ typography = 'body_default_regular';
186
+ }
187
+ }
188
+
189
+ newFontFamily = getTypoStyle(typography, fontFamily).fontFamily;
190
+
191
+ return newFontFamily;
192
+ };
193
+
194
+ export {Text, scaleSize, exportFontFamily, getTypoStyle};
package/Title/index.tsx CHANGED
@@ -38,7 +38,7 @@ const Title: FC<TitleProps> = ({
38
38
  const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
39
39
  const buttonTypo: Typography =
40
40
  buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
41
- const flexStyle = showTrailingAction && {maxWidth: '70%'};
41
+ const flexStyle = showTrailingAction && {maxWidth: '95%'};
42
42
 
43
43
  const renderIcon = () => {
44
44
  if (!icon) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.109.1-optimize.17",
3
+ "version": "0.109.1-optimize.17-beta.19",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},