@hero-design/rn 7.1.3-alpha → 7.1.3-alpha4
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/assets/fonts/be-vietnam-pro-light.ttf +0 -0
- package/assets/fonts/be-vietnam-pro-regular.ttf +0 -0
- package/assets/fonts/be-vietnam-pro-semibold.ttf +0 -0
- package/es/index.js +96 -38
- package/lib/index.js +95 -37
- package/package.json +1 -1
- package/playground/components/Card.tsx +1 -1
- package/playground/components/Typography.tsx +2 -2
- package/playground/index.tsx +13 -6
- package/src/components/Badge/StyledBadge.tsx +1 -1
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +4 -4
- package/src/components/BottomNavigation/__tests__/__snapshots__/BottomNavigation.spec.tsx.snap +4 -4
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -1
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +1 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +24 -24
- package/src/components/FAB/ActionGroup/index.tsx +1 -1
- package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +1 -1
- package/src/components/Typography/Text/StyledText.tsx +3 -3
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +9 -9
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +13 -14
- package/src/theme/components/badge.ts +5 -5
- package/src/theme/components/fab.ts +6 -6
- package/src/theme/components/typography.ts +7 -7
- package/src/theme/global/index.ts +2 -2
- package/src/theme/global/typography.ts +7 -8
- package/src/utils/scale.ts +68 -5
- package/types/src/theme/components/badge.d.ts +3 -3
- package/types/src/theme/components/fab.d.ts +4 -4
- package/types/src/theme/components/typography.d.ts +5 -5
- package/types/src/theme/global/index.d.ts +5 -6
- package/types/src/theme/global/typography.d.ts +6 -7
package/src/utils/scale.ts
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
1
|
+
import { PixelRatio, Dimensions } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
4
|
-
|
|
4
|
+
const pixelRatio = PixelRatio.get();
|
|
5
|
+
const deviceHeight = Dimensions.get('window').height;
|
|
6
|
+
const deviceWidth = Dimensions.get('window').width;
|
|
5
7
|
export const scale = (size: number) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
if (pixelRatio >= 2 && pixelRatio < 3) {
|
|
9
|
+
// iphone 5s and older Androids
|
|
10
|
+
if (deviceWidth < BASE_WIDTH) {
|
|
11
|
+
return size * 0.95;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// iphone 5
|
|
15
|
+
if (deviceHeight < 667) {
|
|
16
|
+
return size;
|
|
17
|
+
// iphone 6-6s
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
21
|
+
return size * 1.15;
|
|
22
|
+
}
|
|
23
|
+
// older phablets
|
|
24
|
+
return size * 1.25;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (pixelRatio >= 3 && pixelRatio < 3.5) {
|
|
28
|
+
// catch Android font scaling on small machines
|
|
29
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
30
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
31
|
+
return size;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Catch other weird android width sizings
|
|
35
|
+
if (deviceHeight < 667) {
|
|
36
|
+
return size * 1.15;
|
|
37
|
+
// catch in-between size Androids and scale font up
|
|
38
|
+
// a tad but not too much
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
42
|
+
return size * 1.2;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// catch larger devices
|
|
46
|
+
// ie iphone 6s plus / 7 plus / mi note 等等
|
|
47
|
+
return size * 1.27;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (pixelRatio >= 3.5) {
|
|
51
|
+
// catch Android font scaling on small machines
|
|
52
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
53
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
54
|
+
return size;
|
|
55
|
+
// Catch other smaller android height sizings
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (deviceHeight < 667) {
|
|
59
|
+
return size * 1.2;
|
|
60
|
+
// catch in-between size Androids and scale font up
|
|
61
|
+
// a tad but not too much
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
65
|
+
return size * 1.25;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// catch larger phablet devices
|
|
69
|
+
return size * 1.4;
|
|
70
|
+
}
|
|
8
71
|
|
|
9
|
-
return
|
|
72
|
+
return size;
|
|
10
73
|
};
|
|
@@ -16,11 +16,11 @@ declare const getBadgeTheme: (theme: GlobalTheme) => {
|
|
|
16
16
|
padding: {
|
|
17
17
|
default: string;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
fonts: {
|
|
20
20
|
default: string;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
default:
|
|
22
|
+
fontSizes: {
|
|
23
|
+
default: string;
|
|
24
24
|
};
|
|
25
25
|
radii: {
|
|
26
26
|
default: string;
|
|
@@ -3,6 +3,10 @@ declare const getFABTheme: (theme: GlobalTheme) => {
|
|
|
3
3
|
radii: {
|
|
4
4
|
actionItem: string;
|
|
5
5
|
};
|
|
6
|
+
fonts: {
|
|
7
|
+
header: string;
|
|
8
|
+
actionItemText: string;
|
|
9
|
+
};
|
|
6
10
|
fontSizes: {
|
|
7
11
|
header: string;
|
|
8
12
|
buttonIcon: string;
|
|
@@ -23,10 +27,6 @@ declare const getFABTheme: (theme: GlobalTheme) => {
|
|
|
23
27
|
header: string;
|
|
24
28
|
actionItemText: string;
|
|
25
29
|
};
|
|
26
|
-
fontWeights: {
|
|
27
|
-
header: string;
|
|
28
|
-
actionItemText: string;
|
|
29
|
-
};
|
|
30
30
|
space: {
|
|
31
31
|
actionItemPaddingLeft: string;
|
|
32
32
|
actionItemPaddingRight: string;
|
|
@@ -5,17 +5,17 @@ declare const getTypographyTheme: (theme: GlobalTheme) => {
|
|
|
5
5
|
subdued: string;
|
|
6
6
|
primary: string;
|
|
7
7
|
};
|
|
8
|
+
fonts: {
|
|
9
|
+
light: string;
|
|
10
|
+
regular: string;
|
|
11
|
+
semiBold: string;
|
|
12
|
+
};
|
|
8
13
|
fontSizes: {
|
|
9
14
|
small: number;
|
|
10
15
|
medium: number;
|
|
11
16
|
large: number;
|
|
12
17
|
xlarge: number;
|
|
13
18
|
};
|
|
14
|
-
fontWeights: {
|
|
15
|
-
light: number;
|
|
16
|
-
regular: number;
|
|
17
|
-
semiBold: number;
|
|
18
|
-
};
|
|
19
19
|
lineHeights: {
|
|
20
20
|
small: string;
|
|
21
21
|
medium: string;
|
|
@@ -34,6 +34,11 @@ declare const globalTheme: {
|
|
|
34
34
|
xxxlarge: number;
|
|
35
35
|
xxxxlarge: number;
|
|
36
36
|
};
|
|
37
|
+
fonts: {
|
|
38
|
+
light: string;
|
|
39
|
+
regular: string;
|
|
40
|
+
semiBold: string;
|
|
41
|
+
};
|
|
37
42
|
fontSizes: {
|
|
38
43
|
xxxxxlarge: number;
|
|
39
44
|
xxxxlarge: number;
|
|
@@ -45,12 +50,6 @@ declare const globalTheme: {
|
|
|
45
50
|
small: number;
|
|
46
51
|
xsmall: number;
|
|
47
52
|
};
|
|
48
|
-
fontWeights: {
|
|
49
|
-
light: number;
|
|
50
|
-
regular: number;
|
|
51
|
-
semiBold: number;
|
|
52
|
-
bold: number;
|
|
53
|
-
};
|
|
54
53
|
lineHeights: {
|
|
55
54
|
xxxxxlarge: number;
|
|
56
55
|
xxxxlarge: number;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare const fonts: {
|
|
2
|
+
light: string;
|
|
3
|
+
regular: string;
|
|
4
|
+
semiBold: string;
|
|
5
|
+
};
|
|
1
6
|
declare const fontSizes: {
|
|
2
7
|
xxxxxlarge: number;
|
|
3
8
|
xxxxlarge: number;
|
|
@@ -9,12 +14,6 @@ declare const fontSizes: {
|
|
|
9
14
|
small: number;
|
|
10
15
|
xsmall: number;
|
|
11
16
|
};
|
|
12
|
-
declare const fontWeights: {
|
|
13
|
-
light: number;
|
|
14
|
-
regular: number;
|
|
15
|
-
semiBold: number;
|
|
16
|
-
bold: number;
|
|
17
|
-
};
|
|
18
17
|
declare const lineHeights: {
|
|
19
18
|
xxxxxlarge: number;
|
|
20
19
|
xxxxlarge: number;
|
|
@@ -26,4 +25,4 @@ declare const lineHeights: {
|
|
|
26
25
|
small: number;
|
|
27
26
|
xsmall: number;
|
|
28
27
|
};
|
|
29
|
-
export {
|
|
28
|
+
export { fonts, fontSizes, lineHeights };
|