playbook_ui 13.10.0 → 13.11.1.pre.alpha.play900startratingasinput1530

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_button/docs/_button_circle_swift.md +28 -0
  3. data/app/pb_kits/playbook/pb_button/docs/_button_default_swift.md +23 -0
  4. data/app/pb_kits/playbook/pb_button/docs/_button_full_width_swift.md +9 -0
  5. data/app/pb_kits/playbook/pb_button/docs/_button_icon_options_swift.md +18 -0
  6. data/app/pb_kits/playbook/pb_button/docs/_button_props_swift.md +11 -0
  7. data/app/pb_kits/playbook/pb_button/docs/_button_size_swift.md +20 -0
  8. data/app/pb_kits/playbook/pb_button/docs/example.yml +8 -0
  9. data/app/pb_kits/playbook/pb_card/docs/_card_background_swift.md +29 -0
  10. data/app/pb_kits/playbook/pb_card/docs/_card_border_none_swift.md +7 -0
  11. data/app/pb_kits/playbook/pb_card/docs/_card_border_radius_swift.md +33 -0
  12. data/app/pb_kits/playbook/pb_card/docs/_card_header_swift.md +33 -0
  13. data/app/pb_kits/playbook/pb_card/docs/_card_highlight_swift.md +17 -0
  14. data/app/pb_kits/playbook/pb_card/docs/_card_light_swift.md +7 -0
  15. data/app/pb_kits/playbook/pb_card/docs/_card_padding_swift.md +33 -0
  16. data/app/pb_kits/playbook/pb_card/docs/_card_props_swift.md +10 -0
  17. data/app/pb_kits/playbook/pb_card/docs/_card_selected_swift.md +0 -0
  18. data/app/pb_kits/playbook/pb_card/docs/_card_separator_swift.md +11 -0
  19. data/app/pb_kits/playbook/pb_card/docs/_card_shadow_swift.md +21 -0
  20. data/app/pb_kits/playbook/pb_card/docs/_card_styles_swift.md +17 -0
  21. data/app/pb_kits/playbook/pb_card/docs/_card_tag_swift.md +0 -0
  22. data/app/pb_kits/playbook/pb_card/docs/example.yml +12 -0
  23. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_default_swift.md +10 -0
  24. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_error_swift.md +12 -0
  25. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_swift.md +12 -0
  26. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_props_swift.md +7 -0
  27. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +7 -0
  28. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +3 -1
  29. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.html.erb +22 -0
  30. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.md +3 -0
  31. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.html.erb +40 -0
  32. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.md +1 -0
  33. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_collapsible/index.js +4 -0
  35. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +3 -3
  36. data/app/pb_kits/playbook/pb_icon/docs/_icon_border_swift.md +7 -0
  37. data/app/pb_kits/playbook/pb_icon/docs/_icon_default_swift.md +7 -0
  38. data/app/pb_kits/playbook/pb_icon/docs/_icon_flip_swift.md +11 -0
  39. data/app/pb_kits/playbook/pb_icon/docs/_icon_props_swift.md +8 -0
  40. data/app/pb_kits/playbook/pb_icon/docs/_icon_rotate_swift.md +11 -0
  41. data/app/pb_kits/playbook/pb_icon/docs/_icon_sizes_swift.md +46 -0
  42. data/app/pb_kits/playbook/pb_icon/docs/example.yml +8 -0
  43. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color_props.md +6 -0
  44. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color_swift.md +16 -0
  45. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_defaul_swift.md +7 -0
  46. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes_swift.md +11 -0
  47. data/app/pb_kits/playbook/pb_icon_circle/docs/example.yml +7 -0
  48. data/app/pb_kits/playbook/pb_image/docs/_image_props_swift.md +7 -0
  49. data/app/pb_kits/playbook/pb_image/docs/_rounded_image_swift.md +47 -0
  50. data/app/pb_kits/playbook/pb_image/docs/_size_image_swift.md +47 -0
  51. data/app/pb_kits/playbook/pb_image/docs/_size_none_image_swift.md +15 -0
  52. data/app/pb_kits/playbook/pb_image/docs/example.yml +5 -0
  53. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_default_swift.md +11 -0
  54. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_examples_swift.md +72 -0
  55. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_swift.md +41 -0
  56. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_props_swift.md +11 -0
  57. data/app/pb_kits/playbook/pb_label_value/docs/example.yml +6 -0
  58. data/app/pb_kits/playbook/pb_message/docs/_message_default_swift.md +57 -0
  59. data/app/pb_kits/playbook/pb_message/docs/_message_props_swift.md +12 -0
  60. data/app/pb_kits/playbook/pb_message/docs/example.yml +4 -0
  61. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +27 -20
  62. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.html.erb +0 -1
  63. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.html.erb +104 -45
  64. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.jsx +100 -43
  65. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.md +1 -0
  66. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.html.erb +138 -0
  67. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.jsx +150 -0
  68. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.md +1 -0
  69. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
  70. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  71. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +10 -2
  72. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +8 -4
  73. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.jsx +33 -0
  74. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.md +3 -0
  75. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  76. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
  77. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_advanced.test.js +47 -0
  78. data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +61 -49
  79. data/app/pb_kits/playbook/pb_star_rating/_star_rating.tsx +151 -54
  80. data/app/pb_kits/playbook/pb_star_rating/custom-icons.js +356 -0
  81. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.html.erb +7 -0
  82. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_color_options.jsx +40 -0
  83. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.html.erb +11 -1
  84. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_default.jsx +17 -2
  85. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.html.erb +6 -1
  86. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_hide.jsx +22 -5
  87. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.html.erb +12 -0
  88. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_number_config.jsx +57 -0
  89. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.html.erb +23 -0
  90. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_size_options.jsx +59 -0
  91. data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +10 -5
  92. data/app/pb_kits/playbook/pb_star_rating/docs/index.js +6 -0
  93. data/app/pb_kits/playbook/pb_star_rating/star.svg +3 -0
  94. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +56 -15
  95. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +49 -6
  96. data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +33 -34
  97. data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +47 -31
  98. data/app/pb_kits/playbook/pb_table/docs/_table_header.md +5 -0
  99. data/app/pb_kits/playbook/pb_table/styles/_hover.scss +26 -2
  100. data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +1 -17
  101. data/app/pb_kits/playbook/pb_table/table_header.html.erb +5 -4
  102. data/app/pb_kits/playbook/pb_table/table_header.rb +28 -5
  103. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -9
  104. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  105. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default_react.jsx +0 -2
  106. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay.jsx +0 -1
  107. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.jsx +0 -1
  108. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_margin.jsx +0 -1
  109. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_selectors.html.erb +1 -1
  110. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.html.erb +39 -0
  111. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.md +5 -0
  112. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.jsx +45 -0
  113. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.md +3 -0
  114. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +3 -0
  115. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
  116. data/app/pb_kits/playbook/pb_tooltip/index.js +6 -0
  117. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -1
  118. data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +34 -0
  119. data/app/pb_kits/playbook/playbook-doc.js +1 -1
  120. data/dist/menu.yml +284 -110
  121. data/dist/playbook-rails.js +5 -5
  122. data/lib/playbook/pb_doc_helper.rb +12 -1
  123. data/lib/playbook/version.rb +2 -2
  124. metadata +73 -7
