playbook_ui 7.0.1.pre.alpha10 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -6
  3. data/app/controllers/playbook/application_controller.rb +1 -4
  4. data/app/helpers/playbook/pb_kit_helper.rb +2 -2
  5. data/app/pb_kits/playbook/_playbook.scss +1 -0
  6. data/app/pb_kits/playbook/index.js +6 -0
  7. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +5 -1
  8. data/app/pb_kits/playbook/pb_badge/_badge.jsx +4 -2
  9. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.html.erb +1 -12
  10. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +2 -1
  12. data/app/pb_kits/playbook/pb_button/_button.jsx +5 -1
  13. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +5 -1
  14. data/app/pb_kits/playbook/pb_caption/_caption.jsx +2 -2
  15. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +5 -2
  16. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +3 -1
  17. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_options.html.erb +10 -0
  18. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -0
  19. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +130 -0
  21. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.scss +1 -1
  22. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +39 -0
  23. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +29 -0
  24. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +28 -0
  25. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx +117 -0
  26. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +53 -0
  27. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +30 -0
  28. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_labels.jsx +45 -0
  29. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_legend_kit.jsx +30 -0
  30. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_title.jsx +45 -0
  31. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +11 -0
  32. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +9 -0
  33. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +5 -1
  34. data/app/pb_kits/playbook/pb_contact/_contact.jsx +5 -1
  35. data/app/pb_kits/playbook/pb_currency/_currency.jsx +5 -1
  36. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +5 -1
  37. data/app/pb_kits/playbook/pb_date/date.rb +2 -1
  38. data/app/pb_kits/playbook/pb_date/docs/_date_default.html.erb +8 -1
  39. data/app/pb_kits/playbook/pb_date/docs/_date_timezone.html.erb +51 -0
  40. data/app/pb_kits/playbook/pb_date/docs/_date_timezone.md +6 -0
  41. data/app/pb_kits/playbook/pb_date/docs/_description.md +2 -0
  42. data/app/pb_kits/playbook/pb_date/docs/example.yml +1 -0
  43. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +7 -4
  44. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -4
  45. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -3
  46. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +8 -10
  47. data/app/pb_kits/playbook/pb_date_picker/docs/{_date_picker_read_only.html.erb → _date_picker_allow_input.html.erb} +1 -1
  48. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.jsx +13 -0
  49. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.md +1 -0
  50. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx +34 -0
  51. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +3 -0
  52. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +3 -2
  53. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  54. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +1 -0
  55. data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.jsx +5 -1
  56. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx +2 -2
  57. data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.jsx +5 -1
  58. data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.html.erb +1 -8
  59. data/app/pb_kits/playbook/pb_distribution_bar/distribution_bar.rb +7 -0
  60. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx +2 -2
  61. data/app/pb_kits/playbook/pb_flex/_flex.jsx +2 -2
  62. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
  63. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +9 -1
  64. data/app/pb_kits/playbook/pb_form/form_builder/checkbox_field.rb +7 -2
  65. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +3 -2
  66. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +1 -1
  67. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
  68. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +2 -2
  69. data/app/pb_kits/playbook/pb_icon/_icon.jsx +2 -2
  70. data/app/pb_kits/playbook/pb_icon_value/_icon_value.jsx +5 -1
  71. data/app/pb_kits/playbook/pb_image/_image.jsx +5 -1
  72. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +5 -1
  73. data/app/pb_kits/playbook/pb_layout/_layout.jsx +4 -4
  74. data/app/pb_kits/playbook/pb_line_graph/_line_graph.html.erb +1 -13
  75. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +1 -1
  76. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +2 -1
  77. data/app/pb_kits/playbook/pb_list/_list.jsx +3 -2
  78. data/app/pb_kits/playbook/pb_list/_list_item.jsx +3 -2
  79. data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +5 -1
  80. data/app/pb_kits/playbook/pb_message/_message.jsx +5 -1
  81. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +5 -2
  82. data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
  83. data/app/pb_kits/playbook/pb_person/_person.jsx +5 -1
  84. data/app/pb_kits/playbook/pb_person_contact/_person_contact.jsx +12 -7
  85. data/app/pb_kits/playbook/pb_person_contact/docs/_person_contact_with_wrong_numbers.jsx +1 -0
  86. data/app/pb_kits/playbook/pb_popover/_popover.jsx +5 -1
  87. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +4 -4
  88. data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
  89. data/app/pb_kits/playbook/pb_radio/_radio.html.erb +1 -1
  90. data/app/pb_kits/playbook/pb_radio/docs/_radio_options.html.erb +9 -0
  91. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
  92. data/app/pb_kits/playbook/pb_radio/radio.rb +2 -4
  93. data/app/pb_kits/playbook/pb_section_separator/_section_separator.jsx +1 -1
  94. data/app/pb_kits/playbook/pb_select/_select.scss +1 -1
  95. data/app/pb_kits/playbook/pb_stat_change/_stat_change.jsx +2 -2
  96. data/app/pb_kits/playbook/pb_stat_value/_stat_value.jsx +3 -3
  97. data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_default.jsx +6 -1
  98. data/app/pb_kits/playbook/pb_table/_table.jsx +2 -2
  99. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
  100. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +17 -8
  101. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -1
  102. data/app/pb_kits/playbook/pb_time/_time.html.erb +23 -17
  103. data/app/pb_kits/playbook/pb_time/_time.jsx +22 -13
  104. data/app/pb_kits/playbook/pb_time/_time.scss +16 -8
  105. data/app/pb_kits/playbook/pb_time/docs/_time_align.html.erb +18 -0
  106. data/app/pb_kits/playbook/pb_time/docs/_time_align.jsx +3 -3
  107. data/app/pb_kits/playbook/pb_time/docs/_time_default.html.erb +47 -3
  108. data/app/pb_kits/playbook/pb_time/docs/_time_default.jsx +33 -4
  109. data/app/pb_kits/playbook/pb_time/docs/_time_sizes.html.erb +11 -0
  110. data/app/pb_kits/playbook/pb_time/docs/_time_sizes.jsx +19 -0
  111. data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.html.erb +3 -1
  112. data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.jsx +0 -7
  113. data/app/pb_kits/playbook/pb_time/docs/_time_timezone.html.erb +38 -0
  114. data/app/pb_kits/playbook/pb_time/docs/_time_timezone.jsx +12 -14
  115. data/app/pb_kits/playbook/pb_time/docs/example.yml +6 -2
  116. data/app/pb_kits/playbook/pb_time/docs/index.js +1 -0
  117. data/app/pb_kits/playbook/pb_time/time.rb +14 -2
  118. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.jsx +1 -1
  119. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +3 -3
  120. data/app/pb_kits/playbook/pb_timestamp/_timestamp.jsx +1 -1
  121. data/app/pb_kits/playbook/pb_title/_title.jsx +5 -1
  122. data/app/pb_kits/playbook/pb_title_count/_title_count.jsx +5 -1
  123. data/app/pb_kits/playbook/pb_title_detail/_title_detail.jsx +5 -5
  124. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +3 -3
  125. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +41 -43
  126. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +0 -2
  127. data/app/pb_kits/playbook/pb_toggle/docs/index.js +0 -1
  128. data/app/pb_kits/playbook/pb_toggle/toggle.rb +1 -1
  129. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +60 -0
  130. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +20 -3
  131. data/app/pb_kits/playbook/pb_typeahead/components/Control.jsx +30 -0
  132. data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.jsx +13 -0
  133. data/app/pb_kits/playbook/pb_typeahead/components/MenuList.jsx +12 -0
  134. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +51 -0
  135. data/app/pb_kits/playbook/pb_typeahead/components/Option.jsx +34 -0
  136. data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.jsx +13 -0
  137. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.jsx +13 -0
  138. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +22 -0
  139. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.jsx +29 -0
  140. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +84 -0
  141. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_summary.jsx +45 -0
  142. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +101 -0
  143. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_summary.jsx +27 -0
  144. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +8 -2
  145. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +4 -0
  146. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +5 -2
  147. data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
  148. data/app/pb_kits/playbook/react_rails_kits.js +5 -0
  149. data/app/pb_kits/playbook/tokens/_colors.scss +22 -23
  150. data/app/pb_kits/playbook/tokens/_typography.scss +7 -7
  151. data/app/pb_kits/playbook/tokens/index.scss +11 -0
  152. data/app/pb_kits/playbook/vendor.js +5 -0
  153. data/lib/generators/kit/kit_generator.rb +1 -1
  154. data/lib/generators/kit/templates/kit_jsx.erb.tt +1 -1
  155. data/lib/playbook/engine.rb +1 -0
  156. data/lib/playbook/version.rb +1 -1
  157. data/lib/tasks/pb_release.rake +14 -3
  158. metadata +46 -70
  159. data/app/controllers/playbook/guides_controller.rb +0 -11
  160. data/app/controllers/playbook/pages_controller.rb +0 -94
  161. data/app/controllers/playbook/samples_controller.rb +0 -40
  162. data/app/pb_kits/playbook/packs/application.js +0 -55
  163. data/app/pb_kits/playbook/packs/examples.js +0 -176
  164. data/app/pb_kits/playbook/packs/main.scss +0 -12
  165. data/app/pb_kits/playbook/packs/samples.js +0 -21
  166. data/app/pb_kits/playbook/packs/site_styles/_samples.scss +0 -72
  167. data/app/pb_kits/playbook/packs/site_styles/_scaffold.scss +0 -43
  168. data/app/pb_kits/playbook/packs/site_styles/_site-style.scss +0 -146
  169. data/app/pb_kits/playbook/packs/site_styles/docs/_all.scss +0 -10
  170. data/app/pb_kits/playbook/packs/site_styles/docs/_bg_light_doc_example.scss +0 -7
  171. data/app/pb_kits/playbook/packs/site_styles/docs/_code_snippet.scss +0 -531
  172. data/app/pb_kits/playbook/packs/site_styles/docs/_color_utilities.scss +0 -92
  173. data/app/pb_kits/playbook/packs/site_styles/docs/_flex_examples.scss +0 -15
  174. data/app/pb_kits/playbook/packs/site_styles/docs/_kit_doc.scss +0 -132
  175. data/app/pb_kits/playbook/packs/site_styles/docs/_kits_examples.scss +0 -15
  176. data/app/pb_kits/playbook/packs/site_styles/docs/_markdown.scss +0 -88
  177. data/app/pb_kits/playbook/packs/site_styles/docs/_spacing_tokens.scss +0 -72
  178. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.jsx +0 -13
  179. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.md +0 -1
  180. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_size.html.erb +0 -11
  181. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_size.jsx +0 -44
  182. data/app/views/layouts/playbook/_mobile_hamburger.html.erb +0 -2
  183. data/app/views/layouts/playbook/_nav.html.erb +0 -34
  184. data/app/views/layouts/playbook/_sidebar.html.erb +0 -51
  185. data/app/views/layouts/playbook/application.html.erb +0 -26
  186. data/app/views/layouts/playbook/fullscreen.html.slim +0 -10
  187. data/app/views/layouts/playbook/grid.html.slim +0 -10
  188. data/app/views/layouts/playbook/samples.html.erb +0 -19
  189. data/app/views/playbook/guides/create_kit.html.slim +0 -16
  190. data/app/views/playbook/guides/create_kit/_file_naming.html.md +0 -2
  191. data/app/views/playbook/guides/create_kit/_generator.html.md +0 -6
  192. data/app/views/playbook/guides/create_kit/_kit_examples.html.md +0 -2
  193. data/app/views/playbook/guides/create_kit/_kit_rails.html.md +0 -2
  194. data/app/views/playbook/guides/create_kit/_kit_react.html.md +0 -2
  195. data/app/views/playbook/guides/create_kit/_layout.html.md +0 -2
  196. data/app/views/playbook/guides/create_kit/_view_objects.html.md +0 -2
  197. data/app/views/playbook/guides/create_kit/_writing_sass.md +0 -10
  198. data/app/views/playbook/guides/use_nitro.html.slim +0 -6
  199. data/app/views/playbook/guides/use_nitro/_local.html.md +0 -2
  200. data/app/views/playbook/guides/use_nitro/_nitro_components.html.md +0 -2
  201. data/app/views/playbook/guides/use_nitro/_versions.html.md +0 -2
  202. data/app/views/playbook/pages/fullscreen.html.slim +0 -10
  203. data/app/views/playbook/pages/grid.html.slim +0 -2
  204. data/app/views/playbook/pages/home.html.slim +0 -4
  205. data/app/views/playbook/pages/kit_category_show.html.erb +0 -14
  206. data/app/views/playbook/pages/kit_show.html.erb +0 -33
  207. data/app/views/playbook/pages/kits.html.erb +0 -12
  208. data/app/views/playbook/pages/principals/_getting_started.html.md +0 -30
  209. data/app/views/playbook/pages/principles.html.slim +0 -3
  210. data/app/views/playbook/pages/tokens.html.slim +0 -15
  211. data/app/views/playbook/pages/tokens/_pb_doc_spacing.html.slim +0 -61
  212. data/app/views/playbook/pages/utilities.html.slim +0 -116
  213. data/app/views/playbook/pages/utilities/_pb_doc_color.html.slim +0 -15
  214. data/app/views/playbook/samples/collection_detail/index.html.erb +0 -169
  215. data/app/views/playbook/samples/collection_detail/index.jsx +0 -372
  216. data/app/views/playbook/samples/dashboards/index.html.erb +0 -81
  217. data/app/views/playbook/samples/dashboards/index.jsx +0 -130
  218. data/app/views/playbook/samples/filter_table/index.html.erb +0 -348
  219. data/app/views/playbook/samples/filter_table/index.jsx +0 -433
  220. data/app/views/playbook/samples/registration/index.html.erb +0 -316
  221. data/app/views/playbook/samples/registration/index.jsx +0 -476
  222. data/app/views/playbook/samples/sample_show.html.erb +0 -36
