playbook_ui 14.0.0.pre.alpha.PBNTR415starratingform3493 → 14.0.0.pre.alpha.PBNTR416formpillsizes3521
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_form/docs/_form_form_with_validate.html.erb +0 -1
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +43 -25
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +6 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +4 -4
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +4 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +0 -2
- data/app/pb_kits/playbook/pb_star_rating/index.js +41 -78
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +2 -4
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +0 -17
- data/dist/chunks/{_typeahead-D6PRvP-1.js → _typeahead-CwApRoDp.js} +1 -1
- data/dist/chunks/_weekday_stacked-BHX7adsZ.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -4
- data/dist/chunks/_weekday_stacked-Dzgi_IL5.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea3c69b9c2b5783ce5705c518e323adcf53ca682d4e0ef23e41db041e2748c2f
|
4
|
+
data.tar.gz: 60fc36ea7adee27547a5e96fd61f5ea1e9aeba509511eb4d55a83e464cc4ee2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e91bbdd240472b13de70c5166769164fe7311d94003237bf9cf82d1ddaf6a1b935f3307901e7bf4a847de519619329abddcdc82f77fec8450ee284ac52438c7
|
7
|
+
data.tar.gz: 920a6c9a3e83ae944b77a466578f9735cf2ac8b1f19cb98f846318f786f9eeaaea0e1819ab47f17475d0cac8905d8e3fed1cdf39a71d6ec0fba642c731027aa6
|
@@ -35,7 +35,6 @@
|
|
35
35
|
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
36
36
|
<%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
|
37
37
|
<%= form.date_picker :example_date_picker_2, props: { label: true, required: true } %>
|
38
|
-
<%= form.star_rating_field :example_star_rating, props: { variant: "interactive", label: true, required: true } %>
|
39
38
|
|
40
39
|
<%= form.actions do |action| %>
|
41
40
|
<%= action.submit %>
|
@@ -3,9 +3,10 @@
|
|
3
3
|
@import "../tokens/opacity";
|
4
4
|
@import "../tokens/shadows";
|
5
5
|
@import "../pb_avatar/avatar";
|
6
|
+
@import "../tokens/typography";
|
6
7
|
|
7
8
|
$selector: ".pb_form_pill";
|
8
|
-
$pb_form_pill_height:
|
9
|
+
$pb_form_pill_height: 27px;
|
9
10
|
$form_pill_colors: (
|
10
11
|
primary: map-get($status_color_text, "primary"),
|
11
12
|
neutral: map-get($status_color_text, "neutral"),
|
@@ -16,18 +17,24 @@ $form_pill_colors: (
|
|
16
17
|
display: inline-flex;
|
17
18
|
justify-content: center;
|
18
19
|
align-items: center;
|
19
|
-
padding: 0 calc($space-
|
20
|
+
padding: 0 calc($space-md/2);
|
20
21
|
height: $pb_form_pill_height;
|
21
22
|
border-radius: calc($pb_form_pill_height/2);
|
22
23
|
margin-bottom: 2px;
|
23
24
|
margin-top: 2px;
|
24
25
|
cursor: pointer;
|
26
|
+
.pb_form_pill_text, .pb_form_pill_close, .pb_form_pill_tag{
|
27
|
+
font-size: $font_small !important;
|
28
|
+
}
|
25
29
|
@each $color_name, $color_value in $form_pill_colors {
|
26
30
|
&[class*=_#{$color_name}] {
|
27
31
|
background-color: mix($color_value, $card_light, 10%);
|
28
32
|
@if ($color_name == "neutral") {
|
29
33
|
background-color: $white;
|
30
34
|
border: 1px solid $border_light;
|
35
|
+
.pb_form_pill_icon {
|
36
|
+
color: $text_lt_default;
|
37
|
+
}
|
31
38
|
}
|
32
39
|
transition: background-color 0.2s ease;
|
33
40
|
box-shadow: none;
|
@@ -51,20 +58,18 @@ $form_pill_colors: (
|
|
51
58
|
@if ($color_name == "neutral") {
|
52
59
|
color: $text_lt_default;
|
53
60
|
}
|
54
|
-
padding
|
55
|
-
padding-right: calc($space-sm/2);
|
61
|
+
padding: 0 $space-xs;
|
56
62
|
}
|
57
63
|
#{$selector}_close {
|
58
64
|
color: $color_value;
|
59
|
-
padding-left: calc($space-sm/4);
|
60
|
-
padding-right: calc($space-sm/4);
|
61
65
|
display: flex;
|
62
66
|
align-items: center;
|
63
|
-
|
64
|
-
|
65
|
-
height: 27px;
|
66
|
-
border-radius: 70px;
|
67
|
+
height: 17px;
|
68
|
+
border-radius: calc(50%);
|
67
69
|
cursor: pointer;
|
70
|
+
@if ($color_name == "neutral") {
|
71
|
+
color: $text_lt_default;
|
72
|
+
}
|
68
73
|
&:hover {
|
69
74
|
background-color: mix($color_value, $card_light, 40%);
|
70
75
|
@if ($color_name == "neutral") {
|
@@ -74,7 +79,7 @@ $form_pill_colors: (
|
|
74
79
|
}
|
75
80
|
#{$selector}_tag {
|
76
81
|
color: $color_value;
|
77
|
-
padding
|
82
|
+
padding: 0 $space-xs;
|
78
83
|
@if ($color_name == "neutral") {
|
79
84
|
color: $text_lt_default;
|
80
85
|
}
|
@@ -92,24 +97,37 @@ $form_pill_colors: (
|
|
92
97
|
.pb_form_pill_icon {
|
93
98
|
height: 12px !important;
|
94
99
|
width: 12px !important;
|
100
|
+
padding-right: $space_xs;
|
101
|
+
+ .pb_form_pill_text, + .pb_form_pill_tag {
|
102
|
+
padding-left: 0;
|
103
|
+
}
|
95
104
|
}
|
96
105
|
&.small {
|
97
|
-
height:
|
98
|
-
|
106
|
+
height: 17px;
|
107
|
+
padding: 0 $space-xs;
|
99
108
|
.pb_form_pill_text, .pb_form_pill_close, .pb_form_pill_tag {
|
100
|
-
font-size: $
|
101
|
-
font-weight: $regular;
|
109
|
+
font-size: $font_smallest !important;
|
102
110
|
}
|
103
111
|
.pb_form_pill_text, .pb_form_pill_tag {
|
104
112
|
line-height: 1.7;
|
105
|
-
padding
|
106
|
-
|
113
|
+
padding: 0 $space_xxs;
|
114
|
+
}
|
115
|
+
.pb_form_pill_close {
|
116
|
+
height: 10px;
|
117
|
+
border-radius: calc(50%);
|
107
118
|
}
|
108
|
-
[class^=pb_avatar_kit]
|
109
|
-
|
110
|
-
height:
|
111
|
-
|
112
|
-
|
119
|
+
[class^=pb_avatar_kit] .avatar_wrapper {
|
120
|
+
flex-basis: 16px;
|
121
|
+
height: 16px;
|
122
|
+
margin-top: 2px;
|
123
|
+
width: 16px;
|
124
|
+
&::before { line-height: 16.5px; }
|
125
|
+
}
|
126
|
+
.pb_form_pill_icon {
|
127
|
+
padding-right: $space_xxs;
|
128
|
+
+ .pb_form_pill_text, + .pb_form_pill_tag {
|
129
|
+
padding-left: 0;
|
130
|
+
}
|
113
131
|
}
|
114
132
|
}
|
115
133
|
&.dark {
|
@@ -118,7 +136,7 @@ $form_pill_colors: (
|
|
118
136
|
// Primary and Neutral are exceptions to the general rule in the handoff
|
119
137
|
&[class*=_#{$color_name}] {
|
120
138
|
// background-color: mix($color_value, $card_dark, 10%);
|
121
|
-
// .pb_form_pill_tag {
|
139
|
+
// .pb_form_pill_text, .pb_form_pill_tag, .pb_form_pill_icon {
|
122
140
|
// color: $color_name;
|
123
141
|
// }
|
124
142
|
// .pb_form_pill_close {
|
@@ -136,7 +154,7 @@ $form_pill_colors: (
|
|
136
154
|
@if ($color_name == "neutral") {
|
137
155
|
background-color: transparent;
|
138
156
|
border: 1px solid $border_dark;
|
139
|
-
.pb_form_pill_text, .pb_form_pill_tag {
|
157
|
+
.pb_form_pill_text, .pb_form_pill_tag, .pb_form_pill_icon {
|
140
158
|
color: $text_dk_default;
|
141
159
|
}
|
142
160
|
.pb_form_pill_close {
|
@@ -157,7 +175,7 @@ $form_pill_colors: (
|
|
157
175
|
}
|
158
176
|
@if ($color_name == "primary") {
|
159
177
|
background-color: mix($active_dark, $card_dark, 10%);
|
160
|
-
.pb_form_pill_text, .pb_form_pill_tag {
|
178
|
+
.pb_form_pill_text, .pb_form_pill_tag, .pb_form_pill_icon {
|
161
179
|
color: $active_dark;
|
162
180
|
}
|
163
181
|
.pb_form_pill_close {
|
@@ -46,6 +46,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
46
46
|
} = props
|
47
47
|
|
48
48
|
const iconClass = icon ? "_icon" : ""
|
49
|
+
const closeIconSize = size === "small" ? "xs" : "sm"
|
49
50
|
const css = classnames(
|
50
51
|
`pb_form_pill_kit_${color}${iconClass}`,
|
51
52
|
globalProps(props),
|
@@ -69,7 +70,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
69
70
|
<Avatar
|
70
71
|
imageUrl={avatarUrl}
|
71
72
|
name={name}
|
72
|
-
size="
|
73
|
+
size="xxs"
|
73
74
|
status={null}
|
74
75
|
/>
|
75
76
|
<Title
|
@@ -84,7 +85,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
84
85
|
<Avatar
|
85
86
|
imageUrl={avatarUrl}
|
86
87
|
name={name}
|
87
|
-
size="
|
88
|
+
size="xxs"
|
88
89
|
status={null}
|
89
90
|
/>
|
90
91
|
<Title
|
@@ -94,6 +95,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
94
95
|
/>
|
95
96
|
<Icon
|
96
97
|
className="pb_form_pill_icon"
|
98
|
+
color={color}
|
97
99
|
icon={icon}
|
98
100
|
/>
|
99
101
|
</>
|
@@ -102,6 +104,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
102
104
|
<>
|
103
105
|
<Icon
|
104
106
|
className="pb_form_pill_icon"
|
107
|
+
color={color}
|
105
108
|
icon={icon}
|
106
109
|
/>
|
107
110
|
<Title
|
@@ -126,6 +129,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
126
129
|
<Icon
|
127
130
|
fixedWidth
|
128
131
|
icon="times"
|
132
|
+
size={closeIconSize}
|
129
133
|
/>
|
130
134
|
</div>
|
131
135
|
</div>
|
@@ -5,11 +5,11 @@ examples:
|
|
5
5
|
- form_pill_size: Form Pill Size
|
6
6
|
- form_pill_tag: Form Pill Tag
|
7
7
|
- form_pill_example: Example
|
8
|
-
|
8
|
+
- form_pill_icon: Form Pill Icon
|
9
9
|
|
10
10
|
react:
|
11
11
|
- form_pill_user: Form Pill User
|
12
12
|
- form_pill_size: Form Pill Size
|
13
13
|
- form_pill_tag: Form Pill Tag
|
14
14
|
- form_pill_example: Example
|
15
|
-
|
15
|
+
- form_pill_icon: Form Pill Icon
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
|
2
2
|
<% if object.name.present? %>
|
3
|
-
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "
|
3
|
+
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xxs" }) %>
|
4
4
|
<%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
|
5
5
|
<% if object.icon.present? %>
|
6
|
-
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", icon: object.icon }) %>
|
6
|
+
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
|
7
7
|
<% end %>
|
8
8
|
<% elsif object.text.present? %>
|
9
9
|
<% if object.icon.present? %>
|
10
|
-
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", icon: object.icon }) %>
|
10
|
+
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
|
11
11
|
<% end %>
|
12
12
|
<% if object.text.present? %>
|
13
13
|
<%= pb_rails("title", props: { text: object.text, size: 4, classname: "pb_form_pill_tag" }) %>
|
14
14
|
<% end %>
|
15
15
|
<% end %>
|
16
16
|
<%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %>
|
17
|
-
<%= pb_rails("icon", props: { icon: 'times'
|
17
|
+
<%= pb_rails("icon", props: { icon: 'times', fixed_width: true, size: object.close_icon_size }) %>
|
18
18
|
<% end %>
|
19
19
|
<% end %>
|
@@ -469,7 +469,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
469
469
|
<FormPill
|
470
470
|
key={index}
|
471
471
|
onClick={(event: any) => handlePillClose(event, item)}
|
472
|
-
size="small"
|
473
472
|
text={item.label}
|
474
473
|
/>
|
475
474
|
))
|
@@ -482,7 +481,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
482
481
|
<FormPill
|
483
482
|
key={index}
|
484
483
|
onClick={(event: any) => handlePillClose(event, item)}
|
485
|
-
size="small"
|
486
484
|
text={item.label}
|
487
485
|
/>
|
488
486
|
))
|
@@ -1,156 +1,119 @@
|
|
1
|
-
import PbEnhancedElement from "../pb_enhanced_element"
|
1
|
+
import PbEnhancedElement from "../pb_enhanced_element";
|
2
2
|
|
3
|
-
const
|
4
|
-
const
|
5
|
-
const STAR_RATING_INPUT_DATA_SELECTOR = "[data-pb-star-rating-input]"
|
3
|
+
const STAR_RATING_SELECTOR = "[data-pb-star-rating]";
|
4
|
+
const STAR_RATING_INPUT_ID = "star-rating-input";
|
6
5
|
|
7
6
|
export default class PbStarRating extends PbEnhancedElement {
|
8
7
|
static get selector() {
|
9
|
-
return
|
8
|
+
return STAR_RATING_SELECTOR;
|
10
9
|
}
|
11
10
|
|
12
11
|
connect() {
|
13
|
-
this.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
this.element.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
|
19
|
-
star.addEventListener("click", (event) => {
|
20
|
-
const clickedStarId = event.currentTarget.id
|
21
|
-
this.updateStarColors(clickedStarId)
|
22
|
-
this.updateHiddenInputValue(clickedStarId)
|
23
|
-
this.clearFormValidation()
|
24
|
-
})
|
12
|
+
this.element.addEventListener("click", (event) => {
|
13
|
+
const clickedStarId = event.currentTarget.id;
|
14
|
+
this.updateStarColors(clickedStarId);
|
15
|
+
this.updateHiddenInputValue(clickedStarId);
|
16
|
+
});
|
25
17
|
|
18
|
+
document.querySelectorAll(STAR_RATING_SELECTOR).forEach(star => {
|
26
19
|
star.addEventListener("mouseenter", (event) => {
|
27
20
|
const hoveredStarId = event.currentTarget.id
|
28
|
-
this.updateStarHoverColors(hoveredStarId)
|
21
|
+
this.updateStarHoverColors(hoveredStarId);
|
29
22
|
})
|
30
23
|
|
31
24
|
star.addEventListener("mouseleave", () => {
|
32
|
-
this.removeStarHoverColors()
|
25
|
+
this.removeStarHoverColors();
|
33
26
|
})
|
34
27
|
|
35
28
|
star.addEventListener("keydown", (event) => {
|
36
29
|
if (event.key === 'Enter' || event.key === ' ') {
|
37
|
-
event.preventDefault()
|
38
|
-
this.handleStarClick(star.id)
|
30
|
+
event.preventDefault();
|
31
|
+
this.handleStarClick(star.id);
|
39
32
|
}
|
40
33
|
})
|
41
34
|
})
|
42
35
|
}
|
43
36
|
|
44
37
|
handleStarClick(starId) {
|
45
|
-
this.updateStarColors(starId)
|
46
|
-
this.updateHiddenInputValue(starId)
|
38
|
+
this.updateStarColors(starId);
|
39
|
+
this.updateHiddenInputValue(starId);
|
47
40
|
}
|
48
41
|
|
49
42
|
updateStarColors(clickedStarId) {
|
50
|
-
const allStars =
|
43
|
+
const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
|
51
44
|
|
52
45
|
allStars.forEach(star => {
|
53
|
-
const starId = star.id
|
54
|
-
const icon = star.querySelector(".interactive-star-icon")
|
46
|
+
const starId = star.id;
|
47
|
+
const icon = star.querySelector(".interactive-star-icon");
|
55
48
|
|
56
49
|
if (icon) {
|
57
50
|
if (starId <= clickedStarId) {
|
58
51
|
if (star.classList.contains("yellow_star")) {
|
59
|
-
icon.classList.add("yellow-star-selected")
|
52
|
+
icon.classList.add("yellow-star-selected");
|
60
53
|
} else if (star.classList.contains("primary_star_light")) {
|
61
|
-
icon.classList.add("primary-star-selected")
|
54
|
+
icon.classList.add("primary-star-selected");
|
62
55
|
} else if (star.classList.contains("primary_star_dark")) {
|
63
|
-
icon.classList.add("primary-star-selected")
|
56
|
+
icon.classList.add("primary-star-selected");
|
64
57
|
} else if (star.classList.contains("subtle_star_light")) {
|
65
|
-
icon.classList.add("subtle-star-selected")
|
58
|
+
icon.classList.add("subtle-star-selected");
|
66
59
|
} else if (star.classList.contains("subtle_star_dark")) {
|
67
|
-
icon.classList.add("subtle-star-selected")
|
60
|
+
icon.classList.add("subtle-star-selected");
|
68
61
|
} else {
|
69
|
-
icon.classList.add("yellow-star-selected")
|
62
|
+
icon.classList.add("yellow-star-selected");
|
70
63
|
}
|
71
64
|
} else {
|
72
|
-
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
|
65
|
+
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected");
|
73
66
|
}
|
74
|
-
icon.classList.remove("star-hovered")
|
67
|
+
icon.classList.remove("star-hovered");
|
75
68
|
}
|
76
|
-
})
|
69
|
+
});
|
77
70
|
}
|
78
71
|
|
79
72
|
updateHiddenInputValue(value) {
|
80
|
-
const hiddenInput =
|
73
|
+
const hiddenInput = document.getElementById(STAR_RATING_INPUT_ID);
|
81
74
|
if (hiddenInput) {
|
82
|
-
hiddenInput.value = value
|
75
|
+
hiddenInput.value = value;
|
83
76
|
}
|
84
77
|
}
|
85
78
|
|
86
79
|
updateStarHoverColors(hoveredStarId) {
|
87
|
-
const allStars =
|
80
|
+
const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
|
88
81
|
|
89
82
|
allStars.forEach(star => {
|
90
|
-
const starId = star.id
|
91
|
-
const icon = star.querySelector(".interactive-star-icon")
|
83
|
+
const starId = star.id;
|
84
|
+
const icon = star.querySelector(".interactive-star-icon");
|
92
85
|
|
93
86
|
if (icon) {
|
94
87
|
if (starId <= hoveredStarId) {
|
95
88
|
if (!icon.classList.contains("yellow-star-selected") &&
|
96
89
|
!icon.classList.contains("primary-star-selected") &&
|
97
90
|
!icon.classList.contains("subtle-star-selected")) {
|
98
|
-
icon.classList.add("star-hovered")
|
91
|
+
icon.classList.add("star-hovered");
|
99
92
|
}
|
100
93
|
} else {
|
101
|
-
icon.classList.remove("star-hovered")
|
94
|
+
icon.classList.remove("star-hovered");
|
102
95
|
}
|
103
96
|
}
|
104
|
-
})
|
97
|
+
});
|
105
98
|
}
|
106
99
|
|
107
100
|
|
108
101
|
removeStarHoverColors() {
|
109
|
-
const allStars =
|
102
|
+
const allStars = document.querySelectorAll(STAR_RATING_SELECTOR);
|
110
103
|
|
111
104
|
allStars.forEach(star => {
|
112
|
-
const icon = star.querySelector(".interactive-star-icon")
|
105
|
+
const icon = star.querySelector(".interactive-star-icon");
|
113
106
|
if (icon) {
|
114
107
|
if (!icon.classList.contains("yellow-star-selected") &&
|
115
108
|
!icon.classList.contains("primary-star-selected") &&
|
116
109
|
!icon.classList.contains("subtle-star-selected")) {
|
117
|
-
icon.classList.remove("star-hovered")
|
110
|
+
icon.classList.remove("star-hovered");
|
118
111
|
}
|
119
112
|
}
|
120
|
-
})
|
113
|
+
});
|
121
114
|
}
|
122
115
|
|
123
116
|
isStarSelected() {
|
124
|
-
return
|
125
|
-
}
|
126
|
-
|
127
|
-
handleFormReset() {
|
128
|
-
const form = this.element.closest("form")
|
129
|
-
if (form) {
|
130
|
-
form.addEventListener("reset", () => {
|
131
|
-
this.updateHiddenInputValue("")
|
132
|
-
this.resetStarRatingValues()
|
133
|
-
})
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
resetStarRatingValues() {
|
138
|
-
const allStars = this.element.querySelectorAll(STAR_RATING_SELECTOR)
|
139
|
-
allStars.forEach(star => {
|
140
|
-
const icon = star.querySelector(".interactive-star-icon")
|
141
|
-
if (icon) {
|
142
|
-
icon.classList.remove("yellow-star-selected", "primary-star-selected", "subtle-star-selected")
|
143
|
-
}
|
144
|
-
})
|
145
|
-
}
|
146
|
-
|
147
|
-
clearFormValidation() {
|
148
|
-
const hiddenInput = this.element.querySelector(STAR_RATING_INPUT_DATA_SELECTOR)
|
149
|
-
if (hiddenInput.checkValidity()) {
|
150
|
-
const errorLabelElement = this.element.querySelector(".pb_body_kit_negative")
|
151
|
-
if (errorLabelElement) {
|
152
|
-
errorLabelElement.remove()
|
153
|
-
}
|
154
|
-
}
|
117
|
+
return document.querySelectorAll(".yellow-star-selected, .primary-star-selected, .subtle-star-selected").length > 0;
|
155
118
|
}
|
156
119
|
}
|
@@ -39,13 +39,11 @@
|
|
39
39
|
<% end %>
|
40
40
|
|
41
41
|
<% else %>
|
42
|
-
<%= pb_rails("flex", props: {
|
42
|
+
<%= pb_rails("flex", props: { orientation: "column" }) do %>
|
43
43
|
<% if object.label.present? %>
|
44
44
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
45
45
|
<% end %>
|
46
|
-
|
47
|
-
<%= hidden_input_tag %>
|
48
|
-
|
46
|
+
<input type="hidden" id="star-rating-input" value="" name="<%= object.name %>"/>
|
49
47
|
<%= pb_rails("flex", props: { orientation: "row" }) do %>
|
50
48
|
<% object.denominator.times do |index| %>
|
51
49
|
<div data-pb-star-rating id="<%= index + 1 %>" class="<%= star_color %>">
|
@@ -30,10 +30,6 @@ module Playbook
|
|
30
30
|
default: "display"
|
31
31
|
prop :label, type: Playbook::Props::String
|
32
32
|
prop :name, type: Playbook::Props::String
|
33
|
-
prop :required, type: Playbook::Props::Boolean,
|
34
|
-
default: false
|
35
|
-
prop :input_options, type: Playbook::Props::HashProp,
|
36
|
-
default: {}
|
37
33
|
|
38
34
|
def one_decimal_rating
|
39
35
|
rating.to_f.round(1)
|
@@ -110,19 +106,6 @@ module Playbook
|
|
110
106
|
def classname
|
111
107
|
generate_classname("pb_star_rating_kit")
|
112
108
|
end
|
113
|
-
|
114
|
-
def hidden_input_tag
|
115
|
-
tag(:input, all_input_options)
|
116
|
-
end
|
117
|
-
|
118
|
-
def all_input_options
|
119
|
-
input_options.merge(
|
120
|
-
data: { "pb-star-rating-input": true },
|
121
|
-
name: name,
|
122
|
-
required: required,
|
123
|
-
style: "display: none"
|
124
|
-
)
|
125
|
-
end
|
126
109
|
end
|
127
110
|
end
|
128
111
|
end
|