playbook_ui 12.14.0 → 12.16.0.pre.alpha.PLAY693tooltipwrongbg532
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_avatar/_avatar.tsx +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +4 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.test.js +14 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_background/_background.tsx +1 -1
- data/app/pb_kits/playbook/pb_background/background.rb +1 -1
- data/app/pb_kits/playbook/pb_badge/_badge.scss +1 -0
- data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -1
- data/app/pb_kits/playbook/pb_badge/badge.rb +5 -1
- data/app/pb_kits/playbook/pb_badge/badge.test.js +16 -1
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +3 -3
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_card/_card.scss +13 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +3 -2
- data/app/pb_kits/playbook/pb_card/card_header.rb +9 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +11 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +169 -139
- data/app/pb_kits/playbook/pb_docs/kit_api.html.erb +295 -8
- data/app/pb_kits/playbook/pb_docs/kit_api.rb +42 -0
- data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +33 -0
- data/app/pb_kits/playbook/pb_docs/kit_example.rb +14 -1
- data/app/pb_kits/playbook/pb_enhanced_element/index.ts +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +5 -5
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -5
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -4
- data/app/pb_kits/playbook/pb_star_rating/{_star_rating.jsx → _star_rating.tsx} +18 -22
- data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +71 -0
- data/app/pb_kits/playbook/pb_table/{_table.jsx → _table.tsx} +9 -11
- data/app/pb_kits/playbook/pb_table/{_table_row.jsx → _table_row.tsx} +7 -8
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +41 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +62 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/{index.js → index.ts} +4 -4
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +129 -0
- data/app/pb_kits/playbook/pb_textarea/{index.js → index.tsx} +2 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.test.js +213 -0
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +11 -6
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +0 -1
- data/app/pb_kits/playbook/tokens/_colors.scss +16 -1
- data/app/pb_kits/playbook/utilities/_cursor.scss +141 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +5 -2
- data/lib/playbook/cursor.rb +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +17 -15
- data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
- data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_white.html.erb +0 -9
@@ -1,12 +1,299 @@
|
|
1
|
-
|
1
|
+
<% if !local_prop_data.present? %>
|
2
|
+
<div data-action="toggle" data-togglable="prop_example" class="pb--propsTable">
|
2
3
|
<%= pb_rails("title", props: { text: "Available Props", size: 3, margin_bottom: "sm" }) %>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
<%= pb_rails("card", props: { padding: "none" }) do %>
|
5
|
+
<%= pb_rails("card/card_body", props: { padding: "sm" }) do %>
|
6
|
+
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %>
|
7
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", active: true }) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
<%= pb_rails("section_separator") %>
|
11
|
+
<%= pb_rails("card/card_body", props: {}) do %>
|
12
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true }) do %>
|
13
|
+
<thead>
|
14
|
+
<tr>
|
15
|
+
<th>Props</th>
|
16
|
+
<th>Type</th>
|
17
|
+
<th>Values</th>
|
18
|
+
<th>Default</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<% global_prop_data.each do |key, value|%>
|
23
|
+
<tr>
|
24
|
+
<td>
|
25
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
26
|
+
</td>
|
27
|
+
<td>
|
28
|
+
<%= pb_rails("card", props: {
|
29
|
+
classname: "card",
|
30
|
+
padding: "xxs",
|
31
|
+
background: "light",
|
32
|
+
border_none: true,
|
33
|
+
border_radius: "sm"
|
34
|
+
}) do %>
|
35
|
+
<%= pb_rails("body", props: {
|
36
|
+
classname: "kearning"
|
37
|
+
}) do %>
|
38
|
+
<%= value[:type].downcase %>
|
39
|
+
<% end %>
|
40
|
+
<% end %>
|
41
|
+
</td>
|
42
|
+
<td>
|
43
|
+
<% if value[:values].present? %>
|
44
|
+
<% value[:values].each do |item| %>
|
45
|
+
<% if item != nil %>
|
46
|
+
<%= pb_rails("card", props: {
|
47
|
+
flex_direction: "row",
|
48
|
+
classname: "card",
|
49
|
+
padding: "xxs",
|
50
|
+
background: "light",
|
51
|
+
border_none: true,
|
52
|
+
border_radius: "sm",
|
53
|
+
margin: "xxs"
|
54
|
+
}) do %>
|
55
|
+
<%= pb_rails("body", props: {
|
56
|
+
classname: "kearning"
|
57
|
+
}) do %>
|
58
|
+
<%= item %>
|
59
|
+
<% end %>
|
60
|
+
<% end %>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
<% end %>
|
64
|
+
</td>
|
65
|
+
<td>
|
66
|
+
<% if value[:default].present? || value[:default].is_a?(TrueClass) || value[:default].is_a?(FalseClass) %>
|
67
|
+
<%= pb_rails("card", props: {
|
68
|
+
classname: "card",
|
69
|
+
padding: "xxs",
|
70
|
+
background: "light",
|
71
|
+
border_none: true,
|
72
|
+
border_radius: "sm"
|
73
|
+
}) do %>
|
74
|
+
<%= pb_rails("body", props: {
|
75
|
+
classname: "kearning"
|
76
|
+
}) do %>
|
77
|
+
<%= value[:default] %>
|
78
|
+
<% end %>
|
79
|
+
<% end %>
|
80
|
+
<% end %>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
<% end %>
|
84
|
+
</tbody>
|
85
|
+
<% end %>
|
86
|
+
<% end %>
|
87
|
+
<% end %>
|
88
|
+
</div>
|
89
|
+
<% else %>
|
90
|
+
<div data-action="toggle" data-togglable="prop_example" class="pb--propsTable">
|
91
|
+
<%= pb_rails("title", props: { text: "Available Props", size: 3, margin_bottom: "sm" }) %>
|
92
|
+
<%= pb_rails("card", props: { padding: "none" }) do %>
|
93
|
+
<%= pb_rails("card/card_body", props: { padding: "sm" }) do %>
|
94
|
+
<%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %>
|
95
|
+
<% if local_prop_data.present? %>
|
96
|
+
<%= pb_rails("nav/item", props: { text: "Kit Props", link: "#", active: true, id: "local-button-active", classname: "local-active" }) %>
|
97
|
+
<% end %>
|
98
|
+
<% if local_prop_data.present? %>
|
99
|
+
<%= pb_rails("nav/item", props: { text: "Kit Props", link: "#", id: "local-button", classname: "global-active" }) %>
|
100
|
+
<% end %>
|
101
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", active: true, id: "global-button-active", classname: "global-active" }) %>
|
102
|
+
<%= pb_rails("nav/item", props: { text: "Global Props", link: "#", id: "global-button", classname: "local-active" }) %>
|
103
|
+
<% end %>
|
104
|
+
<% end %>
|
105
|
+
<%= pb_rails("section_separator") %>
|
106
|
+
<%= pb_rails("card/card_body", props: {}) do %>
|
107
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true, id: "global-prop-table", classname: "global-active"}) do %>
|
108
|
+
<thead>
|
109
|
+
<tr>
|
110
|
+
<th>Props</th>
|
111
|
+
<th>Type</th>
|
112
|
+
<th>Values</th>
|
113
|
+
<th>Default</th>
|
114
|
+
</tr>
|
115
|
+
</thead>
|
116
|
+
<tbody>
|
117
|
+
<% global_prop_data.each do |key, value|%>
|
118
|
+
<tr>
|
119
|
+
<td>
|
120
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
121
|
+
</td>
|
122
|
+
<td>
|
123
|
+
<%= pb_rails("card", props: {
|
124
|
+
classname: "card",
|
125
|
+
padding: "xxs",
|
126
|
+
background: "light",
|
127
|
+
border_none: true,
|
128
|
+
border_radius: "sm"
|
129
|
+
}) do %>
|
130
|
+
<%= pb_rails("body", props: {
|
131
|
+
classname: "kearning"
|
132
|
+
}) do %>
|
133
|
+
<%= value[:type].downcase %>
|
134
|
+
<% end %>
|
135
|
+
<% end %>
|
136
|
+
</td>
|
137
|
+
<td>
|
138
|
+
<% if value[:values].present? %>
|
139
|
+
<% value[:values].each do |item| %>
|
140
|
+
<% if item != nil %>
|
141
|
+
<%= pb_rails("card", props: {
|
142
|
+
flex_direction: "row",
|
143
|
+
classname: "card",
|
144
|
+
padding: "xxs",
|
145
|
+
background: "light",
|
146
|
+
border_none: true,
|
147
|
+
border_radius: "sm",
|
148
|
+
margin: "xxs"
|
149
|
+
}) do %>
|
150
|
+
<%= pb_rails("body", props: {
|
151
|
+
classname: "kearning"
|
152
|
+
}) do %>
|
153
|
+
<%= item %>
|
154
|
+
<% end %>
|
155
|
+
<% end %>
|
156
|
+
<% end %>
|
157
|
+
<% end %>
|
158
|
+
<% end %>
|
159
|
+
</td>
|
160
|
+
<td>
|
161
|
+
<% if value[:default].present? || value[:default].is_a?(TrueClass) || value[:default].is_a?(FalseClass) %>
|
162
|
+
<%= pb_rails("card", props: {
|
163
|
+
classname: "card",
|
164
|
+
padding: "xxs",
|
165
|
+
background: "light",
|
166
|
+
border_none: true,
|
167
|
+
border_radius: "sm"
|
168
|
+
}) do %>
|
169
|
+
<%= pb_rails("body", props: {
|
170
|
+
classname: "kearning"
|
171
|
+
}) do %>
|
172
|
+
<%= value[:default] %>
|
173
|
+
<% end %>
|
174
|
+
<% end %>
|
175
|
+
<% end %>
|
176
|
+
</td>
|
177
|
+
</tr>
|
178
|
+
<% end %>
|
179
|
+
</tbody>
|
180
|
+
<% end %>
|
181
|
+
<%= pb_rails("table", props: {container: false, disable_hover: true, id: "local-prop-table", classname: "local-active"}) do %>
|
182
|
+
<thead>
|
183
|
+
<tr>
|
184
|
+
<th>Props</th>
|
185
|
+
<th>Type</th>
|
186
|
+
<th>Values</th>
|
187
|
+
<th>Default</th>
|
188
|
+
</tr>
|
189
|
+
</thead>
|
190
|
+
<tbody>
|
191
|
+
<% local_prop_data.each do |key, value|%>
|
192
|
+
<tr>
|
193
|
+
<td>
|
194
|
+
<%= pb_rails("title", props: { text: key, tag: "h4", size: 4 }) %>
|
195
|
+
</td>
|
196
|
+
<td>
|
197
|
+
<%= pb_rails("card", props: {
|
198
|
+
classname: "card",
|
199
|
+
padding: "xxs",
|
200
|
+
background: "light",
|
201
|
+
border_none: true,
|
202
|
+
border_radius: "sm"
|
203
|
+
}) do %>
|
204
|
+
<%= pb_rails("body", props: {
|
205
|
+
classname: "kearning"
|
206
|
+
}) do %>
|
207
|
+
<%= value[:type].downcase %>
|
208
|
+
<% end %>
|
209
|
+
<% end %>
|
210
|
+
</td>
|
211
|
+
<td>
|
212
|
+
<% if value[:values].present? %>
|
213
|
+
<% value[:values].each do |item| %>
|
214
|
+
<% if item != nil %>
|
215
|
+
<%= pb_rails("card", props: {
|
216
|
+
flex_direction: "row",
|
217
|
+
classname: "card",
|
218
|
+
padding: "xxs",
|
219
|
+
background: "light",
|
220
|
+
border_none: true,
|
221
|
+
border_radius: "sm",
|
222
|
+
margin: "xxs"
|
223
|
+
}) do %>
|
224
|
+
<%= pb_rails("body", props: {
|
225
|
+
classname: "kearning"
|
226
|
+
}) do %>
|
227
|
+
<%= item %>
|
228
|
+
<% end %>
|
229
|
+
<% end %>
|
230
|
+
<% end %>
|
231
|
+
<% end %>
|
232
|
+
<% end %>
|
233
|
+
</td>
|
234
|
+
<td>
|
235
|
+
<% if value[:default].present? || value[:default].is_a?(TrueClass) || value[:default].is_a?(FalseClass) %>
|
236
|
+
<%= pb_rails("card", props: {
|
237
|
+
classname: "card",
|
238
|
+
padding: "xxs",
|
239
|
+
background: "light",
|
240
|
+
border_none: true,
|
241
|
+
border_radius: "sm"
|
242
|
+
}) do %>
|
243
|
+
<%= pb_rails("body", props: {
|
244
|
+
classname: "kearning"
|
245
|
+
}) do %>
|
246
|
+
<%= value[:default] %>
|
247
|
+
<% end %>
|
248
|
+
<% end %>
|
249
|
+
<% end %>
|
250
|
+
</td>
|
251
|
+
</tr>
|
252
|
+
<% end %>
|
253
|
+
</tbody>
|
8
254
|
<% end %>
|
9
255
|
<% end %>
|
10
256
|
<% end %>
|
11
|
-
|
12
|
-
|
257
|
+
</div>
|
258
|
+
<% end %>
|
259
|
+
|
260
|
+
<script>
|
261
|
+
|
262
|
+
const globalNavAndTable = document.querySelectorAll('.global-active');
|
263
|
+
const localNavAndTable = document.querySelectorAll('.local-active');
|
264
|
+
|
265
|
+
globalNavAndTable.forEach(element => {
|
266
|
+
element.style.display = 'none';
|
267
|
+
});
|
268
|
+
|
269
|
+
const globalButton = document.getElementById("global-button");
|
270
|
+
if (globalButton) {
|
271
|
+
globalButton.addEventListener("click", showGlobal);
|
272
|
+
}
|
273
|
+
|
274
|
+
const localButton = document.getElementById("local-button");
|
275
|
+
if (localButton) {
|
276
|
+
localButton.addEventListener("click", showLocal);
|
277
|
+
}
|
278
|
+
|
279
|
+
function showGlobal() {
|
280
|
+
localNavAndTable.forEach(element => {
|
281
|
+
element.style.display = 'none';
|
282
|
+
});
|
283
|
+
|
284
|
+
globalNavAndTable.forEach(element => {
|
285
|
+
element.style.display = 'table';
|
286
|
+
});
|
287
|
+
}
|
288
|
+
|
289
|
+
function showLocal() {
|
290
|
+
localNavAndTable.forEach(element => {
|
291
|
+
element.style.display = 'table';
|
292
|
+
});
|
293
|
+
|
294
|
+
globalNavAndTable.forEach(element => {
|
295
|
+
element.style.display = 'none';
|
296
|
+
});
|
297
|
+
}
|
298
|
+
|
299
|
+
</script>
|
@@ -5,6 +5,48 @@ module Playbook
|
|
5
5
|
class KitApi < Playbook::KitBase
|
6
6
|
prop :kit, type: Playbook::Props::String, required: true
|
7
7
|
|
8
|
+
def kit_local_props
|
9
|
+
local = []
|
10
|
+
kit_props.each do |key, value|
|
11
|
+
value.kit != Playbook::KitBase && local.push({ key: key, value: value })
|
12
|
+
end
|
13
|
+
local
|
14
|
+
end
|
15
|
+
|
16
|
+
def local_prop_data
|
17
|
+
local_props = {}
|
18
|
+
|
19
|
+
kit_local_props.each do |key, _value|
|
20
|
+
name = key[:value].instance_variable_get(:@name)
|
21
|
+
type = key[:value].class.to_s.split("::").last
|
22
|
+
default = key[:value].instance_variable_get(:@default)
|
23
|
+
values = key[:value].instance_variable_get(:@values)
|
24
|
+
local_props[name.to_sym] = { "type": type, "default": default, "values": values }
|
25
|
+
end
|
26
|
+
local_props
|
27
|
+
end
|
28
|
+
|
29
|
+
def kit_global_props
|
30
|
+
global = []
|
31
|
+
kit_props.each do |key, value|
|
32
|
+
value.kit == Playbook::KitBase && global.push({ key: key, value: value })
|
33
|
+
end
|
34
|
+
global
|
35
|
+
end
|
36
|
+
|
37
|
+
def global_prop_data
|
38
|
+
global_props = {}
|
39
|
+
|
40
|
+
kit_global_props.each do |key, _value|
|
41
|
+
name = key[:value].instance_variable_get(:@name)
|
42
|
+
type = key[:value].class.to_s.split("::").last
|
43
|
+
default = key[:value].instance_variable_get(:@default)
|
44
|
+
values = key[:value].instance_variable_get(:@values)
|
45
|
+
global_props[name.to_sym] = { "type": type, "default": default, "values": values }
|
46
|
+
end
|
47
|
+
global_props
|
48
|
+
end
|
49
|
+
|
8
50
|
def kit_props
|
9
51
|
kit_class.props
|
10
52
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<% example_html = ERB.new(example).result %>
|
2
|
+
|
1
3
|
<%= pb_rails("card", props: { classname: "pb--doc", padding: "none", dark: dark }) do %>
|
2
4
|
<div class="pb--kit-example">
|
3
5
|
<%= pb_rails("caption", props: { text: example_title, dark: dark }) %>
|
@@ -13,6 +15,23 @@
|
|
13
15
|
<div id="code-wrapper">
|
14
16
|
<div class="pb--codeControls">
|
15
17
|
<ul>
|
18
|
+
<% if type == "rails" %>
|
19
|
+
<li>
|
20
|
+
<a href="#" id="copy-<%= example_key %>-trigger" onclick="copyOnClick(`<%= example_html %>`, `copy-<%= example_key %>`)">
|
21
|
+
Copy HTML
|
22
|
+
</a>
|
23
|
+
<%= pb_rails("popover", props: {
|
24
|
+
classname: "popover-copy",
|
25
|
+
close_on_click: "any",
|
26
|
+
trigger_element_id: "copy-#{example_key}-trigger",
|
27
|
+
tooltip_id: "copy-#{example_key}",
|
28
|
+
position: "top",
|
29
|
+
padding: "xs"
|
30
|
+
}) do %>
|
31
|
+
HTML Copied
|
32
|
+
<% end %>
|
33
|
+
</li>
|
34
|
+
<% end %>
|
16
35
|
<li>
|
17
36
|
<a href="#" id="toggle-open" data-toggle="code_example">Code Example</a>
|
18
37
|
</li>
|
@@ -26,3 +45,17 @@
|
|
26
45
|
</div>
|
27
46
|
<% end %>
|
28
47
|
<% end %>
|
48
|
+
|
49
|
+
<script>
|
50
|
+
function copyOnClick(content, elementID) {
|
51
|
+
copyContent(content)
|
52
|
+
|
53
|
+
const popover = document.getElementById(elementID);
|
54
|
+
popover.style.display = "block";
|
55
|
+
|
56
|
+
setTimeout(() => {
|
57
|
+
popover.style.display = "none";
|
58
|
+
}, 3000);
|
59
|
+
}
|
60
|
+
</script>
|
61
|
+
|
@@ -33,12 +33,25 @@ module Playbook
|
|
33
33
|
def source
|
34
34
|
@source ||= begin
|
35
35
|
extension = type == "react" ? "jsx" : "html.erb"
|
36
|
-
read_kit_file("_#{example_key}.#{extension}")
|
36
|
+
stringified_code = read_kit_file("_#{example_key}.#{extension}")
|
37
|
+
sanitize_code(stringified_code)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
private
|
41
42
|
|
43
|
+
def sanitize_code(stringified_code)
|
44
|
+
stringified_code = stringified_code.gsub(%r{'../.*}, "'playbook-ui'")
|
45
|
+
.gsub(%r{"../.*}, '"playbook-ui"')
|
46
|
+
stringified_code = dark ? stringified_code.gsub("{...props}", "dark") : stringified_code.gsub(/\s*{...props}\s*\n/, "\n")
|
47
|
+
if stringified_code.include?("props: { ")
|
48
|
+
stringified_code = stringified_code.gsub("props: {", "props: {dark: true,") if type == "rails" && dark
|
49
|
+
elsif type == "rails" && dark
|
50
|
+
stringified_code = stringified_code.gsub("props: {", "props: {\n dark: true,")
|
51
|
+
end
|
52
|
+
stringified_code
|
53
|
+
end
|
54
|
+
|
42
55
|
def read_kit_file(*args)
|
43
56
|
path = ::Playbook.kit_path(kit, "docs", *args)
|
44
57
|
path.exist? ? path.read : ""
|
@@ -94,13 +94,13 @@ const IconStatValue = (props: IconStatValueProps) => {
|
|
94
94
|
|
95
95
|
<div>
|
96
96
|
<Flex
|
97
|
-
|
97
|
+
align="baseline"
|
98
98
|
>
|
99
|
-
|
99
|
+
{titleSize(size)}
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
<Body
|
102
|
+
text={unit}
|
103
|
+
/>
|
104
104
|
</Flex>
|
105
105
|
<Caption text={text} />
|
106
106
|
</div>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
@import "../tokens/colors";
|
2
2
|
|
3
3
|
$transform-rotate-deg: 135deg;
|
4
|
-
$input-max-width: 284px;
|
5
4
|
$dropdown-min-width: 340px;
|
6
5
|
$flag-min-resolution: 192dpi;
|
7
6
|
|
@@ -10,10 +9,6 @@ $flag-min-resolution: 192dpi;
|
|
10
9
|
color: $focus_input_light;
|
11
10
|
}
|
12
11
|
|
13
|
-
.text_input {
|
14
|
-
max-width: $input-max-width;
|
15
|
-
}
|
16
|
-
|
17
12
|
.dropdown_open {
|
18
13
|
.text_input {
|
19
14
|
border-color: $primary !important;
|
@@ -7,12 +7,10 @@ module Playbook
|
|
7
7
|
default: false
|
8
8
|
prop :initial_country, type: Playbook::Props::String,
|
9
9
|
default: ""
|
10
|
-
prop :is_valid
|
11
10
|
prop :label, type: Playbook::Props::String,
|
12
11
|
default: ""
|
13
12
|
prop :name, type: Playbook::Props::String,
|
14
13
|
default: ""
|
15
|
-
prop :onchange
|
16
14
|
prop :only_countries, type: Playbook::Props::Array,
|
17
15
|
default: []
|
18
16
|
prop :preferred_countries, type: Playbook::Props::Array,
|
@@ -30,10 +28,8 @@ module Playbook
|
|
30
28
|
dark: dark,
|
31
29
|
disabled: disabled,
|
32
30
|
initialCountry: initial_country,
|
33
|
-
isValid: is_valid,
|
34
31
|
label: label,
|
35
32
|
name: name,
|
36
|
-
onChange: onchange,
|
37
33
|
onlyCountries: only_countries,
|
38
34
|
preferredCountries: preferred_countries,
|
39
35
|
value: value,
|
@@ -1,14 +1,12 @@
|
|
1
|
-
|
1
|
+
import React from "react"
|
2
|
+
import classnames from "classnames"
|
2
3
|
|
3
|
-
import
|
4
|
-
import classnames from 'classnames'
|
4
|
+
import { buildAriaProps, buildDataProps } from "../utilities/props"
|
5
5
|
|
6
|
-
import
|
7
|
-
|
8
|
-
import Icon from '../pb_icon/_icon'
|
6
|
+
import Icon from "../pb_icon/_icon"
|
9
7
|
|
10
8
|
type StarRatingProps = {
|
11
|
-
aria?:
|
9
|
+
aria?: {[key: string]: string},
|
12
10
|
className?: string,
|
13
11
|
data?: object,
|
14
12
|
fixedWidth?: boolean,
|
@@ -16,7 +14,7 @@ type StarRatingProps = {
|
|
16
14
|
icon?: string,
|
17
15
|
id?: string,
|
18
16
|
rating: number,
|
19
|
-
}
|
17
|
+
};
|
20
18
|
|
21
19
|
const StarRating = ({
|
22
20
|
aria = {},
|
@@ -29,15 +27,15 @@ const StarRating = ({
|
|
29
27
|
const ariaProps = buildAriaProps(aria)
|
30
28
|
const dataProps = buildDataProps(data)
|
31
29
|
const css = classnames([
|
32
|
-
|
30
|
+
"pb_star_rating_kit", className,
|
33
31
|
])
|
34
32
|
|
35
33
|
const starCount = () => (
|
36
|
-
[...Array(
|
34
|
+
[...Array(Math.floor(rating))]
|
37
35
|
)
|
38
36
|
|
39
37
|
const hasHalfStar = () => (
|
40
|
-
|
38
|
+
rating % 1 !== 0
|
41
39
|
)
|
42
40
|
|
43
41
|
return (
|
@@ -47,12 +45,11 @@ const StarRating = ({
|
|
47
45
|
className={css}
|
48
46
|
id={id}
|
49
47
|
>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
{!hideRating && (
|
49
|
+
<div className="pb_star_rating_number">
|
50
|
+
{rating}
|
51
|
+
</div>
|
52
|
+
)}
|
56
53
|
<div className="pb_star_rating_wrapper">
|
57
54
|
<div className="pb_star_rating_highlight">
|
58
55
|
{starCount().map((_, index) => (
|
@@ -62,13 +59,12 @@ const StarRating = ({
|
|
62
59
|
key={index}
|
63
60
|
/>
|
64
61
|
))}
|
65
|
-
|
66
|
-
<If condition={hasHalfStar()}>
|
62
|
+
{hasHalfStar() && (
|
67
63
|
<Icon
|
68
|
-
|
69
|
-
|
64
|
+
fixedWidth={false}
|
65
|
+
icon="star-half"
|
70
66
|
/>
|
71
|
-
|
67
|
+
)}
|
72
68
|
</div>
|
73
69
|
|
74
70
|
<div className="pb_star_rating_base">
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
|
+
|
4
|
+
import StarRating from "./_star_rating";
|
5
|
+
|
6
|
+
const testId = "star-rating-kit";
|
7
|
+
|
8
|
+
describe("Star Rating Kit", () => {
|
9
|
+
test("Expects to have correct classname", () => {
|
10
|
+
render(
|
11
|
+
<StarRating
|
12
|
+
data={{ testid: testId }}
|
13
|
+
rating={2}
|
14
|
+
/>
|
15
|
+
);
|
16
|
+
|
17
|
+
|
18
|
+
const kit = screen.getByTestId(testId);
|
19
|
+
expect(kit).toHaveClass("pb_star_rating_kit");
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
test('should render aria-label', () => {
|
24
|
+
render(
|
25
|
+
<StarRating
|
26
|
+
aria={{ label: testId }}
|
27
|
+
data={{ testid: testId }}
|
28
|
+
rating={2}
|
29
|
+
/>
|
30
|
+
);
|
31
|
+
|
32
|
+
const kit = screen.getByTestId(testId)
|
33
|
+
expect(kit).toHaveAttribute('aria-label', testId)
|
34
|
+
});
|
35
|
+
|
36
|
+
test("Displays two highlighted stars", () => {
|
37
|
+
render(
|
38
|
+
<StarRating
|
39
|
+
data={{ testid: testId }}
|
40
|
+
rating={2}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
|
44
|
+
|
45
|
+
const kit = screen.getByTestId(testId);
|
46
|
+
const highlight = kit.querySelector(".pb_star_rating_highlight");
|
47
|
+
const stars = highlight.querySelectorAll(".far.fa-star");
|
48
|
+
const count = stars.length;
|
49
|
+
|
50
|
+
expect(count).toBe(2);
|
51
|
+
});
|
52
|
+
|
53
|
+
test("Displays three highlighted stars and a half star", () => {
|
54
|
+
render(
|
55
|
+
<StarRating
|
56
|
+
data={{ testid: testId }}
|
57
|
+
rating={3.5}
|
58
|
+
/>
|
59
|
+
);
|
60
|
+
|
61
|
+
const kit = screen.getByTestId(testId);
|
62
|
+
const highlight = kit.querySelector(".pb_star_rating_highlight");
|
63
|
+
const stars = highlight.querySelectorAll(".far.fa-star");
|
64
|
+
const halfStars = highlight.querySelectorAll(".far.fa-star-half");
|
65
|
+
const starCount = stars.length;
|
66
|
+
const halfStarCount = halfStars.length;
|
67
|
+
|
68
|
+
expect(starCount).toBe(3);
|
69
|
+
expect(halfStarCount).toBe(1);
|
70
|
+
});
|
71
|
+
});
|