@momo-kits/rating 0.167.1-duotest.1 → 0.167.1-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/index.tsx +15 -5
- package/package.json +15 -15
package/index.tsx
CHANGED
|
@@ -3,6 +3,13 @@ import React, {FC} from 'react';
|
|
|
3
3
|
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
4
4
|
import {RatingProps} from './type';
|
|
5
5
|
|
|
6
|
+
const toNumber = (value: number | string) => {
|
|
7
|
+
if (typeof value === 'string') {
|
|
8
|
+
return parseFloat(value.replace(',', '.'));
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
|
|
6
13
|
const Rating: FC<RatingProps> = ({
|
|
7
14
|
rating,
|
|
8
15
|
numOfStars,
|
|
@@ -11,10 +18,8 @@ const Rating: FC<RatingProps> = ({
|
|
|
11
18
|
style,
|
|
12
19
|
...props
|
|
13
20
|
}) => {
|
|
14
|
-
const normalizedRating =
|
|
15
|
-
|
|
16
|
-
const normalizedNumOfStars =
|
|
17
|
-
typeof numOfStars === 'string' ? parseFloat(numOfStars) : numOfStars;
|
|
21
|
+
const normalizedRating = toNumber(rating);
|
|
22
|
+
const normalizedNumOfStars = toNumber(numOfStars);
|
|
18
23
|
|
|
19
24
|
const renderStar = (index: number) => {
|
|
20
25
|
// Full star
|
|
@@ -42,7 +47,12 @@ const Rating: FC<RatingProps> = ({
|
|
|
42
47
|
return Colors.black_07;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
let sizes = 24;
|
|
51
|
+
if (size === 'small') {
|
|
52
|
+
sizes = 16;
|
|
53
|
+
} else if (size === 'medium') {
|
|
54
|
+
sizes = 20;
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
return (
|
|
48
58
|
<View style={[style, styles.container]}>
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
2
|
+
"name": "@momo-kits/rating",
|
|
3
|
+
"version": "0.167.1-rc.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*"
|
|
10
|
+
},
|
|
11
|
+
"license": "MoMo",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {}
|
|
16
|
+
}
|