playbook_ui 15.2.0.pre.alpha.PLAY1978bugiconauto11317 → 15.2.0.pre.alpha.PLAY236711331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +4 -6
  3. data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
  4. data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +7 -3
  5. data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +29 -0
  6. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
  7. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +8 -0
  8. data/app/pb_kits/playbook/pb_dropdown/index.js +1 -1
  9. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_icon/_icon.tsx +2 -1
  11. data/app/pb_kits/playbook/pb_icon/icon.rb +2 -1
  12. data/app/pb_kits/playbook/pb_list/item.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +8 -6
  14. data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +7 -10
  15. data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +73 -1
  16. data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
  17. data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +7 -10
  18. data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +47 -0
  19. data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +3 -0
  20. data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +61 -0
  21. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -0
  22. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +34 -0
  23. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +52 -0
  24. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +5 -0
  25. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +34 -0
  26. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +45 -0
  27. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +47 -0
  28. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +64 -0
  29. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +3 -0
  30. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +24 -0
  31. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +37 -0
  32. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +39 -0
  33. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +45 -0
  34. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +86 -0
  35. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +116 -0
  36. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +11 -0
  37. data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +20 -0
  38. data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +6 -0
  39. data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +125 -0
  40. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +1 -0
  41. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +25 -0
  42. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +110 -0
  43. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +105 -22
  44. data/app/pb_kits/playbook/pb_popover/docs/_popover_list.html.erb +2 -2
  45. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +1 -1
  46. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +250 -233
  47. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
  48. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
  49. data/dist/chunks/{_line_graph-B-R1nzPu.js → _line_graph-AKTV-rqw.js} +1 -1
  50. data/dist/chunks/_typeahead-DCInCM2E.js +6 -0
  51. data/dist/chunks/{_weekday_stacked-C3YxWFMB.js → _weekday_stacked-ByJl1kOQ.js} +2 -2
  52. data/dist/chunks/vendor.js +1 -1
  53. data/dist/menu.yml +6 -0
  54. data/dist/playbook-doc.js +2 -2
  55. data/dist/playbook-rails-react-bindings.js +1 -1
  56. data/dist/playbook-rails.js +1 -1
  57. data/dist/playbook.css +1 -1
  58. data/lib/playbook/version.rb +1 -1
  59. metadata +28 -4
  60. data/dist/chunks/_typeahead-DqRbRocY.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4e9805dca544c9abae71d1c12b067c3ee333a62161fe7ed82aa968c9499d4b3
4
- data.tar.gz: 3b43477f5c391da8f9dcf343702f46396c522a0794bfc51bbe03fbf21c98a865
3
+ metadata.gz: 0e2c8dffcd7defe26d6fefe13f404f679b53a467a26f19e6d0e642ea8ef8dd85
4
+ data.tar.gz: c4592d02d0338fd0b4f476c94bb2c600a0fcd3f3924ce3930758a0ee9b2e782b
5
5
  SHA512:
6
- metadata.gz: b1de16b7f90de98e7b11c7d6a217da3013ae0f540bcf46dd38b2f8b56fb0fadf5bddfdcd364b5f68b895e8237a7c9a53087a2dc6041098b09be377e3153132f6
7
- data.tar.gz: 85a61bef4066f0d3761c349fd1f9007a5ee00b82c8dd1d859bc89bbfd84bd5536f6d61dfca4f82e21a629730b939cbe84b1addc10b96dd79a35d163f6f086c9c
6
+ metadata.gz: f1e1563932e3cfc9222f98c859687fcaf69fa43ce717bfa03e1706a0360f10591682d4bca57111b816f38d83d9c4e3fe6c1af65ccb7d02293b71de67067f8640
7
+ data.tar.gz: bc8206fe7856f1f43c18957aa6bfcd609d35b04930a1ab12d9570bc1a7b0be7fd9b0524612a03e488fa35e5923aa21a601f604474089fa1d1c1861cce8971f95
@@ -1,6 +1,3 @@
1
-
2
-
3
-
4
1
  @import 'pb_advanced_table/advanced_table';
5
2
  @import 'pb_avatar/avatar';