@@ -1,3 +1,9 @@
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
+
3
5
  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'
@@ -0,0 +1,3 @@
1
+ <svg width="50" height="48" viewBox="0 0 50 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M26.7271 1.3113C26.3525 0.561986 25.6032 0 24.6665 0C23.8235 0 23.0742 0.561986 22.6996 1.3113L16.2367 14.518L1.90607 16.6723C1.06309 16.7659 0.40744 17.4216 0.126447 18.1709C-0.154546 19.0139 0.0327825 19.8568 0.688433 20.5125L11.0852 30.8156L8.55624 45.3335C8.46257 46.1765 8.83723 47.1132 9.49288 47.5815C10.2422 48.0498 11.0852 48.1435 11.8345 47.7688L24.6665 40.8377L37.4985 47.7688C38.2478 48.1435 39.1845 48.0498 39.9338 47.5815C40.5895 47.1132 40.9641 46.1765 40.7768 45.3335L38.3415 30.8156L48.7382 20.5125C49.3939 19.8568 49.5812 19.0139 49.3002 18.1709C49.0192 17.4216 48.3636 16.7659 47.5206 16.6723L33.19 14.518L26.7271 1.3113Z" fill="#0056CF"/>
3
+ </svg>
@@ -3,29 +3,70 @@
3
3
  data: object.data,
