@momo-kits/rating 0.169.8 → 0.169.10
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 +9 -5
- package/package.json +1 -1
- package/{type.ts → types.ts} +2 -2
package/index.tsx
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Colors, Icon } from '@momo-kits/foundation';
|
|
2
2
|
import React, { FC } from 'react';
|
|
3
3
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
4
|
-
import { RatingProps } from './
|
|
4
|
+
import { RatingProps } from './types';
|
|
5
|
+
|
|
6
|
+
const LARGE_STAR_SIZE = 24;
|
|
7
|
+
const MEDIUM_STAR_SIZE = 20;
|
|
8
|
+
const SMALL_STAR_SIZE = 16;
|
|
5
9
|
|
|
6
10
|
/** Parses a number prop that may be a string with a comma decimal (`'4,5'`). */
|
|
7
11
|
const toNumber = (value: number | string) => {
|
|
@@ -46,11 +50,11 @@ const Rating: FC<RatingProps> = ({
|
|
|
46
50
|
return Colors.black_07;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
let
|
|
53
|
+
let starSize = LARGE_STAR_SIZE;
|
|
50
54
|
if (size === 'small') {
|
|
51
|
-
|
|
55
|
+
starSize = SMALL_STAR_SIZE;
|
|
52
56
|
} else if (size === 'medium') {
|
|
53
|
-
|
|
57
|
+
starSize = MEDIUM_STAR_SIZE;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
return (
|
|
@@ -64,7 +68,7 @@ const Rating: FC<RatingProps> = ({
|
|
|
64
68
|
>
|
|
65
69
|
<Icon
|
|
66
70
|
source={renderStar(index)}
|
|
67
|
-
size={
|
|
71
|
+
size={starSize}
|
|
68
72
|
color={tintColor(index)}
|
|
69
73
|
/>
|
|
70
74
|
</TouchableOpacity>
|
package/package.json
CHANGED
package/{type.ts → types.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {TouchableOpacityProps} from 'react-native';
|
|
1
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export interface RatingProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
@@ -19,7 +19,7 @@ export interface RatingProps extends TouchableOpacityProps {
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* `size`: Optional. Represents the size of the Rating component.
|
|
22
|
-
* Defaults to `large`
|
|
22
|
+
* Defaults to `large` (24) if not provided.
|
|
23
23
|
*/
|
|
24
24
|
size?: 'small' | 'medium' | 'large';
|
|
25
25
|
}
|