6
3
  @import 'pb_background/background';
@@ -33,6 +30,7 @@
33
30
  @import 'pb_distribution_bar/distribution_bar';
34
31
  @import 'pb_draggable/draggable';
35
32
  @import 'pb_dropdown/dropdown';
33
+ @import 'pb_empty_state/empty_state';
36
34
  @import 'pb_file_upload/file_upload';
37
35
  @import 'pb_filter/filter';
38
36
  @import 'pb_fixed_confirmation_toast/fixed_confirmation_toast';
@@ -70,6 +68,9 @@
70
68
  @import 'pb_overlay/overlay';
71
69
  @import 'pb_pagination/pagination';
72
70
  @import 'pb_passphrase/passphrase';
71
+ @import 'pb_pb_bar_graph/pb_bar_graph';
72
+ @import 'pb_pb_circle_chart/pb_circle_chart';
73
+ @import 'pb_pb_line_graph/pb_line_graph';
73
74
  @import 'pb_person/person';
74
75
  @import 'pb_person_contact/person_contact';
75
76
  @import 'pb_phone_number_input/phone_number_input';
@@ -108,9 +109,6 @@
108
109
  @import 'pb_user/user';
109
110
  @import 'pb_user_badge/user_badge';
110
111
  @import 'pb_weekday_stacked/weekday_stacked';
111
- @import 'pb_empty_state/empty_state';
112
- @import 'pb_pb_bar_graph/pb_bar_graph';
113
- @import 'pb_pb_circle_chart/pb_circle_chart';
114
112
  @import 'utilities/mixins';
115
113
  @import 'utilities/spacing';
116
114
  @import 'utilities/cursor';
@@ -81,6 +81,12 @@ $pb_button_sizes: (
81
81
  // Loading state
82
82
  &.pb_button_loading {
83
83
  @include pb_button_loading(true);
84
+ &.pb_button_size_sm {
85
+ min-height: 30px;
86
+ }
87
+ &.pb_button_size_lg {
88
+ min-height: 45px;
89
+ }
84
90
  }
85
91
 
86
92
  // Disabled state
@@ -1,3 +1,7 @@
1
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", loading: true, margin_right: "lg" }) %>
2
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", variant: "secondary", loading: true, margin_right: "lg" }) %>
3
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", variant: "link", loading: true, margin_right: "lg" }) %>
1
+ <%= pb_rails("caption", props: { margin_y: "md", text: "Button variants with loading" }) %>
2
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, margin_right: "lg" }) %>
3
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "secondary", loading: true, margin_right: "lg" }) %>
4
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "link", loading: true, margin_right: "lg" }) %>
5
+ <%= pb_rails("caption", props: { margin_y: "md", text: "Button sizes with loading" }) %>
6
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "sm", margin_right: "lg" }) %>
7
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "lg", margin_right: "lg" }) %>
@@ -1,8 +1,13 @@
1
1
  import React from 'react'
2
2
  import Button from "../../pb_button/_button"
3
+ import Caption from "../../pb_caption/_caption"
3
4
 