4
4
  class: object.classname) do %>
5
5
  <%# Rating value %>
6
- <% if !object.hide_rating %>
7
- <%= content_tag(:div, object.rating, class: "pb_star_rating_number") %>
6
+ <% if layout_option == "number" %>
7
+ <%= content_tag(:div, class: "number_rails_#{size}") do %>
8
+ <% case object.size %>
9
+ <% when "xs", "sm" %>
10
+ <%= pb_rails("caption", props: { text: object.rating,
11
+ size: "sm",
12
+ dark: dark,
13
+ padding_right: "xxs" }) %>
14
+ <% when "md" %>
15
+ <%= pb_rails("body", props: { text: object.rating,
16
+ dark: dark,
17
+ padding_right: "xxs" }) %>
18
+ <% when "lg" %>
19
+ <%= pb_rails("title", props: { text: object.rating,
20
+ size: 2,
21
+ dark: dark,
22
+ padding_right: "sm" }) %>
23
+ <% end %>
24
+ <% end %>
8
25
  <% end %>
9
-
10
26
  <%= content_tag(:div, class: "pb_star_rating_wrapper") do %>
11
27
  <%# Gold stars generated by rating value %>
12
28
  <%= content_tag(:div, class: "pb_star_rating_highlight") do %>
13
29
  <% object.star_count.times do %>
14
- <%= pb_rails("icon", props: { icon: "star" }) %>
30
+ <svg width="<%= svg_size %>" height="<%= svg_size %>" viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
31
+ <% case object.color_option %>
32
+ <% when "yellow"%>
33
+ <path fill-rule="evenodd" clip-rule="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"/>
34
+ <% when "primary", "outline" %>
35
+ <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"/>
36
+ <% when "subtle"%>
37
+ <path fill="<%= 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" />
38
+ <% end %>
39
+ </svg>
15
40
  <% end %>
16
- <% unless object.star_full %>
17
- <%= pb_rails("icon", props: { icon: "star-half" }) %>
41
+ <% object.empty_stars.times do %>
42
+ <svg width="<%= svg_size %>" height="<%= svg_size %>" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
43
+ <% if object.color_option == "outline" %>
44
+ <path stroke="<%= 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" />
45
+ <% else %>
46
+ <path fill="<%= 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" />
47
+ <% end %>
48
+ </svg>
18
49
  <% end %>
19
50
  <% 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" }) %>
51
+ <% end %>
52
+ <% if layout_option == "onestar" %>
53
+ <%= content_tag(:div, class: "number_rails_#{size}") do %>
54
+ <% case object.size %>
55
+ <% when "xs", "sm" %>
56
+ <%= pb_rails("caption", props: { text: "#{object.rating} of #{object.denominator}",
57
+ size: "xs",
58
+ dark: dark,
59
+ padding_left: "xxs" }) %>
60
+ <% when "md" %>
61
+ <%= pb_rails("body", props: { text: "#{object.rating} of #{object.denominator}",
62
+ dark: dark,
63
+ padding_left: "xxs" }) %>
64
+ <% when "lg" %>
65
+ <%= pb_rails("title", props: { text: "#{object.rating} of #{object.denominator}",
66
+ size: 2,
67
+ dark: dark,
68
+ padding_left: "sm" }) %>
69
+ <% end %>
28
70
  <% end %>
29
-
30
71
  <% end %>