@@ -2,55 +2,53 @@
2
2
 
3
3
  $color_checkbox_success: $data_1;
4
4
  $color_checkbox_default: $border_light;
5
- $transition: .2s cubic-bezier(0.95, 0.05, 0.795, 0.035);
6
- $toggle_sizes: (
7
- "sm": 50px,
8
- "md": 60px,
9
- );
5
+ $transition: .2s ease-in-out;
10
6
 
11
7
  [class^=pb_toggle_kit] {
12
8
  position: relative;
9
+ $width: 44px;
10
+ $height: $width/2;
11
+ $border_success: 3px solid $color_checkbox_success;
12
+ $border_default: 3px solid $color_checkbox_default;
13
13
 
14
- @each $name, $size in $toggle_sizes {
15
- &[class*=_#{$name}] {
16
14
 
17
- $width: $size;
18
- $height: $width/2;
19
-
20
- .pb_toggle_wrapper {
21
- .pb_toggle_control {
22
- cursor: pointer;
23
- transition: $transition;
24
- width: $width;
25
- height: $height;
26
- display: block;
27
- border-radius: $height;
28
- border: 3px solid $color_checkbox_default;
29
- background-color: $color_checkbox_default;
30
- position: relative;
31
- box-sizing: content-box;
32
- &:after {
33
- transition: $transition;
34
- content: "";
35
- width: $width/2;
36
- height: $height;
37
- display: block;
38
- background-color: $white;
39
- border-radius: 50%;
40
- position: absolute;
41
- top: 0;
42
- left: 0;
43
- }
15
+ .pb_toggle_wrapper {
16
+ .pb_toggle_control {
17
+ cursor: pointer;
18
+ transition: $transition;
19
+ width: $width;
20
+ height: $height;
21
+ display: block;
22
+ border-radius: $height;
23
+ border: $border_default;
24
+ position: relative;
25
+ box-sizing: content-box;
26
+ &:after {
27
+ transition: $transition;
28
+ content: "";
29
+ width: $width/2 - 4px;
30
+ height: $height - 4px;
31
+ background-color: $color_checkbox_default;
32
+ border-radius: 50%;
33
+ position: absolute;
34
+ top: 2px;
35
+ left: 2px;
36
+ }
37
+ &:hover {
38
+ border: $border_success;
39
+ &:after{
40
+ background-color: $color_checkbox_success;
44
41
  }
45
- input {
46
- display: none;
47
- &:checked + .pb_toggle_control {
48
- border-color: $color_checkbox_success;
49
- background-color: $color_checkbox_success;
50
- &:after{
51
- left: $width/2;
52
- }
53
- }
42
+ }
43
+ }
44
+ input {
45
+ display: none;
46
+ &:checked + .pb_toggle_control {
47
+ border: $border_success;
48
+ background-color: $color_checkbox_success;
49
+ &:after{
50
+ left: $width/2 + 2px;
51
+ background-color: $white;
54
52
  }
55
53
  }
56
54
  }
@@ -2,14 +2,12 @@ examples:
2
2
 
3
3
  rails:
4
4
  - toggle_default: Default State
5
- - toggle_size: Sizes
6
5
  - toggle_name: Name and Value
7
6
  - toggle_custom: Custom checkbox input
8
7
  - toggle_custom_radio: Custom radio inputs
9
8
 
10
9
  react:
11
10
  - toggle_default: Default State
12
- - toggle_size: Sizes
13
11
  - toggle_name: Name and Value
14
12
  - toggle_custom: Custom checkbox input
15
13
  - toggle_custom_radio: Custom radio inputs
@@ -1,5 +1,4 @@
1
1
  export { default as ToggleDefault } from './_toggle_default'
2
- export { default as ToggleSize } from './_toggle_size'
3
2
  export { default as ToggleCustom } from './_toggle_custom'
4
3
  export { default as ToggleName } from './_toggle_name'
5
4
  export { default as ToggleCustomRadio } from './_toggle_custom_radio'
@@ -16,7 +16,7 @@ module Playbook
16
16
  prop :name
17
17
  prop :size, type: Playbook::Props::Enum,
18
18
  values: %w[sm md],
19
- default: "md"
19
+ default: "sm"
20
20
  prop :value
21
21
 
22
22
  def classname
@@ -0,0 +1,60 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import Select from 'react-select'
5
+ import AsyncSelect from 'react-select/async'
6
+
7
+ import Control from './components/Control'
8
+ import IndicatorsContainer from './components/IndicatorsContainer'
9
+ import MenuList from './components/MenuList'
10
+ import MultiValue from './components/MultiValue'
11
+ import Option from './components/Option'
12
+ import Placeholder from './components/Placeholder'
13
+ import ValueContainer from './components/ValueContainer'
14
+
15
+ /**
16
+ * @typedef {object} Props
17
+ * @prop {boolean} async - whether Typeahead should fetch data from
18
+ * a remote location to populate the options
19
+ * @prop {string} label - the text for the optional typeahead input label
20
+ */
21
+
22
+ type Props = {
23
+ async?: boolean,
24
+ label?: string,
25
+ }
26
+
27
+ /**
28
+ * @constant {React.ReactComponent} Typeahead
29
+ * @param {Props} props - props as described at https://react-select.com/props
30
+ */
31
+
32
+ const Typeahead = (props: Props) => {
33
+ const selectProps = {
34
+ cacheOptions: true,
35
+ defaultOptions: true,
36
+ components: {
37
+ Control,
38
+ IndicatorsContainer,
39
+ IndicatorSeparator: null,
40
+ MenuList,
41
+ MultiValue,
42
+ Option,
43
+ Placeholder,
44
+ ValueContainer,
45
+ },
46
+ isClearable: true,
47
+ isSearchable: true,
48
+ ...props,
49
+ }
50
+
51
+ const Tag = props.async ? AsyncSelect : Select
52
+
53
+ return (
54
+ <div className="pb_typeahead_kit react-select">
55
+ <Tag {...selectProps} />
56
+ </div>
57
+ )
58
+ }
59
+
60
+ export default Typeahead
@@ -1,5 +1,7 @@
1
1
  @import "../tokens/colors";
2
2
  @import "../tokens/border_radius";
3
+ @import "../tokens/spacing";
4
+ @import "../tokens/shadows";
3
5
 
4
6
  [class^=pb_typeahead_kit] {
5
7
  .pb_typeahead_wrapper {
@@ -17,8 +19,10 @@
17
19
  }
18
20
 
19
21
  [class^=pb_text_input_kit] {
20
- .text_input_wrapper > input:first-child {
21
- padding-right: $space_xl;
22
+ .text_input_wrapper {
23
+ & > input:first-child {
24
+ padding-right: $space_xl;
25
+ }
22
26
  }
23
27
  }
24
28
 
@@ -31,7 +35,7 @@
31
35
  }
32
36
  }
33
37
  }
34
-
38
+
35
39
  [class^=pb_list_kit] {
36
40
  max-height: 18em;
37
41
  overflow-y: auto;
@@ -86,4 +90,17 @@
86
90
  color: $text_dk_light;
87
91
  }
88
92
  }
93
+
94
+ &.react-select {
95
+ .text_input {
96
+ display: inherit;
97
+ padding: 3px 4px;
98
+ &_indicators {
99
+ max-width: 70px;
100
+ }
101
+ &_value_container {
102
+ flex-grow: 1;
103
+ }
104
+ }
105
+ }
89
106
  }
@@ -0,0 +1,30 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ import {
7
+ Flex,
8
+ TextInput,
9
+ } from '../..'
10
+
11
+ type Props = {
12
+ selectProps: any,
13
+ }
14
+
15
+ const TypeaheadControl = (props: Props) => (
16
+ <div className="pb_typeahead_wrapper">
17
+ <TextInput
18
+ label={props.selectProps.label}
19
+ >
20
+ <Flex>
21
+ <components.Control
22
+ className="text_input"
23
+ {...props}
24
+ />
25
+ </Flex>
26
+ </TextInput>
27
+ </div>
28
+ )
29
+
30
+ export default TypeaheadControl
@@ -0,0 +1,13 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ const IndicatorsContainer = (props: any) => (
7
+ <components.IndicatorsContainer
8
+ className="text_input_indicators"
9
+ {...props}
10
+ />
11
+ )
12
+
13
+ export default IndicatorsContainer
@@ -0,0 +1,12 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ const MenuList = (props: any) => (
7
+ <components.MenuList {...props}>
8
+ {props.children}
9
+ </components.MenuList>
10
+ )
11
+
12
+ export default MenuList
@@ -0,0 +1,51 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ import { FormPill } from '../../'
7
+
8
+ type Props = {
9
+ data: object,
10
+ multiValueTemplate: any,
11
+ removeProps: any,
12
+ selectProps: any,
13
+ }
14
+
15
+ const MultiValue = (props: Props) => {
16
+ const {
17
+ data,
18
+ removeProps,
19
+ selectProps,
20
+ } = props
21
+
22
+ const handleOnClick = () => {
23
+ if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(data)
24
+ removeProps.onClick()
25
+ }
26
+ const { imageUrl, label } = data
27
+
28
+ return (
29
+ <components.MultiValueContainer
30
+ className="text_input_multivalue_container"
31
+ {...props}
32
+ >
33
+ <If condition={imageUrl}>
34
+ <FormPill
35
+ avatarUrl={imageUrl}
36
+ marginRight="xs"
37
+ name={label}
38
+ onClick={handleOnClick}
39
+ />
40
+ <Else />
41
+ <FormPill
42
+ marginRight="xs"
43
+ onClick={handleOnClick}
44
+ text={label}
45
+ />
46
+ </If>
47
+ </components.MultiValueContainer>
48
+ )
49
+ }
50
+
51
+ export default MultiValue
@@ -0,0 +1,34 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ import {
7
+ User,
8
+ } from '../../'
9
+
10
+ const Option = (props: any) => {
11
+ const {
12
+ imageUrl,
13
+ label,
14
+ } = props.data
15
+ return (
16
+ <components.Option {...props}>
17
+ <Choose>
18
+ <When condition={imageUrl}>
19
+ <User
20
+ align="left"
21
+ avatarUrl={imageUrl}
22
+ name={label}
23
+ orientation="horizontal"
24
+ />
25
+ </When>
26
+ <When condition={!imageUrl}>
27
+ {label}
28
+ </When>
29
+ </Choose>
30
+ </components.Option>
31
+ )
32
+ }
33
+
34
+ export default Option
@@ -0,0 +1,13 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ const Placeholder = (props: any) => (
7
+ <components.IndicatorsContainer
8
+ className="placeholder"
9
+ {...props}
10
+ />
11
+ )
12
+
13
+ export default Placeholder
@@ -0,0 +1,13 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ const ValueContainer = (props: Props) => (
7
+ <components.ValueContainer
8
+ className="text_input_value_container"
9
+ {...props}
10
+ />
11
+ )
12
+
13
+ export default ValueContainer
@@ -0,0 +1,22 @@
1
+ // @flow
2
+
3
+ import React from 'react'
4
+ import { Typeahead } from '../../'
5
+
6
+ const options = [
7
+ { label: 'Orange', value: '#FFA500' },
8
+ { label: 'Red', value: '#FF0000' },
9
+ { label: 'Green', value: '#00FF00' },
10
+ { label: 'Blue', value: '#0000FF' },
11
+ ]
12
+
13
+ const TypeaheadDefault = () => {
14
+ return (
15
+ <Typeahead
16
+ label="Colors"
17
+ options={options}
18
+ />
19
+ )
20
+ }
21
+
22
+ export default TypeaheadDefault
@@ -0,0 +1,29 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { Typeahead } from '../..'
5
+
6
+ const options = [
7
+ { label: 'Windows', value: '#FFA500' },
8
+ { label: 'Siding', value: '#FF0000' },
9
+ { label: 'Doors', value: '#00FF00' },
10
+ { label: 'Roofs', value: '#0000FF' },
11
+ ]
12
+
13
+ import TypeaheadWithPillsSummary from './_typeahead_with_pills_summary'
14
+
15
+ const TypeaheadWithPills = () => {
16
+ return (
17
+ <>
18
+ <TypeaheadWithPillsSummary />
19
+ <Typeahead
20
+ isMulti
21
+ label="Colors"
22
+ options={options}
23
+ placeholder=""
24
+ />
25
+ </>
26
+ )
27
+ }
28
+
29
+ export default TypeaheadWithPills