4
5
  const ButtonLoading = (props) => (
5
6
  <div>
7
+ <Caption
8
+ marginY="md"
9
+ text="Button variants with loading"
10
+ />
6
11
  <Button
7
12
  aria={{ label: 'Loading' }}
8
13
  loading
@@ -31,6 +36,30 @@ const ButtonLoading = (props) => (
31
36
  variant="link"
32
37
  {...props}
33
38
  />
39
+ <br/>
40
+ <Caption
41
+ marginY="md"
42
+ text="Button sizes with loading"
43
+ />
44
+ <Button
45
+ aria={{ label: 'Loading' }}
46
+ loading
47
+ marginRight='lg'
48
+ size="sm"
49
+ tabIndex={0}
50
+ text="Small Button"
51
+ {...props}
52
+ />
53
+ {' '}
54
+ <Button
55
+ aria={{ label: 'Loading' }}
56
+ loading
57
+ marginRight='lg'
58
+ size="lg"
59
+ tabIndex={0}
60
+ text="Small Button"
61
+ {...props}
62
+ />
34
63
  </div>
35
64
  )
36
65
 
@@ -32,9 +32,9 @@ exports[`html structure is correct 1`] = `
32
32
  class="pb_custom_icon svg-inline--fa svg_lg svg_fw"
33
33
  color="currentColor"
34
34
  fill="none"
35
- height="1.5em"
35
+ height="auto"
36
36
  viewBox="0 0 30 25"
37
- width="1em"
37
+ width="auto"
38
38
  xmlns="http://www.w3.org/2000/svg"
39
39
  >
40
40
  <path
@@ -141,4 +141,12 @@
141
141
  }
142
142
  }
143
143
  }
144
+
145
+ .pb_draggable_item:has(.pb_item_kit) {
146
+ border-bottom: 1px solid $border_light;
147
+ }
148
+
149
+ .pb_draggable_item:has(.pb_item_kit):last-child {
150
+ border-bottom: none;
151
+ }
144
152
  }
@@ -522,7 +522,7 @@ export default class PbDropdown extends PbEnhancedElement {
522
522
  closeIcon.className = "pb_form_pill_close";
523
523
  closeIcon.innerHTML = `<svg class="pb_custom_icon svg-inline--fa svg_${
524
524
  this.formPillProps.size === "small" ? "xs" : "sm"
525
- } svg_fw" xmlns="http://www.w3.org/2000/svg" width="1em" viewBox="0 0 31 25"><path fill="currentColor" d="M23.0762 6.77734L17.4512 12.4023L23.0293 17.9805C23.498 18.4023 23.498 19.1055 23.0293 19.5273C22.6074 19.9961 21.9043 19.9961 21.4824 19.5273L15.8574 13.9492L10.2793 19.5273C9.85742 19.9961 9.1543 19.9961 8.73242 19.5273C8.26367 19.1055 8.26367 18.4023 8.73242 17.9336L14.3105 12.3555L8.73242 6.77734C8.26367 6.35547 8.26367 5.65234 8.73242 5.18359C9.1543 4.76172 9.85742 4.76172 10.3262 5.18359L15.9043 10.8086L21.4824 5.23047C21.9043 4.76172 22.6074 4.76172 23.0762 5.23047C23.498 5.65234 23.498 6.35547 23.0762 6.77734Z"/></svg>`;
525
+ } svg_fw" xmlns="http://www.w3.org/2000/svg" width="auto" height="auto" viewBox="0 0 31 25"><path fill="currentColor" d="M23.0762 6.77734L17.4512 12.4023L23.0293 17.9805C23.498 18.4023 23.498 19.1055 23.0293 19.5273C22.6074 19.9961 21.9043 19.9961 21.4824 19.5273L15.8574 13.9492L10.2793 19.5273C9.85742 19.9961 9.1543 19.9961 8.73242 19.5273C8.26367 19.1055 8.26367 18.4023 8.73242 17.9336L14.3105 12.3555L8.73242 6.77734C8.26367 6.35547 8.26367 5.65234 8.73242 5.18359C9.1543 4.76172 9.85742 4.76172 10.3262 5.18359L15.9043 10.8086L21.4824 5.23047C21.9043 4.76172 22.6074 4.76172 23.0762 5.23047C23.498 5.65234 23.498 6.35547 23.0762 6.77734Z"/></svg>`;
526
526
  pill.appendChild(closeIcon);
527
527
 
528
528
  closeIcon.addEventListener("click", (e) => {
@@ -101,7 +101,7 @@
101
101
  <%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %>
102
102
  <%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %>
103
103
  <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
104
- <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
104
+ <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true, required: true } %>
105
105
  <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
106
106
  <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
107
107
  <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
@@ -235,7 +235,8 @@ const Icon = (props: IconProps) => {
235
235
  ...htmlProps,
236
236
  className: classes,
237
237
  id,
238
- width: '1em',
238
+ width: 'auto',
239
+ height: 'auto',
239
240
  ...(props.tabIndex !== undefined && { tabIndex }),
240
241
  })
241
242
  }