31
72
  <% end %>
@@ -3,18 +3,61 @@
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
-
9
6
  prop :rating, type: Playbook::Props::Numeric,
10
7
  default: 0
11
8
 
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
+
12
24
  def star_count
13
- rating.floor
25
+ rating.floor > denominator_style ? denominator_style : 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 ? "$border_dark" : "#E4E8F0"
38
+ end
39
+
40
+ def outline_star_color
41
+ dark ? "$text_dk_lighter" : "#C1CDD6"
42
+ end
43
+
44
+ def subtle_star_color
45
+ dark ? "$text_dk_default" : "#242B42"
14
46
  end
15
47
 
16
- def star_full
17
- (rating.to_f % 1).zero?
48
+ def svg_size
49
+ case size
50
+ when "sx"
51
+ 14
52
+ when "sm"
53
+ 16
54
+ when "md"
55
+ 24
56
+ when "lg"
57
+ 48
58
+ else
59
+ 16
60
+ end
18
61
  end
19
62
 
20
63
  def classname
@@ -1,24 +1,22 @@
1
- import React from "react";
2
- import { render, screen } from "../utilities/test-utils";
1
+ import React from "react"
2
+ import { render, screen } from "../utilities/test-utils"
3
3
 
4
- import StarRating from "./_star_rating";
4
+ import StarRating from "./_star_rating"
5
5
 
6
- const testId = "star-rating-kit";
6
+ const testId = "star-rating-kit"
7
7
 
8
8
  describe("Star Rating Kit", () => {
9
9
  test("Expects to have correct classname", () => {
10
10
  render(
11
11
  <StarRating
12
12
  data={{ testid: testId }}
13
- rating={2}
14
13
  />
15
- );
16
-
14
+ )
17
15
 
18
- const kit = screen.getByTestId(testId);
19
- expect(kit).toHaveClass("pb_star_rating_kit");
16
+ const kit = screen.getByTestId(testId)
17
+ expect(kit.className).toBe("pb_star_rating_kit")
20
18
 
21
- });
19
+ })
22
20
 
23
21
  test('should render aria-label', () => {
24
22
  render(
@@ -27,45 +25,46 @@ describe("Star Rating Kit", () => {
27
25
  data={{ testid: testId }}
28
26
  rating={2}
29
27
  />
30
- );
28
+ )
31
29
 
32
30
  const kit = screen.getByTestId(testId)
33
31
  expect(kit).toHaveAttribute('aria-label', testId)
34
- });
32
+ })
35
33
 
36
- test("Displays two highlighted stars", () => {
34
+ test("Displays correct denominator", () => {
37
35
  render(
38
36
  <StarRating
39
37
  data={{ testid: testId }}
38
+ denominator={4}
40
39
  rating={2}
41
40
  />
42
- );
43
-
41
+ )
44
42
 
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;
43
+ const kit = screen.getByTestId(testId)
44
+ const highlight = kit.querySelector(".pb_star_rating_wrapper")
45
+ const stars = highlight.querySelectorAll(".pb_star_sm")
46
+ const count = stars.length
49
47
 
50
- expect(count).toBe(2);
51
- });
48
+ expect(count).toBe(4)
49
+ })
52
50
 
