vpt-sebraeds 0.0.73 → 0.0.74
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/components/CNAESelectItem/index.jsx +1 -1
- package/components/Rating/Rating.stories.jsx +39 -0
- package/components/Rating/index.jsx +43 -2
- package/dist/components/CNAESelectItem/index.js +1 -1
- package/dist/components/Rating/index.d.ts.map +1 -1
- package/dist/components/Rating/index.js +18 -2
- package/package.json +1 -1
|
@@ -46,6 +46,45 @@ export const StarRatings = () => (
|
|
|
46
46
|
</View>
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
+
// Demonstrações com estrelas amarelas
|
|
50
|
+
export const YellowStarRatings = () => (
|
|
51
|
+
<View style={styles.container}>
|
|
52
|
+
<View style={styles.row}>
|
|
53
|
+
<Rating rating={0} variant="yellowStar" />
|
|
54
|
+
</View>
|
|
55
|
+
<View style={styles.row}>
|
|
56
|
+
<Rating rating={0.5} variant="yellowStar" />
|
|
57
|
+
</View>
|
|
58
|
+
<View style={styles.row}>
|
|
59
|
+
<Rating rating={1} variant="yellowStar" />
|
|
60
|
+
</View>
|
|
61
|
+
<View style={styles.row}>
|
|
62
|
+
<Rating rating={1.5} variant="yellowStar" />
|
|
63
|
+
</View>
|
|
64
|
+
<View style={styles.row}>
|
|
65
|
+
<Rating rating={2} variant="yellowStar" />
|
|
66
|
+
</View>
|
|
67
|
+
<View style={styles.row}>
|
|
68
|
+
<Rating rating={2.5} variant="yellowStar" />
|
|
69
|
+
</View>
|
|
70
|
+
<View style={styles.row}>
|
|
71
|
+
<Rating rating={3} variant="yellowStar" />
|
|
72
|
+
</View>
|
|
73
|
+
<View style={styles.row}>
|
|
74
|
+
<Rating rating={3.5} variant="yellowStar" />
|
|
75
|
+
</View>
|
|
76
|
+
<View style={styles.row}>
|
|
77
|
+
<Rating rating={4} variant="yellowStar" />
|
|
78
|
+
</View>
|
|
79
|
+
<View style={styles.row}>
|
|
80
|
+
<Rating rating={4.5} variant="yellowStar" />
|
|
81
|
+
</View>
|
|
82
|
+
<View style={styles.row}>
|
|
83
|
+
<Rating rating={5} variant="yellowStar" />
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
|
|
49
88
|
// Demonstrações com corações
|
|
50
89
|
export const HeartRatings = () => (
|
|
51
90
|
<View style={styles.container}>
|
|
@@ -3,10 +3,14 @@ import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
|
3
3
|
import Icon from '../Icon';
|
|
4
4
|
import { fontFamily } from '../utils/fontFamily';
|
|
5
5
|
|
|
6
|
+
const YELLOW_FILL_COLOR = '#F5CD47';
|
|
7
|
+
const YELLOW_BORDER_COLOR = '#E3A80F';
|
|
8
|
+
const YELLOW_EMPTY_COLOR = '#D0D5DD';
|
|
9
|
+
|
|
6
10
|
const Rating = ({
|
|
7
11
|
rating = 0,
|
|
8
12
|
maxRating = 5,
|
|
9
|
-
variant = 'star', // 'star' ou '
|
|
13
|
+
variant = 'star', // 'star', 'heart' ou 'yellowStar'
|
|
10
14
|
size = 'medium', // 'small', 'medium', 'large'
|
|
11
15
|
showLabel = true,
|
|
12
16
|
readonly = false,
|
|
@@ -49,7 +53,8 @@ const Rating = ({
|
|
|
49
53
|
const handlePress = (index) => {
|
|
50
54
|
if (readonly) return;
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
// Toggle: se clicar no mesmo nível já selecionado, desseleciona
|
|
57
|
+
const newRating = currentRating === index + 1 ? index : index + 1;
|
|
53
58
|
setCurrentRating(newRating);
|
|
54
59
|
onRatingChange(newRating);
|
|
55
60
|
};
|
|
@@ -59,6 +64,42 @@ const Rating = ({
|
|
|
59
64
|
const remainder = currentRating - index;
|
|
60
65
|
const isHalf = remainder > 0 && remainder < 1;
|
|
61
66
|
|
|
67
|
+
// Variação estrela amarela: sobrepõe star-line (borda escura) em star-fill (preenchimento claro)
|
|
68
|
+
if (variant === 'yellowStar') {
|
|
69
|
+
const filled = isActive || isHalf;
|
|
70
|
+
return (
|
|
71
|
+
<TouchableOpacity
|
|
72
|
+
key={index}
|
|
73
|
+
onPress={() => handlePress(index)}
|
|
74
|
+
disabled={readonly}
|
|
75
|
+
style={styles.iconContainer}
|
|
76
|
+
>
|
|
77
|
+
{filled ? (
|
|
78
|
+
<View style={{ width: iconSizes[size], height: iconSizes[size] }}>
|
|
79
|
+
<Icon
|
|
80
|
+
name="star-fill"
|
|
81
|
+
color={YELLOW_FILL_COLOR}
|
|
82
|
+
size={iconSizes[size]}
|
|
83
|
+
/>
|
|
84
|
+
<View style={StyleSheet.absoluteFill}>
|
|
85
|
+
<Icon
|
|
86
|
+
name="star-line"
|
|
87
|
+
color={YELLOW_BORDER_COLOR}
|
|
88
|
+
size={iconSizes[size]}
|
|
89
|
+
/>
|
|
90
|
+
</View>
|
|
91
|
+
</View>
|
|
92
|
+
) : (
|
|
93
|
+
<Icon
|
|
94
|
+
name="star-line"
|
|
95
|
+
color={YELLOW_EMPTY_COLOR}
|
|
96
|
+
size={iconSizes[size]}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</TouchableOpacity>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
62
103
|
let iconName;
|
|
63
104
|
let iconColor;
|
|
64
105
|
|
|
@@ -36,7 +36,7 @@ function CNAESelectItem({ code, title, segmento, naoInclusas, checked = false, e
|
|
|
36
36
|
isPressingRight && styles.pressedBg,
|
|
37
37
|
pressed && { opacity: 0.98 },
|
|
38
38
|
]} accessibilityRole={hasDetails ? 'button' : undefined}>
|
|
39
|
-
<SEText type="ns-xs-body" style={styles.resultTitle}
|
|
39
|
+
<SEText type="ns-xs-body" style={styles.resultTitle}>
|
|
40
40
|
{title}
|
|
41
41
|
</SEText>
|
|
42
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Rating/index.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Rating/index.jsx"],"names":[],"mappings":";AASA;;;;;;;;sBAmJC;kBA5J+B,OAAO"}
|
|
@@ -2,7 +2,10 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
3
3
|
import Icon from '../Icon';
|
|
4
4
|
import { fontFamily } from '../utils/fontFamily';
|
|
5
|
-
const
|
|
5
|
+
const YELLOW_FILL_COLOR = '#F5CD47';
|
|
6
|
+
const YELLOW_BORDER_COLOR = '#E3A80F';
|
|
7
|
+
const YELLOW_EMPTY_COLOR = '#D0D5DD';
|
|
8
|
+
const Rating = ({ rating = 0, maxRating = 5, variant = 'star', // 'star', 'heart' ou 'yellowStar'
|
|
6
9
|
size = 'medium', // 'small', 'medium', 'large'
|
|
7
10
|
showLabel = true, readonly = false, onRatingChange = () => { }, }) => {
|
|
8
11
|
const [currentRating, setCurrentRating] = useState(rating);
|
|
@@ -38,7 +41,8 @@ showLabel = true, readonly = false, onRatingChange = () => { }, }) => {
|
|
|
38
41
|
const handlePress = (index) => {
|
|
39
42
|
if (readonly)
|
|
40
43
|
return;
|
|
41
|
-
|
|
44
|
+
// Toggle: se clicar no mesmo nível já selecionado, desseleciona
|
|
45
|
+
const newRating = currentRating === index + 1 ? index : index + 1;
|
|
42
46
|
setCurrentRating(newRating);
|
|
43
47
|
onRatingChange(newRating);
|
|
44
48
|
};
|
|
@@ -46,6 +50,18 @@ showLabel = true, readonly = false, onRatingChange = () => { }, }) => {
|
|
|
46
50
|
const isActive = index < currentRating;
|
|
47
51
|
const remainder = currentRating - index;
|
|
48
52
|
const isHalf = remainder > 0 && remainder < 1;
|
|
53
|
+
// Variação estrela amarela: sobrepõe star-line (borda escura) em star-fill (preenchimento claro)
|
|
54
|
+
if (variant === 'yellowStar') {
|
|
55
|
+
const filled = isActive || isHalf;
|
|
56
|
+
return (<TouchableOpacity key={index} onPress={() => handlePress(index)} disabled={readonly} style={styles.iconContainer}>
|
|
57
|
+
{filled ? (<View style={{ width: iconSizes[size], height: iconSizes[size] }}>
|
|
58
|
+
<Icon name="star-fill" color={YELLOW_FILL_COLOR} size={iconSizes[size]}/>
|
|
59
|
+
<View style={StyleSheet.absoluteFill}>
|
|
60
|
+
<Icon name="star-line" color={YELLOW_BORDER_COLOR} size={iconSizes[size]}/>
|
|
61
|
+
</View>
|
|
62
|
+
</View>) : (<Icon name="star-line" color={YELLOW_EMPTY_COLOR} size={iconSizes[size]}/>)}
|
|
63
|
+
</TouchableOpacity>);
|
|
64
|
+
}
|
|
49
65
|
let iconName;
|
|
50
66
|
let iconColor;
|
|
51
67
|
// Para corações, não usar meio preenchimento devido à limitação do Remix Icon
|