@@ -110,7 +110,8 @@ module Playbook
110
110
  svg["class"] = %w[pb_custom_icon svg-inline--fa].concat([object.custom_icon_classname]).join(" ")
111
111
  svg["id"] = object.id
112
112
  svg["data"] = object.data
113
- svg["width"] = "1em"
113
+ svg["height"] = "auto"
114
+ svg["width"] = "auto"
114
115
  svg["tabindex"] = object.tabindex
115
116
  fill_color = object.color || "currentColor"
116
117
  doc.at_css("path")["fill"] = fill_color
@@ -11,7 +11,7 @@
11
11
  <% if object.drag_handle %>
12
12
  <span style="vertical-align: middle;">
13
13
  <%= pb_rails("body") do %>
14
- <svg width="14em" viewBox="0 0 31 25" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="pb_custom_icon svg-inline--fa vertical_align_middle svg_fw"><path d="M12.904 6.355a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm0 7.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm4.5-13.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm-1.5 9a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5z" fill="#242B42"></path></svg>
14
+ <svg width="auto" height="auto" viewBox="0 0 31 25" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="pb_custom_icon svg-inline--fa vertical_align_middle svg_fw"><path d="M12.904 6.355a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm0 7.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm4.5-13.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm-1.5 9a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5z" fill="#242B42"></path></svg>
15
15
  <% end %>
16
16
  </span>
17
17
  <% end %>
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo } from "react"
2
2
  import { globalProps } from "../utilities/globalProps";
3
- import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
3
+ import { buildAriaProps, buildDataProps, buildCss, buildHtmlProps } from "../utilities/props";
4
4
  import Highcharts from "highcharts"
5
5
  import HighchartsReact from "highcharts-react-official"
6
6
 
@@ -18,23 +18,25 @@ type PbBarGraphProps = {
18
18
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)};
19
19
  }
20
20
 