53
- test("Displays three highlighted stars and a half star", () => {
51
+ test("Uses correct size", () => {
54
52
  render(
55
53
  <StarRating
56
54
  data={{ testid: testId }}
57
- rating={3.5}
55
+ layoutOption="number"
56
+ rating={2}
57
+ size="lg"
58
58
  />
59
- );
59
+ )
60
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;
61
+ const kit = screen.getByTestId(testId)
62
+ const highlight = kit.querySelector(".pb_star_rating_wrapper")
63
+ const title = kit.querySelector(".pb_star_rating_number_lg")
64
+ const stars = highlight.querySelectorAll(".pb_star_lg")
65
+ const count = stars.length
67
66
 
68
- expect(starCount).toBe(3);
69
- expect(halfStarCount).toBe(1);
70
- });
71
- });
67
+ expect(title.className).toBe("pb_star_rating_number_lg")
68
+ expect(count).toBe(5)
69
+ })
70
+ })
@@ -1,12 +1,37 @@
1
- <%= pb_rails("table", props: { size: "lg"} ) do %>
1
+ <%# Example data for demonstration purposes %>
2
+ <% data_rows = [
3
+ { 'territory' => 'North', 'firstname' => 'John', 'lastname' => 'Doe', 'age' => 30, 'job' => 'Engineer' },
4
+ { 'territory' => 'South', 'firstname' => 'Alice', 'lastname' => 'Smith', 'age' => 28, 'job' => 'Designer' },
5
+ { 'territory' => 'East', 'firstname' => 'Mike', 'lastname' => 'Johnson', 'age' => 35, 'job' => 'Manager' },
6
+ { 'territory' => 'West', 'firstname' => 'Sarah', 'lastname' => 'Brown', 'age' => 29, 'job' => 'Developer' },
7
+ { 'territory' => 'Central', 'firstname' => 'David', 'lastname' => 'Wilson', 'age' => 32, 'job' => 'Analyst' }
8
+ ]
9
+ %>
10
+
11
+ <%# Example sort method for demonstration purposes %>
12
+ <% if params["sort"] %>
13
+ <% sort_param = params["sort"].gsub(/_(asc|desc)\z/, "") %>
14
+ <% sort_direction = params["sort"].end_with?("_asc") ? 1 : -1 %>
15
+ <% data_rows.sort! do |a, b|
16
+ value_a = a[sort_param]
17
+ value_b = b[sort_param]
18
+
19
+ value_a = value_a.to_i if value_a.is_a?(String) && value_a.match?(/^\d+$/)
20
+ value_b = value_b.to_i if value_b.is_a?(String) && value_b.match?(/^\d+$/)
21
+
22
+ sort_direction * (value_a <=> value_b)
23
+ end %>
24
+ <% end %>
25
+
26
+ <%= pb_rails("table", props: { data_table: true, vertical_border: true, id: "table-header" } ) do %>
2
27
  <thead>
3
28
  <tr>
4
29
  <%= pb_rails("table/table_header", props: {
5
30
  text: "Territory",
6
31
  id: "territory",
7
32
  sort_menu: [
8
- { item: "Territory", link: "?sort=territory_desc", active: params["sort"] == "territory_desc", direction: "desc" },
9
- { item: "Territory", link: "?sort=territory_asc", active: params["sort"] == "territory_asc", direction: "asc" }
33
+ { item: "Territory", link: "?sort=territory_asc#table-header", active: params["sort"] == "territory_asc", direction: "asc" },
34
+ { item: "Territory", link: "?sort=territory_desc#table-header", active: params["sort"] == "territory_desc", direction: "desc" }
10
35
  ],
11
36
  }) %>
12
37
  <%= pb_rails("table/table_header", props: {
@@ -14,45 +39,36 @@
14
39
  text: "Full Name",
15
40
  colspan: 2,
16
41
  sort_menu: [
17
- { item: "First Name Descending", link: "?sort=firstname_desc", active: params["sort"] == "firstname_desc", direction: "desc" },
18
- { item: "First Name Ascending", link: "?sort=firstname_asc", active: params["sort"] == "firstname_asc", direction: "asc" },
19
- { item: "Last Name Descending", link: "?sort=lastname_desc", active: params["sort"] == "lastname_desc", direction: "desc" },
20
- { item: "Last Name Ascending", link: "?sort=lastname_asc", active: params["sort"] == "lastname_asc", direction: "asc" }
42
+ { item: "First Name", link: "?sort=firstname_desc#table-header", active: params["sort"] == "firstname_desc", direction: "desc" },
43
+ { item: "First Name", link: "?sort=firstname_asc#table-header", active: params["sort"] == "firstname_asc", direction: "asc" },
44
+ { item: "Last Name", link: "?sort=lastname_desc#table-header", active: params["sort"] == "lastname_desc", direction: "desc" },
45
+ { item: "Last Name", link: "?sort=lastname_asc#table-header", active: params["sort"] == "lastname_asc", direction: "asc" }
21
46
  ],
22
47
  }) %>
