playbook_ui 13.12.0.pre.alpha.play900startratingasinput1612 → 13.12.0.pre.alpha.play1051highchartstest1556
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +36 -32
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +68 -63
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +257 -3
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +59 -47
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +40 -34
- data/app/pb_kits/playbook/pb_multiple_users/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +53 -84
- data/app/pb_kits/playbook/pb_star_rating/_star_rating.tsx +55 -184
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.html.erb +1 -11
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.jsx +2 -17
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.html.erb +1 -6
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.jsx +5 -22
- data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +5 -10
- data/app/pb_kits/playbook/pb_star_rating/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +20 -58
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +6 -42
- data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +34 -34
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +0 -7
- data/app/pb_kits/playbook/pb_toggle/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +107 -102
- data/app/pb_kits/playbook/playbook-doc.js +4 -4
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +4 -4
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +1 -1
- metadata +2 -25
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_default_swift.md +0 -11
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_props_swift.md +0 -7
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_reverse_swift.md +0 -13
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_size_swift.md +0 -11
- data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_default_swift.md +0 -15
- data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_props_swift.md +0 -5
- data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_small_swift.md +0 -15
- data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_xsmall_swift.md +0 -15
- data/app/pb_kits/playbook/pb_star_rating/custom-icons.js +0 -356
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.html.erb +0 -7
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.jsx +0 -40
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.html.erb +0 -12
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.jsx +0 -57
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.html.erb +0 -23
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.jsx +0 -59
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_add_on_swift.md +0 -35
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default_swift.md +0 -29
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_disabled_swift.md +0 -13
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error_swift.md +0 -24
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_props_swift.md +0 -13
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_default_swift.md +0 -11
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_name_swift.md +0 -10
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_props_swift.md +0 -6
@@ -2,38 +2,27 @@ import React from "react"
|
|
2
2
|
import classnames from "classnames"
|
3
3
|
|
4
4
|
import { buildAriaProps, buildDataProps } from "../utilities/props"
|
5
|
-
|
6
|
-
import
|
7
|
-
import Title from '../pb_title/_title'
|
8
|
-
import Icon from '../pb_icon/_icon'
|
9
|
-
import Flex from '../pb_flex/_flex'
|
5
|
+
|
6
|
+
import Icon from "../pb_icon/_icon"
|
10
7
|
|
11
8
|
type StarRatingProps = {
|
12
9
|
aria?: {[key: string]: string},
|
13
10
|
className?: string,
|
14
11
|
data?: object,
|
15
|
-
dark?: boolean,
|
16
12
|
fixedWidth?: boolean,
|
17
|
-
|
13
|
+
hideRating: boolean,
|
18
14
|
icon?: string,
|
19
15
|
id?: string,
|
20
16
|
rating: number,
|
21
|
-
denominator: number,
|
22
|
-
colorOption?: "yellow" | "primary" | "subtle" | "outline",
|
23
|
-
size?: "xs" | "sm" | "md" | "lg";
|
24
17
|
};
|
25
18
|
|
26
19
|
const StarRating = ({
|
27
20
|
aria = {},
|
28
21
|
className,
|
29
22
|
data = {},
|
30
|
-
|
31
|
-
layoutOption = "default",
|
23
|
+
hideRating = false,
|
32
24
|
id,
|
33
25
|
rating = 0,
|
34
|
-
denominator = 5,
|
35
|
-
colorOption = "yellow",
|
36
|
-
size = "sm",
|
37
26
|
}: StarRatingProps) => {
|
38
27
|
const ariaProps = buildAriaProps(aria)
|
39
28
|
const dataProps = buildDataProps(data)
|
@@ -41,49 +30,12 @@ const StarRating = ({
|
|
41
30
|
"pb_star_rating_kit", className,
|
42
31
|
])
|
43
32
|
|
44
|
-
const
|
45
|
-
|
46
|
-
const emptyStars = denominatorStyle - Math.round(rating) < 0 ? 0 : denominatorStyle - Math.round(rating)
|
47
|
-
let iconSize = ""
|
48
|
-
|
49
|
-
if (size === 'xs') {
|
50
|
-
iconSize = "pb_star_xs"
|
51
|
-
} else if (size === 'sm') {
|
52
|
-
iconSize = "pb_star_sm"
|
53
|
-
} else if (size === 'md') {
|
54
|
-
iconSize = "pb_star_md"
|
55
|
-
} else if (size === 'lg') {
|
56
|
-
iconSize = "pb_star_lg"
|
57
|
-
}
|
58
|
-
|
59
|
-
const starYellow = (
|
60
|
-
<svg className="iamyellow" viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
61
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M9.86015 0.4371C9.73527 0.187329 9.4855 0 9.17328 0C8.89229 0 8.64252 0.187329 8.51763 0.4371L6.36335 4.83932L1.58647 5.55742C1.30547 5.58864 1.08692 5.80719 0.99326 6.05696C0.899595 6.33795 0.962038 6.61895 1.18059 6.8375L4.64617 10.2719L3.80319 15.1112C3.77197 15.3922 3.89685 15.7044 4.11541 15.8605C4.36518 16.0166 4.64617 16.0478 4.89594 15.9229L9.17328 13.6126L13.4506 15.9229C13.7004 16.0478 14.0126 16.0166 14.2624 15.8605C14.4809 15.7044 14.6058 15.3922 14.5434 15.1112L13.7316 10.2719L17.1972 6.8375C17.4157 6.61895 17.4782 6.33795 17.3845 6.05696C17.2909 5.80719 17.0723 5.58864 16.7913 5.55742L12.0144 4.83932L9.86015 0.4371Z" fill="#F9BB00"/>
|
62
|
-
</svg>
|
63
|
-
)
|
64
|
-
|
65
|
-
const starPrimary = (
|
66
|
-
<svg viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
67
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M9.86015 0.4371C9.73527 0.187329 9.4855 0 9.17328 0C8.89229 0 8.64252 0.187329 8.51763 0.4371L6.36335 4.83932L1.58647 5.55742C1.30547 5.58864 1.08692 5.80719 0.99326 6.05696C0.899595 6.33795 0.962038 6.61895 1.18059 6.8375L4.64617 10.2719L3.80319 15.1112C3.77197 15.3922 3.89685 15.7044 4.11541 15.8605C4.36518 16.0166 4.64617 16.0478 4.89594 15.9229L9.17328 13.6126L13.4506 15.9229C13.7004 16.0478 14.0126 16.0166 14.2624 15.8605C14.4809 15.7044 14.6058 15.3922 14.5434 15.1112L13.7316 10.2719L17.1972 6.8375C17.4157 6.61895 17.4782 6.33795 17.3845 6.05696C17.2909 5.80719 17.0723 5.58864 16.7913 5.55742L12.0144 4.83932L9.86015 0.4371Z" fill="#0056CF"/>
|
68
|
-
</svg>
|
69
|
-
);
|
70
|
-
|
71
|
-
const starSubtle = (
|
72
|
-
<svg viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
73
|
-
<path className={dark === true ? "suble_star_dark" : "suble_star_light"} fillRule="evenodd" clipRule="evenodd" d="M8.90904 0.4371C8.78416 0.187329 8.53438 0 8.22217 0C7.94118 0 7.69141 0.187329 7.56652 0.4371L5.41224 4.83932L0.635357 5.55742C0.354364 5.58864 0.135813 5.80719 0.042149 6.05696C-0.0515154 6.33795 0.0109275 6.61895 0.229478 6.8375L3.69506 10.2719L2.85208 15.1112C2.82086 15.3922 2.94574 15.7044 3.16429 15.8605C3.41407 16.0166 3.69506 16.0478 3.94483 15.9229L8.22217 13.6126L12.4995 15.9229C12.7493 16.0478 13.0615 16.0166 13.3113 15.8605C13.5298 15.7044 13.6547 15.3922 13.5923 15.1112L12.7805 10.2719L16.2461 6.8375C16.4646 6.61895 16.5271 6.33795 16.4334 6.05696C16.3397 5.80719 16.1212 5.58864 15.8402 5.55742L11.0633 4.83932L8.90904 0.4371Z" />
|
74
|
-
</svg>
|
75
|
-
);
|
76
|
-
|
77
|
-
const starBackground = (
|
78
|
-
<svg viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
79
|
-
<path className={dark === true ? "empty_star_dark" : "empty_star_light"} fillRule="evenodd" clipRule="evenodd" d="M9.31126 0.4371C9.18638 0.187329 8.93661 0 8.62439 0C8.3434 0 8.09363 0.187329 7.96874 0.4371L5.81446 4.83932L1.03758 5.55742C0.756585 5.58864 0.538035 5.80719 0.444371 6.05696C0.350706 6.33795 0.413149 6.61895 0.631699 6.8375L4.09728 10.2719L3.2543 15.1112C3.22308 15.3922 3.34797 15.7044 3.56652 15.8605C3.81629 16.0166 4.09728 16.0478 4.34705 15.9229L8.62439 13.6126L12.9017 15.9229C13.1515 16.0478 13.4637 16.0166 13.7135 15.8605C13.932 15.7044 14.0569 15.3922 13.9945 15.1112L13.1827 10.2719L16.6483 6.8375C16.8669 6.61895 16.9293 6.33795 16.8356 6.05696C16.742 5.80719 16.5234 5.58864 16.2424 5.55742L11.4655 4.83932L9.31126 0.4371Z" />
|
80
|
-
</svg>
|
33
|
+
const starCount = () => (
|
34
|
+
[...Array(Math.floor(rating))]
|
81
35
|
)
|
82
36
|
|
83
|
-
const
|
84
|
-
|
85
|
-
<path className={dark === true ? "outline_star_dark" : "outline_star_light"} d="M5.91323 5.33377L6.17269 5.29477L6.28801 5.0591L8.44116 0.659187C8.49971 0.543364 8.59517 0.5 8.64884 0.5C8.74499 0.5 8.83506 0.555009 8.88775 0.659235L11.0409 5.0591L11.1562 5.29477L11.4157 5.33377L16.1925 6.05186L16.2021 6.0533L16.2117 6.05436C16.2359 6.05706 16.2671 6.06847 16.3024 6.09973C16.3374 6.13062 16.3686 6.17476 16.3886 6.22412C16.4186 6.32162 16.401 6.40181 16.3198 6.48332C16.3196 6.48353 16.3194 6.48374 16.3192 6.48394L12.8552 9.91671L12.6712 10.0991L12.7141 10.3546L13.5258 15.1939L13.528 15.2068L13.5308 15.2196C13.5488 15.3004 13.5074 15.402 13.4567 15.4462C13.3391 15.5132 13.2227 15.5096 13.1546 15.4781L8.88646 13.1726L8.64884 13.0443L8.41121 13.1726L4.14274 15.4782C4.07877 15.5083 3.99031 15.5147 3.87267 15.4466C3.82302 15.4033 3.76655 15.2914 3.77463 15.1781L4.61431 10.3577L4.65911 10.1005L4.47368 9.91671L1.0097 6.48394C1.00947 6.48372 1.00925 6.4835 1.00903 6.48327C0.927878 6.40178 0.910311 6.3216 0.94026 6.22412C0.960274 6.17476 0.99154 6.13062 1.02646 6.09973C1.0618 6.06847 1.09296 6.05706 1.11724 6.05436L1.12682 6.0533L1.13635 6.05186L5.91323 5.33377Z"/>
|
86
|
-
</svg>
|
37
|
+
const hasHalfStar = () => (
|
38
|
+
rating % 1 !== 0
|
87
39
|
)
|
88
40
|
|
89
41
|
return (
|
@@ -93,134 +45,53 @@ const StarRating = ({
|
|
93
45
|
className={css}
|
94
46
|
id={id}
|
95
47
|
>
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<Caption
|
100
|
-
text={rating.toString()}
|
101
|
-
size="xs"
|
102
|
-
paddingRight="xs"
|
103
|
-
dark={dark}
|
104
|
-
className="pb_star_rating_number_sm"
|
105
|
-
/>
|
106
|
-
)}
|
107
|
-
{size === 'sm' && (
|
108
|
-
<Caption
|
109
|
-
text={rating.toString()}
|
110
|
-
size="xs"
|
111
|
-
paddingRight="xs"
|
112
|
-
dark={dark}
|
113
|
-
className="pb_star_rating_number_sm"
|
114
|
-
/>
|
115
|
-
)}
|
116
|
-
{size === 'md' && (
|
117
|
-
<Body
|
118
|
-
text={rating.toString()}
|
119
|
-
paddingRight="xs"
|
120
|
-
dark={dark}
|
121
|
-
className="pb_star_rating_number_md"
|
122
|
-
/>
|
123
|
-
)}
|
124
|
-
{size === 'lg' && (
|
125
|
-
<Title
|
126
|
-
text={rating.toString()}
|
127
|
-
size={2}
|
128
|
-
paddingRight="sm"
|
129
|
-
dark={dark}
|
130
|
-
className="pb_star_rating_number_lg"
|
131
|
-
/>
|
132
|
-
)}
|
133
|
-
</>
|
134
|
-
)}
|
135
|
-
<Flex className="star_flex_area">
|
136
|
-
{[...Array(activeStars)].map((_, index) => (
|
137
|
-
<React.Fragment key={index}>
|
138
|
-
{colorOption === 'yellow' && (
|
139
|
-
<Icon
|
140
|
-
// @ts-ignore
|
141
|
-
customIcon={starYellow}
|
142
|
-
className={iconSize}
|
143
|
-
/>
|
144
|
-
) }
|
145
|
-
{colorOption === 'primary' && (
|
146
|
-
<Icon
|
147
|
-
// @ts-ignore
|
148
|
-
customIcon={starPrimary}
|
149
|
-
className={iconSize}
|
150
|
-
/>
|
151
|
-
) }
|
152
|
-
{colorOption === 'outline' && (
|
153
|
-
<Icon
|
154
|
-
// @ts-ignore
|
155
|
-
customIcon={starPrimary}
|
156
|
-
className={iconSize}
|
157
|
-
/>
|
158
|
-
) }
|
159
|
-
{colorOption === 'subtle' && (
|
160
|
-
<Icon
|
161
|
-
// @ts-ignore
|
162
|
-
customIcon={starSubtle}
|
163
|
-
className={iconSize}
|
164
|
-
/>
|
165
|
-
) }
|
166
|
-
</React.Fragment>
|
167
|
-
))}
|
168
|
-
{[...Array(emptyStars)].map((_, index) => (
|
169
|
-
<React.Fragment key={index}>
|
170
|
-
{colorOption === 'outline' && (
|
171
|
-
<Icon
|
172
|
-
// @ts-ignore
|
173
|
-
customIcon={starOutline}
|
174
|
-
className={iconSize}
|
175
|
-
/>
|
176
|
-
) }
|
177
|
-
{colorOption !== 'outline' && (
|
178
|
-
<Icon
|
179
|
-
// @ts-ignore
|
180
|
-
customIcon={starBackground}
|
181
|
-
className={iconSize}
|
182
|
-
/>
|
183
|
-
) }
|
184
|
-
</React.Fragment>
|
185
|
-
))}
|
186
|
-
</Flex>
|
187
|
-
{layoutOption === "onestar" && (
|
188
|
-
<>
|
189
|
-
{size === 'xs' && (
|
190
|
-
<Caption
|
191
|
-
text={`${rating.toString()} of ${denominator}`}
|
192
|
-
size="xs"
|
193
|
-
dark={dark}
|
194
|
-
className="pb_star_rating_number_sm"
|
195
|
-
/>
|
196
|
-
)}
|
197
|
-
{size === 'sm' && (
|
198
|
-
<Caption
|
199
|
-
text={`${rating.toString()} of ${denominator}`}
|
200
|
-
size="xs"
|
201
|
-
dark={dark}
|
202
|
-
className="pb_star_rating_number_sm"
|
203
|
-
/>
|
204
|
-
)}
|
205
|
-
{size === 'md' && (
|
206
|
-
<Body
|
207
|
-
text={`${rating.toString()} of ${denominator}`}
|
208
|
-
dark={dark}
|
209
|
-
className="pb_star_rating_number_md"
|
210
|
-
/>
|
211
|
-
)}
|
212
|
-
{size === 'lg' && (
|
213
|
-
<Title
|
214
|
-
text={`${rating.toString()} of ${denominator}`}
|
215
|
-
size={2}
|
216
|
-
dark={dark}
|
217
|
-
className="pb_star_rating_number_lg"
|
218
|
-
/>
|
219
|
-
)}
|
220
|
-
</>
|
221
|
-
)}
|
48
|
+
{!hideRating && (
|
49
|
+
<div className="pb_star_rating_number">
|
50
|
+
{rating}
|
222
51
|
</div>
|
223
|
-
)
|
224
|
-
|
52
|
+
)}
|
53
|
+
<div className="pb_star_rating_wrapper">
|
54
|
+
<div className="pb_star_rating_highlight">
|
55
|
+
{starCount().map((_, index) => (
|
56
|
+
<Icon
|
57
|
+
fixedWidth={false}
|
58
|
+
icon="star"
|
59
|
+
key={index}
|
60
|
+
/>
|
61
|
+
))}
|
62
|
+
{hasHalfStar() && (
|
63
|
+
<Icon
|
64
|
+
fixedWidth={false}
|
65
|
+
icon="star-half"
|
66
|
+
/>
|
67
|
+
)}
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div className="pb_star_rating_base">
|
71
|
+
<Icon
|
72
|
+
fixedWidth={false}
|
73
|
+
icon="star"
|
74
|
+
/>
|
75
|
+
<Icon
|
76
|
+
fixedWidth={false}
|
77
|
+
icon="star"
|
78
|
+
/>
|
79
|
+
<Icon
|
80
|
+
fixedWidth={false}
|
81
|
+
icon="star"
|
82
|
+
/>
|
83
|
+
<Icon
|
84
|
+
fixedWidth={false}
|
85
|
+
icon="star"
|
86
|
+
/>
|
87
|
+
<Icon
|
88
|
+
fixedWidth={false}
|
89
|
+
icon="star"
|
90
|
+
/>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
)
|
95
|
+
}
|
225
96
|
|
226
97
|
export default StarRating
|
@@ -2,22 +2,12 @@
|
|
2
2
|
|
3
3
|
<br>
|
4
4
|
|
5
|
-
<%= pb_rails("star_rating", props: { rating: 1 }) %>
|
6
|
-
|
7
|
-
<br>
|
8
|
-
|
9
|
-
<%= pb_rails("star_rating", props: { rating: 2}) %>
|
10
|
-
|
11
|
-
<br>
|
12
|
-
|
13
5
|
<%= pb_rails("star_rating", props: { rating: 3 }) %>
|
14
6
|
|
15
7
|
<br>
|
16
8
|
|
17
|
-
<%= pb_rails("star_rating", props: { rating:
|
9
|
+
<%= pb_rails("star_rating", props: { rating: 1.5 }) %>
|
18
10
|
|
19
11
|
<br>
|
20
12
|
|
21
13
|
<%= pb_rails("star_rating", props: { rating: 5 }) %>
|
22
|
-
|
23
|
-
<br>
|
@@ -4,21 +4,7 @@ import StarRating from '../_star_rating'
|
|
4
4
|
|
5
5
|
const StarRatingDefault = (props) => (
|
6
6
|
<>
|
7
|
-
<StarRating
|
8
|
-
|
9
|
-
<br />
|
10
|
-
|
11
|
-
<StarRating
|
12
|
-
rating={0.9}
|
13
|
-
{...props}
|
14
|
-
/>
|
15
|
-
|
16
|
-
<br />
|
17
|
-
|
18
|
-
<StarRating
|
19
|
-
rating={1.5}
|
20
|
-
{...props}
|
21
|
-
/>
|
7
|
+
<StarRating />
|
22
8
|
|
23
9
|
<br />
|
24
10
|
|
@@ -30,11 +16,10 @@ const StarRatingDefault = (props) => (
|
|
30
16
|
<br />
|
31
17
|
|
32
18
|
<StarRating
|
33
|
-
rating={
|
19
|
+
rating={1.5}
|
34
20
|
{...props}
|
35
21
|
/>
|
36
22
|
|
37
|
-
|
38
23
|
<br />
|
39
24
|
|
40
25
|
<StarRating
|
@@ -1,6 +1 @@
|
|
1
|
-
<%= pb_rails("star_rating", props: { rating: 3 }) %>
|
2
|
-
</br>
|
3
|
-
<%= pb_rails("star_rating", props: { rating: 3, layout_option: "number" }) %>
|
4
|
-
</br>
|
5
|
-
<%= pb_rails("star_rating", props: { rating: 3, layout_option: "onestar" }) %>
|
6
|
-
</br>
|
1
|
+
<%= pb_rails("star_rating", props: { rating: 3.5, hide_rating: true }) %>
|
@@ -3,30 +3,13 @@ import React from 'react'
|
|
3
3
|
import StarRating from '../_star_rating'
|
4
4
|
|
5
5
|
const StarRatingHide = (props) => (
|
6
|
-
<>
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
<StarRating
|
8
|
+
hideRating
|
9
|
+
rating={3.5}
|
10
|
+
{...props}
|
11
|
+
/>
|
12
12
|
|
13
|
-
<br />
|
14
|
-
|
15
|
-
<StarRating
|
16
|
-
layoutOption={"number"}
|
17
|
-
rating={3}
|
18
|
-
{...props}
|
19
|
-
/>
|
20
|
-
|
21
|
-
<br />
|
22
|
-
|
23
|
-
<StarRating
|
24
|
-
layoutOption={"onestar"}
|
25
|
-
rating={3}
|
26
|
-
{...props}
|
27
|
-
/>
|
28
|
-
|
29
|
-
</>
|
30
13
|
)
|
31
14
|
|
32
15
|
export default StarRatingHide
|
@@ -1,14 +1,9 @@
|
|
1
1
|
examples:
|
2
|
+
|
2
3
|
rails:
|
3
|
-
|
4
|
-
|
5
|
-
- star_rating_hide: Layout Options
|
6
|
-
- star_rating_number_config: Number Config
|
7
|
-
- star_rating_size_options: Size Options
|
4
|
+
- star_rating_default: Default
|
5
|
+
- star_rating_hide: Hide Rating Value
|
8
6
|
|
9
7
|
react:
|
10
|
-
|
11
|
-
|
12
|
-
- star_rating_hide: Layout Options
|
13
|
-
- star_rating_number_config: Number Config
|
14
|
-
- star_rating_size_options: Size Options
|
8
|
+
- star_rating_default: Default
|
9
|
+
- star_rating_hide: Hide Rating Value
|
@@ -1,9 +1,3 @@
|
|
1
1
|
export { default as StarRatingDefault } from './_star_rating_default.jsx'
|
2
2
|
|
3
|
-
export { default as StarRatingColorOptions } from './_star_rating_color_options.jsx'
|
4
|
-
|
5
3
|
export { default as StarRatingHide } from './_star_rating_hide.jsx'
|
6
|
-
|
7
|
-
export { default as StarRatingNumberConfig } from './_star_rating_number_config.jsx'
|
8
|
-
|
9
|
-
export { default as StarRatingSizeOptions } from './_star_rating_size_options.jsx'
|
@@ -3,67 +3,29 @@
|
|
3
3
|
data: object.data,
|
4
4
|
class: object.classname) do %>
|
5
5
|
<%# Rating value %>
|
6
|
-
<% if
|
7
|
-
|
8
|
-
<% when "xs", "sm" %>
|
9
|
-
<%= pb_rails("caption", props: { text: object.rating,
|
10
|
-
size: "sm",
|
11
|
-
classname: "pb_star_rating_number_#{size}",
|
12
|
-
dark: dark,
|
13
|
-
padding_right: "xxs" }) %>
|
14
|
-
<% when "md" %>
|
15
|
-
<%= pb_rails("body", props: { text: object.rating,
|
16
|
-
dark: dark,
|
17
|
-
classname: "pb_star_rating_number_#{size}",
|
18
|
-
padding_right: "xxs" }) %>
|
19
|
-
<% when "lg" %>
|
20
|
-
<%= pb_rails("title", props: { text: object.rating,
|
21
|
-
size: 2,
|
22
|
-
dark: dark,
|
23
|
-
classname: "pb_star_rating_number_#{size}",
|
24
|
-
padding_right: "sm" }) %>
|
25
|
-
<% end %>
|
6
|
+
<% if !object.hide_rating %>
|
7
|
+
<%= content_tag(:div, object.rating, class: "pb_star_rating_number") %>
|
26
8
|
<% end %>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<% when "primary", "outline" %>
|
34
|
-
<path fillRule="evenodd" clipRule="evenodd" d="M9.86015 0.4371C9.73527 0.187329 9.4855 0 9.17328 0C8.89229 0 8.64252 0.187329 8.51763 0.4371L6.36335 4.83932L1.58647 5.55742C1.30547 5.58864 1.08692 5.80719 0.99326 6.05696C0.899595 6.33795 0.962038 6.61895 1.18059 6.8375L4.64617 10.2719L3.80319 15.1112C3.77197 15.3922 3.89685 15.7044 4.11541 15.8605C4.36518 16.0166 4.64617 16.0478 4.89594 15.9229L9.17328 13.6126L13.4506 15.9229C13.7004 16.0478 14.0126 16.0166 14.2624 15.8605C14.4809 15.7044 14.6058 15.3922 14.5434 15.1112L13.7316 10.2719L17.1972 6.8375C17.4157 6.61895 17.4782 6.33795 17.3845 6.05696C17.2909 5.80719 17.0723 5.58864 16.7913 5.55742L12.0144 4.83932L9.86015 0.4371Z" fill="#0056CF"/>
|
35
|
-
<% when "subtle"%>
|
36
|
-
<path class="<%= subtle_star_color %>" fill-rule="evenodd" clip-rule="evenodd" d="M8.90904 0.4371C8.78416 0.187329 8.53438 0 8.22217 0C7.94118 0 7.69141 0.187329 7.56652 0.4371L5.41224 4.83932L0.635357 5.55742C0.354364 5.58864 0.135813 5.80719 0.042149 6.05696C-0.0515154 6.33795 0.0109275 6.61895 0.229478 6.8375L3.69506 10.2719L2.85208 15.1112C2.82086 15.3922 2.94574 15.7044 3.16429 15.8605C3.41407 16.0166 3.69506 16.0478 3.94483 15.9229L8.22217 13.6126L12.4995 15.9229C12.7493 16.0478 13.0615 16.0166 13.3113 15.8605C13.5298 15.7044 13.6547 15.3922 13.5923 15.1112L12.7805 10.2719L16.2461 6.8375C16.4646 6.61895 16.5271 6.33795 16.4334 6.05696C16.3397 5.80719 16.1212 5.58864 15.8402 5.55742L11.0633 4.83932L8.90904 0.4371Z" />
|
9
|
+
|
10
|
+
<%= content_tag(:div, class: "pb_star_rating_wrapper") do %>
|
11
|
+
<%# Gold stars generated by rating value %>
|
12
|
+
<%= content_tag(:div, class: "pb_star_rating_highlight") do %>
|
13
|
+
<% object.star_count.times do %>
|
14
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
37
15
|
<% end %>
|
38
|
-
|
39
|
-
|
40
|
-
<% object.empty_stars.times do %>
|
41
|
-
<svg class="<%= "pb_star_padding_#{size}" %>" width="100%" height="1em" viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
42
|
-
<% if object.color_option == "outline" %>
|
43
|
-
<path class="<%= outline_star_color %>" d="M5.91323 5.33377L6.17269 5.29477L6.28801 5.0591L8.44116 0.659187C8.49971 0.543364 8.59517 0.5 8.64884 0.5C8.74499 0.5 8.83506 0.555009 8.88775 0.659235L11.0409 5.0591L11.1562 5.29477L11.4157 5.33377L16.1925 6.05186L16.2021 6.0533L16.2117 6.05436C16.2359 6.05706 16.2671 6.06847 16.3024 6.09973C16.3374 6.13062 16.3686 6.17476 16.3886 6.22412C16.4186 6.32162 16.401 6.40181 16.3198 6.48332C16.3196 6.48353 16.3194 6.48374 16.3192 6.48394L12.8552 9.91671L12.6712 10.0991L12.7141 10.3546L13.5258 15.1939L13.528 15.2068L13.5308 15.2196C13.5488 15.3004 13.5074 15.402 13.4567 15.4462C13.3391 15.5132 13.2227 15.5096 13.1546 15.4781L8.88646 13.1726L8.64884 13.0443L8.41121 13.1726L4.14274 15.4782C4.07877 15.5083 3.99031 15.5147 3.87267 15.4466C3.82302 15.4033 3.76655 15.2914 3.77463 15.1781L4.61431 10.3577L4.65911 10.1005L4.47368 9.91671L1.0097 6.48394C1.00947 6.48372 1.00925 6.4835 1.00903 6.48327C0.927878 6.40178 0.910311 6.3216 0.94026 6.22412C0.960274 6.17476 0.99154 6.13062 1.02646 6.09973C1.0618 6.06847 1.09296 6.05706 1.11724 6.05436L1.12682 6.0533L1.13635 6.05186L5.91323 5.33377Z" />
|
44
|
-
<% else %>
|
45
|
-
<path class="<%= empty_star_color %>" fill-rule="evenodd" clip-rule="evenodd" d="M9.31126 0.4371C9.18638 0.187329 8.93661 0 8.62439 0C8.3434 0 8.09363 0.187329 7.96874 0.4371L5.81446 4.83932L1.03758 5.55742C0.756585 5.58864 0.538035 5.80719 0.444371 6.05696C0.350706 6.33795 0.413149 6.61895 0.631699 6.8375L4.09728 10.2719L3.2543 15.1112C3.22308 15.3922 3.34797 15.7044 3.56652 15.8605C3.81629 16.0166 4.09728 16.0478 4.34705 15.9229L8.62439 13.6126L12.9017 15.9229C13.1515 16.0478 13.4637 16.0166 13.7135 15.8605C13.932 15.7044 14.0569 15.3922 13.9945 15.1112L13.1827 10.2719L16.6483 6.8375C16.8669 6.61895 16.9293 6.33795 16.8356 6.05696C16.742 5.80719 16.5234 5.58864 16.2424 5.55742L11.4655 4.83932L9.31126 0.4371Z" />
|
46
|
-
<% end %>
|
47
|
-
</svg>
|
48
|
-
<% end %>
|
49
|
-
<% end %>
|
50
|
-
<% if layout_option == "onestar" %>
|
51
|
-
<%= content_tag(:div, class: "pb_star_rating_number_#{size}") do %>
|
52
|
-
<% case object.size %>
|
53
|
-
<% when "xs", "sm" %>
|
54
|
-
<%= pb_rails("caption", props: { text: "#{object.rating} of #{object.denominator}",
|
55
|
-
size: "xs",
|
56
|
-
dark: dark,
|
57
|
-
padding_left: "xxs" }) %>
|
58
|
-
<% when "md" %>
|
59
|
-
<%= pb_rails("body", props: { text: "#{object.rating} of #{object.denominator}",
|
60
|
-
dark: dark,
|
61
|
-
padding_left: "xxs" }) %>
|
62
|
-
<% when "lg" %>
|
63
|
-
<%= pb_rails("title", props: { text: "#{object.rating} of #{object.denominator}",
|
64
|
-
size: 2,
|
65
|
-
dark: dark }) %>
|
16
|
+
<% unless object.star_full %>
|
17
|
+
<%= pb_rails("icon", props: { icon: "star-half" }) %>
|
66
18
|
<% end %>
|
67
19
|
<% end %>
|
20
|
+
|
21
|
+
<%# Grey background stars as base %>
|
22
|
+
<%= content_tag(:div, class: "pb_star_rating_base") do %>
|
23
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
24
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
25
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
26
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
27
|
+
<%= pb_rails("icon", props: { icon: "star" }) %>
|
28
|
+
<% end %>
|
29
|
+
|
68
30
|
<% end %>
|
69
31
|
<% end %>
|
@@ -3,54 +3,18 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbStarRating
|
5
5
|
class StarRating < Playbook::KitBase
|
6
|
+
prop :hide_rating, type: Playbook::Props::Boolean,
|
7
|
+
default: false
|
8
|
+
|
6
9
|
prop :rating, type: Playbook::Props::Numeric,
|
7
10
|
default: 0
|
8
11
|
|
9
|
-
prop :denominator, type: Playbook::Props::Numeric,
|
10
|
-
default: 5
|
11
|
-
|
12
|
-
prop :layout_option, type: Playbook::Props::Enum,
|
13
|
-
values: %w[default onestar number],
|
14
|
-
default: "default"
|
15
|
-
|
16
|
-
prop :color_option, type: Playbook::Props::Enum,
|
17
|
-
values: %w[yellow primary subtle outline],
|
18
|
-
default: "yellow"
|
19
|
-
|
20
|
-
prop :size, type: Playbook::Props::Enum,
|
21
|
-
values: %w[xs sm md lg],
|
22
|
-
default: "sm"
|
23
|
-
|
24
12
|
def star_count
|
25
|
-
rating.floor
|
26
|
-
end
|
27
|
-
|
28
|
-
def denominator_style
|
29
|
-
layout_option == "onestar" ? 1 : denominator
|
30
|
-
end
|
31
|
-
|
32
|
-
def empty_stars
|
33
|
-
(denominator_style - rating.floor).negative? ? 0 : denominator_style - rating.floor
|
34
|
-
end
|
35
|
-
|
36
|
-
def empty_star_color
|
37
|
-
dark ? "empty_star_dark" : "empty_star_light"
|
38
|
-
end
|
39
|
-
|
40
|
-
def outline_star_color
|
41
|
-
dark ? "outline_star_dark" : "outline_star_light"
|
42
|
-
end
|
43
|
-
|
44
|
-
def subtle_star_color
|
45
|
-
dark ? "suble_star_dark" : "suble_star_light"
|
13
|
+
rating.floor
|
46
14
|
end
|
47
15
|
|
48
|
-
def
|
49
|
-
|
50
|
-
"sm": "pb_star_sm",
|
51
|
-
"md": "pb_star_md",
|
52
|
-
"lg": "pb_star_lg" }
|
53
|
-
sizes[size.to_sym]
|
16
|
+
def star_full
|
17
|
+
(rating.to_f % 1).zero?
|
54
18
|
end
|
55
19
|
|
56
20
|
def classname
|