21
- const PbBarGraph = ({
21
+ const PbBarGraph = ( props: PbBarGraphProps): React.ReactElement => {
22
+ const {
22
23
  aria = {},
23
24
  data = {},
24
25
  id,
25
26
  htmlOptions = {},
26
27
  options,
27
- className = "pb_pb_bar_graph",
28
- }: PbBarGraphProps): React.ReactElement => {
28
+ className,
29
+ } = props
29
30
 
30
31
  const ariaProps = buildAriaProps(aria);
31
32
  const dataProps = buildDataProps(data)
32
33
  const htmlProps = buildHtmlProps(htmlOptions);
34
+ const classes = classnames(buildCss('pb_pb_bar_graph'), globalProps(props), className)
33
35
 
34
36
  const mergedOptions = useMemo(() => {
35
37
  if (!options || typeof options !== "object") {
36
38
  // eslint-disable-next-line no-console
37
- console.error("❌ Invalid options passed to <BarGraph />", options)
39
+ console.error("❌ Invalid options passed to <PbBarGraph />", options)
38
40
  return {}
39
41
  }
40
42
 
@@ -46,7 +48,7 @@ const PbBarGraph = ({
46
48
  <div>
47
49
  <HighchartsReact
48
50
  containerProps={{
49
- className: classnames(globalProps, className),
51
+ className: classnames(classes),
50
52
  id: id,
51
53
  ...ariaProps,
52
54
  ...dataProps,
@@ -4,24 +4,21 @@ module Playbook
4
4
  module PbPbBarGraph
5
5
  class PbBarGraph < ::Playbook::KitBase
6
6
  prop :options, default: {}
7
- prop :container_props, default: {}
8
7
 
9
8
  def react_props
10
9
  {
10
+ className: classname,
11
+ data: data,
11
12
  options: options,
12
- containerProps: container_props_hash,
13
+ id: id,
13
14
  }
14
15
  end
15
16
 
16
- def container_props_hash
17
- container_props.merge({
18
- id: id,
19
- className: classname,
20
- }).compact
21
- end
22
-
23
17
  def classname
24
- generate_classname("pb_pb_bar_graph")
18
+ # Highcharts react needs classname attached to the container div,
19
+ # we pass an empty string here to avoid conflicts, classname is built in the TSX
20
+ # We still need generate_classnames to retain ability to pass in custom classnames or global props
21
+ generate_classname("")
25
22
  end
26
23
  end
27
24
  end
@@ -15,6 +15,41 @@ afterEach(() => {
15
15
  console.warn.mockRestore();
16
16
  });
17
17
 
18
+ const chartData = [{
19
+ name: 'Installation',
20
+ data: [1475, 200, 3000, 654, 656],
21
+ }, {
22
+ name: 'Manufacturing',
23
+ data: [4434, 524, 2320, 440, 500],
24
+ }, {
25
+ name: 'Sales & Distribution',
26
+ data: [3387, 743, 1344, 434, 440],
27
+ }, {
28
+ name: 'Project Development',
29
+ data: [3227, 878, 999, 780, 1000],
30
+ }, {
31
+ name: 'Other',
32
+ data: [1111, 677, 3245, 500, 200],
33
+ }]
34
+
35
+ const chartOptions = {
36
+ series: chartData,
37
+ title: {
38
+ text: 'Solar Employment Growth by Sector, 2010-2016',
39
+ },
40
+ subtitle: {
41
+ text: 'Source: thesolarfoundation.com',
42
+ },
43
+ xAxis: {
44
+ categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
45
+ },
46
+ yAxis: {
47
+ title: {
48
+ text: 'Number of Employees',
49
+ },
50
+ },
51
+ }
52
+
18
53
  const testId = 'bargraph1';
19
54
 
20
55
  test('bargraph uses exact classname', () => {
@@ -23,9 +58,46 @@ test('bargraph uses exact classname', () => {
23
58
  className='super_important_class'
24
59
  data={{ testid: testId }}
25
60
  id='bar-default'
61
+ options={chartOptions}
26
62
  />
27
63
  );
28
64
 
29
65
  const kit = screen.getByTestId(testId);
30
66
  expect(kit).toHaveClass('super_important_class');
31
- });
67
+ });
68
+
69
+ test('Kit to apply base classname', () => {
70
+ render(
71
+ <PbBarGraph
72
+ data={{testid: testId}}
73
+ options={chartOptions}
74
+ />
75
+ )
76
+
77
+ expect(screen.getByTestId(testId)).toHaveClass('pb_pb_bar_graph')
78
+ })
79
+
80
+
81
+ test('Kit to apply global props', () => {
82
+ render(
83
+ <PbBarGraph
84
+ data={{testid: testId}}
85
+ margin="lg"
86
+ options={chartOptions}
87
+ />
88
+ )
89
+
90
+ expect(screen.getByTestId(testId)).toHaveClass('m_lg')
91
+ })
92
+
93
+ test('kit to apply id', () => {
94
+ render(
95
+ <PbBarGraph
96
+ data={{testid: testId}}
97
+ id='bar-graph-id'
98
+ options={chartOptions}
99
+ />
100
+ )
101
+
102
+ expect(screen.getByTestId(testId)).toHaveAttribute('id', 'bar-graph-id')
103
+ })
@@ -46,7 +46,7 @@ const PbCircleChart = (props: PbCircleChartProps) => {
46
46
  <div>
47
47
  <HighchartsReact
48
48
  containerProps={{
49
- className: classnames(globalProps, className),
49
+ className: classnames(classes),
50
50
  id: id,
51
51
  ...ariaProps,
52
52
  ...dataProps,
@@ -4,24 +4,21 @@ module Playbook
4
4
  module PbPbCircleChart
5
5
  class PbCircleChart < ::Playbook::KitBase
6
6
  prop :options, default: {}
7
- prop :container_props, default: {}
8
7
 
9
8
  def react_props
10
9
  {
10
+ className: classname,
11
+ data: data,
11
12
  options: options,
12
- containerProps: container_props_hash,
13
+ id: id,
13
14
  }
14
15
  end
15
16
 
16
- def container_props_hash
17
- container_props.merge({
18
- id: id,
19
- className: classname,
20
- }).compact
21
- end
22
-
23
17
  def classname
24
- generate_classname("pb_pb_circle_chart")
18
+ # Highcharts react needs classname attached to the container div,
19
+ # we pass an empty string here to avoid conflicts, classname is built in the TSX
20
+ # We still need generate_classnames to retain ability to pass in custom classnames or global props
21
+ generate_classname("")
25
22
  end
26
23
  end
27
24
  end
@@ -49,3 +49,50 @@ test('Kit to exist', () => {
49
49
  expect(screen.getByTestId(testId)).toBeInTheDocument()
50
50
  })
51
51
 
52
+ test('Kit to apply base classname', () => {
53
+ render(
54
+ <PbCircleChart
55
+ data={{testid: testId}}
56
+ options={chartOptions}
57
+ />
58
+ )
59
+
60
+ expect(screen.getByTestId(testId)).toHaveClass('pb_pb_circle_chart')
61
+ })
62
+
63
+ test('Kit to have custom class', () => {
64
+ render(
65
+ <PbCircleChart
66
+ className='custom-class'
67
+ data={{testid: testId}}
68
+ options={chartOptions}
69
+ />
70
+ )
71
+
72
+ expect(screen.getByTestId(testId)).toHaveClass('custom-class')
73
+ })
74
+
75
+ test('Kit to apply global props', () => {
76
+ render(
77
+ <PbCircleChart
78
+ data={{testid: testId}}
79
+ margin="lg"
80
+ options={chartOptions}
81
+ />
82
+ )
83
+
84
+ expect(screen.getByTestId(testId)).toHaveClass('m_lg')
85
+ })
86
+
87
+ test('kit to apply id', () => {
88
+ render(
89
+ <PbCircleChart
90
+ data={{testid: testId}}
91
+ id='circle-chart-id'
92
+ options={chartOptions}
93
+ />
94
+ )
95
+
96
+ expect(screen.getByTestId(testId)).toHaveAttribute('id', 'circle-chart-id')
97
+ })
98
+
@@ -0,0 +1,3 @@
1
+ .pb_pb_line_graph {
2
+
3
+ }
@@ -0,0 +1,61 @@
1
+
2
+ import React, { useMemo } from 'react'
3
+ import classnames from 'classnames'
4
+ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
5
+ import Highcharts from "highcharts"
6
+ import HighchartsReact from "highcharts-react-official"
7
+ import pbLineGraphTheme from './pbLineGraphTheme'
8
+ import { globalProps } from '../utilities/globalProps'
9
+
10
+
11
+ type PbLineGraphProps = {
12
+ aria?: { [key: string]: string },
13
+ className?: string,
14
+ data?: { [key: string]: string },
15
+ id?: string,
16
+ htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
17
+ options: Record<string, unknown>
18
+ }
19
+
20
+ const PbLineGraph = (props: PbLineGraphProps) => {
21
+ const {
22
+ aria = {},
23
+ className,
24
+ data = {},
25
+ id,
26
+ htmlOptions = {},
27
+ options
28
+ } = props
29
+
30
+ const ariaProps = buildAriaProps(aria)
31
+ const dataProps = buildDataProps(data)
32
+ const htmlProps = buildHtmlProps(htmlOptions);
33
+ const classes = classnames(buildCss('pb_pb_line_graph'), globalProps(props), className)
34
+
35
+ const mergedOptions = useMemo(() => {
36
+ if (!options || typeof options !== "object") {
37
+ // eslint-disable-next-line no-console
38
+ console.error("❌ Invalid options passed to <PbLineGraph />", options)
39
+ return {}
40
+ }
41
+
42
+ return Highcharts.merge({}, pbLineGraphTheme, options)
43
+ }, [options])
44
+ return (
45
+ <div>
46
+ <HighchartsReact
47
+ containerProps={{
48
+ className: classnames(classes),
49
+ id: id,
50
+ ...ariaProps,
51
+ ...dataProps,
52
+ ...htmlProps
53
+ }}
54
+ highcharts={Highcharts}
55
+ options={mergedOptions}
56
+ />
57
+ </div>
58
+ )
59
+ }
60
+
61
+ export default PbLineGraph
@@ -0,0 +1,3 @@
1
+ This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specifc props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
2
+
3
+ See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
@@ -0,0 +1,34 @@
1
+ <% data = [{
2
+ name: 'Installation',
3
+ data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
4
+ }, {
5
+ name: 'Manufacturing',
6
+ data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
7
+ }, {
8
+ name: 'Sales & Distribution',
9
+ data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
10
+ }, {
11
+ name: 'Project Development',
12
+ data: [nil, nil, 7988, 12169, 15112, 22452, 34400, 34227],
13
+ }, {
14
+ name: 'Other',
15
+ data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
16
+ }] %>
17
+
18
+ <% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
19
+
20
+ <% chart_options = {
21
+ series: data,
22
+ colors: ['#1CA05C', '#FD804C', '#144075', '#00C4D7', '#DA0014'],
23
+ title: { text: "Line Graph with Custom Data Colors" },
24
+ xAxis: {
25
+ categories: categories,
26
+ },
27
+ yAxis: {
28
+ title: {
29
+ text: "Number of Employees",
30
+ },
31
+ },
32
+ } %>
33
+
34
+ <%= pb_rails("pb_line_graph", props: {options: chart_options}) %>
@@ -0,0 +1,52 @@
1
+ import React from 'react'
2
+ import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
3
+ import { colors } from 'playbook-ui'
4
+
5
+ const data = [{
6
+ name: 'Installation',
7
+ data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
8
+ }, {
9
+ name: 'Manufacturing',
10
+ data: [24916, 28064, 29742, 40851, 50590, 65282, 70121, 85434],
11
+ }, {
12
+ name: 'Sales & Distribution',
13
+ data: [11744, 17722, 16005, 19771, 25185, 28377, 36147, 43387],
14
+ }, {
15
+ name: 'Project Development',
16
+ data: [5332, 6344, 7988, 12169, 15112, 14452, 22400, 30227],
17
+ }, {
18
+ name: 'Other',
19
+ data: [null, null, null, 3112, 4989, 5816, 15274, 18111],
20
+ }]
21
+
22
+ const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
23
+
24
+ const chartOptions = {
25
+ title: {
26
+ text: 'Line Graph with Custom Data Colors',
27
+ },
28
+ xAxis: {
29
+ categories: categories,
30
+ },
31
+ yAxis: {
32
+ min: 0,
33
+ title: {
34
+ text: 'Number of Employees',
35
+ },
36
+ },
37
+ series: data,
38
+ colors: [colors.data_4, colors.data_5, "#144075", colors.data_7, colors.data_8]
39
+ }
40
+
41
+ const PbLineGraphColors = (props) => {
42
+ return (
43
+ <div>
44
+ <PbLineGraph
45
+ options={chartOptions}
46
+ {...props}
47
+ />
48
+ </div>
49
+ )
50
+ }
51
+
52
+ export default PbLineGraphColors
@@ -0,0 +1,5 @@
1
+ Custom data colors allow for color customization to match the needs of business requirements.
2
+
3
+ For React, import 'colors' from Playbook, then set custom colors in the colors array using the desired color variables. Hex colors are also available.
4
+
5
+ For Rails, HEX values are required.
@@ -0,0 +1,34 @@
1
+ <% data = [{
2
+ name: 'Installation',
3
+ data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
4
+ }, {
5
+ name: 'Manufacturing',
6
+ data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
7
+ }, {
8
+ name: 'Sales & Distribution',
9
+ data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
10
+ }, {
11
+ name: 'Project Development',
12
+ data: [nil, nil, 7988, 12169, 15112, 22452, 34400, 34227],
13
+ }, {
14
+ name: 'Other',
15
+ data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
16
+ }] %>
17
+
18
+ <% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
19
+
20
+ <% chart_options = {
21
+ series: data,
22
+ title: { text: "Solar Employment Growth by Sector, 2010-2016" },
23
+ subtitle: { text: "Source: thesolarfoundation.com" },
24
+ xAxis: {
25
+ categories: categories,
26
+ },
27
+ yAxis: {
28
+ title: {
29
+ text: "Number of Employees",
30
+ },
31
+ },
32
+ } %>
33
+
34
+ <%= pb_rails("pb_line_graph", props: {options: chart_options}) %>