23
48
  <%= pb_rails("table/table_header", props: {
24
49
  text: "Age",
25
50
  id: "age",
26
- sort_dropdown: true,
27
51
  sort_menu: [
28
- { item: "Age Descending", link: "?sort=age_desc", active: params["sort"] == "age_desc", direction: "desc" },
29
- { item: "Age Ascending", link: "?sort=age_asc", active: params["sort"] == "age_asc", direction: "asc" }
52
+ { item: "Age Descending", link: "?sort=age_desc#table-header", active: params["sort"] == "age_desc", direction: "desc" },
53
+ { item: "Age Ascending", link: "?sort=age_asc#table-header", active: params["sort"] == "age_asc", direction: "asc" }
30
54
  ],
31
55
  }) %>
32
56
  <%= pb_rails("table/table_header", props: { text: "Job Title" }) %>
33
57
  </tr>
34
58
  </thead>
35
59
  <tbody>
36
- <tr>
37
- <td>Ter 1</td>
38
- <td>First Name 1</td>
39
- <td>Last Name 1</td>
40
- <td>Age 1</td>
41
- <td>Job 1</td>
42
- </tr>
43
- <tr>
44
- <td>Ter 2</td>
45
- <td>First Name 2</td>
46
- <td>Last Name 2</td>
47
- <td>Age 2</td>
48
- <td>Job 2</td>
49
- </tr>
50
- <tr>
51
- <td>Ter 3</td>
52
- <td>First Name 3</td>
53
- <td>Last Name 3</td>
54
- <td>Age 3</td>
55
- <td>Job 3</td>
56
- </tr>
60
+ <% data_rows.each do |row| %>
61
+ <tr>
62
+ <% row.each do |key, value| %>
63
+ <%= pb_rails("background", props: {
64
+ background_color: (params["sort"] && params["sort"].start_with?(key) ? "info_subtle" : "card_light"),
65
+ text_align: (value.is_a?(Integer) ? "right" : ""),
66
+ tag: "td"
67
+ }) do %>
68
+ <%= value %>
69
+ <% end %>
70
+ <% end %>
71
+ </tr>
72
+ <% end %>
57
73
  </tbody>
58
74
  <% end %>
@@ -6,3 +6,8 @@ presence of `sort_menu` enables the sort link within the header
6
6
  * `sort_dropdown` (boolean) optionally declares that (true) clicking a header's sort link opens a dropdown of sort options, or (false) each sort link click cycles through available sort_menu items in the order they are passed
7
7
  * passing a valid `colspan` will render sort options within a dropdown by default, without requiring `sort_dropdown` explicitly. Alternatively, the default sort dropdown can be prevented on headers with `colspan` by setting `sort_dropdown: false`, which reverts the column to sorting to multi-click default (each click of the sort link cycles through the available sort_menu items in the order they are passed)
8
8
  * `id` (string) is required for headers that have a dropdown (for popover reference); otherwise they are optional
9
+
10
+ </br>
11
+ <div class="pb_pill_kit_warning"><div class="pb_title_kit_size_4 pb_pill_text">Disclaimer</div></div>
12
+
13
+ This example uses a custom sort method that may need to be modified or replaced within your project.
@@ -1,6 +1,7 @@
1
1
  @import "../../tokens/opacity";
2
2
 
3
3
  $transition-speed: 0.2s;
4
+ $border_hover_color_dark: lighten($border_dark, 5%);
4
5
 
