@momo-kits/foundation 0.154.1-beta.5 → 0.154.1-beta.7
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/NavigationContainer.tsx +4 -5
- package/Application/types.ts +3 -2
- package/Input/Input.tsx +2 -1
- package/Input/InputDropDown.tsx +3 -2
- package/Input/InputMoney.tsx +2 -1
- package/Input/InputPhoneNumber.tsx +2 -1
- package/Input/common.tsx +9 -3
- package/Text/index.tsx +7 -12
- package/Text/styles.ts +4 -0
- package/Text/utils.ts +2 -6
- package/package.json +1 -1
|
@@ -40,22 +40,21 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
40
40
|
enableHapticDialog: true,
|
|
41
41
|
enableForceFoundationList: false,
|
|
42
42
|
enableHapticBottomTab: true,
|
|
43
|
-
scaleSizeMaxRate: 1.5,
|
|
44
43
|
},
|
|
45
44
|
}) => {
|
|
46
45
|
const context = useContext<any>(MiniAppContext);
|
|
47
46
|
const [currentContext, setCurrentContext] = useState({});
|
|
48
47
|
|
|
49
|
-
const isBaselineEnabled = context?.isBaselineEnabled ?? false;
|
|
50
|
-
|
|
51
48
|
return (
|
|
52
49
|
<SafeAreaProvider>
|
|
53
50
|
<MiniAppContext.Provider
|
|
54
51
|
value={{
|
|
55
52
|
...context,
|
|
56
53
|
...currentContext,
|
|
57
|
-
features
|
|
58
|
-
|
|
54
|
+
features: {
|
|
55
|
+
...context?.features,
|
|
56
|
+
...features,
|
|
57
|
+
},
|
|
59
58
|
}}
|
|
60
59
|
>
|
|
61
60
|
<Navigation
|
package/Application/types.ts
CHANGED
|
@@ -142,11 +142,12 @@ export type Tool = {
|
|
|
142
142
|
onPress: () => void;
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
-
export type
|
|
145
|
+
export type FeatureFlags = {
|
|
146
146
|
enableFoundationList?: boolean;
|
|
147
147
|
enableBottomTabAnimation?: boolean;
|
|
148
148
|
enableHapticBottomTab?: boolean;
|
|
149
149
|
enableHapticDialog?: boolean;
|
|
150
|
+
showBaseLineDebug?: boolean;
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
export type NavigationContainerProps = {
|
|
@@ -156,7 +157,7 @@ export type NavigationContainerProps = {
|
|
|
156
157
|
maxApi: any;
|
|
157
158
|
initialParams?: any;
|
|
158
159
|
localize: LocalizeProps;
|
|
159
|
-
features?:
|
|
160
|
+
features?: FeatureFlags;
|
|
160
161
|
};
|
|
161
162
|
|
|
162
163
|
export type WidgetContainerProps = {
|
package/Input/Input.tsx
CHANGED
|
@@ -70,6 +70,7 @@ const Input = forwardRef(
|
|
|
70
70
|
) => {
|
|
71
71
|
const { theme } = useContext(ApplicationContext);
|
|
72
72
|
const scaledFontSize = useScaleSize(14);
|
|
73
|
+
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
|
|
73
74
|
const [focused, setFocused] = useState(false);
|
|
74
75
|
const haveValue = !!value || !!defaultValue;
|
|
75
76
|
const inputRef = useRef<TextInput | null>(null);
|
|
@@ -135,7 +136,7 @@ const Input = forwardRef(
|
|
|
135
136
|
style={[
|
|
136
137
|
styles.inputWrapper,
|
|
137
138
|
{ backgroundColor: theme.colors.background.surface },
|
|
138
|
-
getSizeStyle(size),
|
|
139
|
+
getSizeStyle(size, undefined, scaleHeight),
|
|
139
140
|
getBorderColor(theme, focused, errorMessage, disabled),
|
|
140
141
|
]}
|
|
141
142
|
>
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
getSizeStyle,
|
|
11
11
|
} from './common';
|
|
12
12
|
import { InputDropDownProps } from './index';
|
|
13
|
-
import { Text } from '../Text';
|
|
13
|
+
import { Text, useScaleSize } from '../Text';
|
|
14
14
|
import styles from './styles';
|
|
15
15
|
import { Spacing } from '../Consts';
|
|
16
16
|
|
|
@@ -35,6 +35,7 @@ const InputDropDown = ({
|
|
|
35
35
|
...props
|
|
36
36
|
}: InputDropDownProps) => {
|
|
37
37
|
const { theme } = useContext(ApplicationContext);
|
|
38
|
+
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
|
|
38
39
|
const componentName = 'InputDropDown';
|
|
39
40
|
|
|
40
41
|
const { componentId } = useComponentId(
|
|
@@ -60,7 +61,7 @@ const InputDropDown = ({
|
|
|
60
61
|
style={[
|
|
61
62
|
styles.inputDropDownWrapper,
|
|
62
63
|
{ backgroundColor: theme.colors.background.surface },
|
|
63
|
-
getSizeStyle(size, multiline),
|
|
64
|
+
getSizeStyle(size, multiline, scaleHeight),
|
|
64
65
|
getBorderColor(theme, false, errorMessage, disabled as boolean),
|
|
65
66
|
]}
|
|
66
67
|
>
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -62,6 +62,7 @@ const InputMoney = forwardRef(
|
|
|
62
62
|
ref,
|
|
63
63
|
) => {
|
|
64
64
|
const { theme } = useContext(ApplicationContext);
|
|
65
|
+
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
|
|
65
66
|
const scaledFontSize = useScaleSize(20);
|
|
66
67
|
const [focused, setFocused] = useState(false);
|
|
67
68
|
const [displayValue, setDisplayValue] = useState('');
|
|
@@ -198,7 +199,7 @@ const InputMoney = forwardRef(
|
|
|
198
199
|
style={[
|
|
199
200
|
styles.inputWrapper,
|
|
200
201
|
{ backgroundColor: theme.colors.background.surface },
|
|
201
|
-
getSizeStyle(size),
|
|
202
|
+
getSizeStyle(size, undefined, scaleHeight),
|
|
202
203
|
getBorderColor(theme, focused, errorMessage, disabled),
|
|
203
204
|
]}
|
|
204
205
|
>
|
|
@@ -62,6 +62,7 @@ const InputPhoneNumber = forwardRef(
|
|
|
62
62
|
ref,
|
|
63
63
|
) => {
|
|
64
64
|
const { theme } = useContext(ApplicationContext);
|
|
65
|
+
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
|
|
65
66
|
const [focused, setFocused] = useState(false);
|
|
66
67
|
const haveValue = !!value || !!defaultValue;
|
|
67
68
|
const inputRef = useRef<TextInput | null>(null);
|
|
@@ -142,7 +143,7 @@ const InputPhoneNumber = forwardRef(
|
|
|
142
143
|
style={[
|
|
143
144
|
styles.inputWrapper,
|
|
144
145
|
{ backgroundColor: theme.colors.background.surface },
|
|
145
|
-
getSizeStyle(size),
|
|
146
|
+
getSizeStyle(size, undefined, scaleHeight),
|
|
146
147
|
{ borderWidth },
|
|
147
148
|
getBorderColor(theme, focused, errorMessage, disabled),
|
|
148
149
|
]}
|
package/Input/common.tsx
CHANGED
|
@@ -61,8 +61,12 @@ export const getBorderColor = (
|
|
|
61
61
|
export const getSizeStyle = (
|
|
62
62
|
size?: 'small' | 'large',
|
|
63
63
|
multiline: boolean = false,
|
|
64
|
+
height?: number,
|
|
64
65
|
) => {
|
|
65
|
-
|
|
66
|
+
let scaleStyle: ViewStyle = {};
|
|
67
|
+
if (height) {
|
|
68
|
+
scaleStyle = { height };
|
|
69
|
+
}
|
|
66
70
|
|
|
67
71
|
if (multiline)
|
|
68
72
|
return [
|
|
@@ -70,13 +74,15 @@ export const getSizeStyle = (
|
|
|
70
74
|
{
|
|
71
75
|
minHeight: size === 'small' ? 48 : 56,
|
|
72
76
|
},
|
|
77
|
+
scaleStyle,
|
|
73
78
|
];
|
|
74
79
|
|
|
75
80
|
if (size === 'small') {
|
|
76
|
-
return [styles.smallContainer,
|
|
81
|
+
return [styles.smallContainer, scaleStyle];
|
|
77
82
|
}
|
|
78
|
-
return [styles.container,
|
|
83
|
+
return [styles.container, scaleStyle];
|
|
79
84
|
};
|
|
85
|
+
|
|
80
86
|
export const ErrorView: FC<{
|
|
81
87
|
errorMessage?: string;
|
|
82
88
|
errorSpacing?: boolean;
|
package/Text/index.tsx
CHANGED
|
@@ -2,10 +2,13 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { Text as RNText, TextProps as RNTextProps, View } from 'react-native';
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import { Typography, TypographyWeight } from './types';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ApplicationContext,
|
|
7
|
+
MiniAppContext,
|
|
8
|
+
SkeletonContext,
|
|
9
|
+
} from '../Context';
|
|
6
10
|
import { scaleSize, useScaleSize } from './utils';
|
|
7
11
|
import { Skeleton } from '../Skeleton';
|
|
8
|
-
import { Colors } from '../Consts';
|
|
9
12
|
|
|
10
13
|
const SFProText: TypographyWeight = {
|
|
11
14
|
100: 'Thin',
|
|
@@ -166,15 +169,7 @@ const Text: React.FC<TextProps> = ({
|
|
|
166
169
|
);
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
const isDebugBaseline = context?.isBaselineEnabled ?? false;
|
|
171
|
-
|
|
172
|
-
const baseLineStyle = isDebugBaseline
|
|
173
|
-
? {
|
|
174
|
-
borderWidth: 1,
|
|
175
|
-
borderColor: Colors.green_06,
|
|
176
|
-
}
|
|
177
|
-
: {};
|
|
172
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
178
173
|
|
|
179
174
|
if (skeleton.loading) {
|
|
180
175
|
return (
|
|
@@ -203,7 +198,7 @@ const Text: React.FC<TextProps> = ({
|
|
|
203
198
|
style={[
|
|
204
199
|
style,
|
|
205
200
|
textStyle,
|
|
206
|
-
|
|
201
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
207
202
|
{
|
|
208
203
|
color: color ?? theme.colors.text.default,
|
|
209
204
|
},
|
package/Text/styles.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Colors } from '../Consts';
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
headline_l_bold: { fontSize: 28, lineHeight: 40, fontWeight: '700' },
|
|
3
5
|
headline_default_bold: { fontSize: 24, lineHeight: 34, fontWeight: '700' },
|
|
@@ -71,4 +73,6 @@ export default {
|
|
|
71
73
|
action_xxs: { fontSize: 10, lineHeight: 14, fontWeight: '700' },
|
|
72
74
|
action_xs: { fontSize: 12, lineHeight: 16, fontWeight: '700' },
|
|
73
75
|
action_s: { fontSize: 15, lineHeight: 22, fontWeight: '700' },
|
|
76
|
+
|
|
77
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
74
78
|
};
|
package/Text/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ScaleSizeContext } from '../Context';
|
|
4
4
|
|
|
5
5
|
const deviceWidth = Dimensions.get('window').width;
|
|
6
6
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
@@ -8,17 +8,13 @@ const MAX_FONT_SCALE = 1.5;
|
|
|
8
8
|
const MAX_DEVICE_SCALE = 5;
|
|
9
9
|
|
|
10
10
|
const useScaleSize = (size: number, scaleRate?: number) => {
|
|
11
|
-
const context = useContext<any>(MiniAppContext);
|
|
12
11
|
const scaleSizeContext = useContext<any>(ScaleSizeContext);
|
|
13
12
|
const fontScale = PixelRatio.getFontScale();
|
|
14
13
|
const windowSize = useWindowDimensions();
|
|
15
14
|
const deviceScale = windowSize.width / DEFAULT_SCREEN_SIZE;
|
|
16
15
|
|
|
17
16
|
const maxScaleRate =
|
|
18
|
-
scaleRate ||
|
|
19
|
-
scaleSizeContext?.scaleSizeMaxRate ||
|
|
20
|
-
context?.features?.scaleSizeMaxRate ||
|
|
21
|
-
MAX_FONT_SCALE;
|
|
17
|
+
scaleRate || scaleSizeContext?.scaleSizeMaxRate || MAX_FONT_SCALE;
|
|
22
18
|
|
|
23
19
|
let fontSizeDeviceScale = size;
|
|
24
20
|
let fontSizeOSScale = size;
|