5
6
  [class^=pb_table] {
6
7
  &.table-sm,
@@ -15,9 +16,9 @@ $transition-speed: 0.2s;
15
16
  td {
16
17
  border-top-color: transparent;
17
18
  border-top-width: 0;
18
- transition: all $transition-speed ease;
19
+ transition: all $transition-speed ease;
19
20
  }
20
- @media (hover:hover) {
21
+ @media (hover:hover) {
21
22
  td {
22
23
  position: relative;
23
24
  &:after {
@@ -69,6 +70,29 @@ $transition-speed: 0.2s;
69
70
  }
70
71
  }
71
72
  }
73
+
74
+ &.dark {
75
+ tbody {
76
+ tr {
77
+ @media (hover:hover) {
78
+ &:hover {
79
+ box-shadow: 0 2px 10px 0 $shadow_dark;
80
+ td {
81
+ border-top-width: 0;
82
+ border-top-color: transparent;
83
+ border-color: $border_hover_color_dark !important;
84
+ &:after {
85
+ transition: background-color $transition-speed ease, height $transition-speed ease;
86
+ background-color: $border_hover_color_dark !important;
87
+ height: 1px;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+
72
96
  }
73
97
  }
74
98
  }
@@ -1,6 +1,6 @@
1
1
  @import "../../tokens/screen_sizes";
2
2
 
3
- $table-dark-card-bg: $bg_dark;
3
+ $table-dark-card-bg: $card_dark;
4
4
 
5
5
  [class^=pb_table] {
6
6
  &.table-sm,
@@ -24,7 +24,6 @@ $table-dark-card-bg: $bg_dark;
24
24
 
25
25
  td {
26
26
  border-color: $border_dark !important;
27
- border-bottom-width: 0 !important;
28
27
  color: $white;
29
28
 
30
29
  &:before {
@@ -39,21 +38,6 @@ $table-dark-card-bg: $bg_dark;
39
38
  }
40
39
  }
41
40
 
42
- &:not(.no-hover) {
43
- tbody {
44
- tr {
45
- @media (hover:hover) {
46
- &:hover {
47
- td {
48
- border-color: $border_dark !important;
49
- background: $bg_dark;
50
- }
51
- }
52
- }
53
- }
54
- }
55
- }
56
-
57
41
  &.table-card {
58
42
  background: $table-dark-card-bg !important;
59
43
  }
@@ -3,7 +3,7 @@
3
3
  aria: object.aria,
4
4
  class: object.classname,
5
5
  data: object.data,
6
- id: "pb-th#{object.id}") do %>
6
+ id: "pb-th#{object.id}" ) do %>
7
7
  <% unless sorting_style? %>
8
8
  <%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_nolink" }) do %>
9
9
  <%= content.presence || object.text %>
@@ -28,15 +28,16 @@
28
28
  position: object.placement ,
29
29
  padding: 'none'}) do %>
30
30
  <%= pb_rails("nav", props: {classname: "pb_table_header_dropdown"}) do %>
31
- <% object.sort_menu.each_with_index do |item, index| %>
31
+ <% object.sort_items.each do |sort_item| %>
32
+ <% item = active_or_first_item(sort_items_for(sort_item)) %>
32
33
  <%= pb_rails("nav/item", props: {
33
34
  text: item[:item],
34
- link: item[:link],
35
+ link: next_link(sort_item: sort_item),
35
36
  highlighted_border: false,
36
37
  padding: "xs",
37
38
  icon_right: sort_icon(item[:direction], item[:active]),
38
39
  active: item[:active],
39
- classname: "header_nav_item #{'header_first_item' if index == 0} #{'header_last_item' if index == object.sort_menu.size - 1}"
40
+ classname: "header_nav_item"
40
41
  }) %>
41
42
  <% end %>
42
43
  <% end %>
@@ -32,20 +32,43 @@ module Playbook
32
32
  align.present? ? "align_#{align}" : nil
33
33
  end
34
34
 
35
- def next_link
36
- return sort_menu[0][:link] if sort_menu.all? { |item| item[:active] == false }
35
+ def next_link(sort_item: "")
36
+ sort_menu_for = if sort_item.blank?
37
+ sort_menu
38
+ else
39
+ sort_items_for(sort_item)
40
+ end
41
+
42
+ return sort_menu_for[0][:link] if sort_menu_for.all? { |item| item[:active] == false }
37
43
 
38
44
  link = ""
39
45
 
40
- sort_menu.each_with_index do |item, index|
46
+ sort_menu_for.each_with_index do |item, index|
41
47
  if item[:active] == true
42
- next_index = (index + 1) % sort_menu.length
43
- link = sort_menu[next_index][:link]
48
+ next_index = (index + 1) % sort_menu_for.length
49
+ link = sort_menu_for[next_index][:link]
44
50
  end
45
51
  end
46
52
  link
47
53
  end
48
54
 
55
+ def sort_items
56
+ sort_menu.map { |hash| hash[:item] }.uniq
57
+ end
58
+
59
+ def sort_items_for(sort_item)
60
+ sort_menu.find_all { |hash| hash[:item] == sort_item }
61
+ end
62
+
63
+ def active_or_first_item(items)
64
+ active_item = items.find { |hash| hash[:active] == true }
65
+ if active_item.present?
66
+ active_item
67
+ else
68
+ items[0]
69
+ end
70
+ end
71
+
49
72
  def sorting_style?
50
73
  sort_menu != [{}]
51
74
  end
@@ -1,4 +1,4 @@
1
- import React, { useRef, useState } from "react"
1
+ import React, { useRef, useState, forwardRef, ForwardedRef } from "react"
2
2
 
3
3
  import {
4
4
  arrow,
@@ -28,9 +28,10 @@ type TooltipProps = {
28
28
  placement?: Placement,
29
29
  position?: "absolute" | "fixed";
30
30
  text: string,
31
+ showTooltip?: boolean,
31
32
  } & GlobalProps
32
33
 
33
- const Tooltip = (props: TooltipProps): React.ReactElement => {
34
+ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): React.ReactElement => {
34
35
  const {
35
36
  aria = {},
36
37
  className,
@@ -42,6 +43,7 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
42
43
  placement: preferredPlacement = "top",
43
44
  position = "absolute",
44
45
  text,
46
+ showTooltip = true,
45
47
  zIndex,
46
48
  ...rest
47
49
  } = props
@@ -59,10 +61,9 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
59
61
 
60
62
  const {
61
63
  context,
62
- floating,
63
64
  middlewareData: { arrow: { x: arrowX, y: arrowY } = {}, },
64
65
  placement,
65
- reference,
66
+ refs,
66
67
  strategy,
67
68
  x,
68
69
  y,
@@ -82,12 +83,16 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
82
83
  ],
83
84
  open,
84
85
  onOpenChange(open) {
85
- setOpen(open)
86
+ if(!showTooltip) {
87
+ return
88
+ } else {
89
+ setOpen(open)
90
+ }
86
91
  },
87
92
  placement: preferredPlacement
88
93
  })
89
94
 
90
-
95
+
91
96
  const { getFloatingProps } = useInteractions([
92
97
  useHover(context, {
93
98
  delay,
@@ -108,7 +113,16 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
108
113
  <>
109
114
  <div
110
115
  className={`pb_tooltip_kit ${css}`}
111
- ref={reference}
116
+ ref={(element) => {
117
+ refs.setReference(element);
118
+ if (ref) {
119
+ if (typeof ref === "function") {
120
+ ref(element);
121
+ } else if (typeof ref === "object") {
122
+ ref.current = element;
123
+ }
124
+ }
125
+ }}
112
126
  role="tooltip_trigger"
113
127
  style={{ display: "inline-flex" }}
114
128
  {...ariaProps}
@@ -120,7 +134,7 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
120
134
  <div
121
135
  {...getFloatingProps({
122
136
  className: `tooltip_tooltip ${placement} visible`,
123
- ref: floating,
137
+ ref: refs.setFloating,
124
138
  role: "tooltip",
125
139
  style: {
126
140
  position: strategy,
@@ -153,6 +167,8 @@ const Tooltip = (props: TooltipProps): React.ReactElement => {
153
167
  )}
154
168
  </>
155
169
  )
156
- }
170
+ })
171
+
172
+ Tooltip.displayName = "Tooltip"
157
173
 
158
174
  export default Tooltip