playbook_ui 13.11.1 → 13.12.0.pre.alpha.PLAY1051removinghighchartsdependency1551

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +36 -32
  3. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +67 -63
  4. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.rb +3 -1
  5. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.html.erb +22 -0
  6. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls.md +3 -0
  7. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.html.erb +40 -0
  8. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_external_controls_multiple.md +1 -0
  9. data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +2 -0
  10. data/app/pb_kits/playbook/pb_collapsible/index.js +4 -0
  11. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +57 -46
  12. data/app/pb_kits/playbook/pb_icon/docs/_icon_border_swift.md +7 -0
  13. data/app/pb_kits/playbook/pb_icon/docs/_icon_default_swift.md +7 -0
  14. data/app/pb_kits/playbook/pb_icon/docs/_icon_flip_swift.md +11 -0
  15. data/app/pb_kits/playbook/pb_icon/docs/_icon_props_swift.md +8 -0
  16. data/app/pb_kits/playbook/pb_icon/docs/_icon_rotate_swift.md +11 -0
  17. data/app/pb_kits/playbook/pb_icon/docs/_icon_sizes_swift.md +46 -0
  18. data/app/pb_kits/playbook/pb_icon/docs/example.yml +8 -0
  19. data/app/pb_kits/playbook/pb_image/docs/_image_props_swift.md +7 -0
  20. data/app/pb_kits/playbook/pb_image/docs/_rounded_image_swift.md +47 -0
  21. data/app/pb_kits/playbook/pb_image/docs/_size_image_swift.md +47 -0
  22. data/app/pb_kits/playbook/pb_image/docs/_size_none_image_swift.md +15 -0
  23. data/app/pb_kits/playbook/pb_image/docs/example.yml +5 -0
  24. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_default_swift.md +11 -0
  25. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_examples_swift.md +72 -0
  26. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_details_swift.md +41 -0
  27. data/app/pb_kits/playbook/pb_label_value/docs/_label_value_props_swift.md +11 -0
  28. data/app/pb_kits/playbook/pb_label_value/docs/example.yml +6 -0
  29. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +39 -34
  30. data/app/pb_kits/playbook/pb_message/docs/_message_default_swift.md +57 -0
  31. data/app/pb_kits/playbook/pb_message/docs/_message_props_swift.md +12 -0
  32. data/app/pb_kits/playbook/pb_message/docs/example.yml +4 -0
  33. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children_swift.md +14 -0
  34. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_dashed_swift.md +7 -0
  35. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_line_swift.md +8 -0
  36. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_props_swift.md +8 -0
  37. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_text_swift.md +7 -0
  38. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical_swift.md +18 -0
  39. data/app/pb_kits/playbook/pb_section_separator/docs/example.yml +8 -0
  40. data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +4 -4
  41. data/app/pb_kits/playbook/pb_table/styles/_hover.scss +26 -2
  42. data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +1 -17
  43. data/app/pb_kits/playbook/pb_table/table_header.html.erb +4 -3
  44. data/app/pb_kits/playbook/pb_table/table_header.rb +28 -5
  45. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default_swift.md +27 -0
  46. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error_swift.md +11 -0
  47. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_props_swift.md +9 -0
  48. data/app/pb_kits/playbook/pb_textarea/docs/example.yml +5 -0
  49. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -9
  50. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  51. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default_react.jsx +0 -2
  52. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay.jsx +0 -1
  53. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.jsx +0 -1
  54. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_margin.jsx +0 -1
  55. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_selectors.html.erb +1 -1
  56. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.html.erb +39 -0
  57. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip.md +5 -0
  58. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.jsx +45 -0
  59. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_show_tooltip_react.md +3 -0
  60. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +3 -0
  61. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
  62. data/app/pb_kits/playbook/pb_tooltip/index.js +6 -0
  63. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -1
  64. data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +34 -0
  65. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +33 -28
  66. data/app/pb_kits/playbook/playbook-doc.js +1 -1
  67. data/dist/playbook-rails.js +7 -7
  68. data/lib/playbook/version.rb +2 -2
  69. metadata +40 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ee8e7e286c406057d392df39a78b5386ccab676d22aa828c988d7ee705ef968
4
- data.tar.gz: ee9a52e005b2d69eebf688975b86bb2e6690cbc36213745e099c53a9148b71f7
3
+ metadata.gz: 4a59ab1213c1c17a6ab6bfa775d7ac7edf06972be95d950e479f16b8cafc4216
4
+ data.tar.gz: cb50f83ac242358db6b9e951ba8d7fa7bfee32ff78c02eef0b0829ed5e97a0d7
5
5
  SHA512:
6
- metadata.gz: d56962a2defca43883e75b975d30829a1222671ebcc55b08258ec18d581937cd73252ee556ca113788388ff6f1dcc3952ca0f446ae1eba5c91acac03d5131e5e
7
- data.tar.gz: 2295ee61c45223e3000b277bec93ac715d0f0cd134494b2d746172f93af2d979e9edc9ef76be7bfe67a689dca148063e3bac03f4ae3050e5db05f59ea4907f76
6
+ metadata.gz: 53af5b80de72a1f40570fd93a05f1a5282d9c79cfa04b007ecfc7e04ee31bfaa27d2202467edaf02ca50ea05173faccc0fb5b2207e16cf936957eaf8bd4b3338
7
+ data.tar.gz: 287e8051ab76bba6451b8c76ba3df6d95d1d7cfd4f4de33ae82b5745345294903e40fd74510c1b740b40395d6193f5c2c24c285980b116873a381917fdd146f7
@@ -3,7 +3,6 @@ import { globalProps } from "../utilities/globalProps";
3
3
  import { buildAriaProps, buildDataProps } from "../utilities/props";
4
4
 
5
5
  import HighchartsReact from "highcharts-react-official";
6
- import Highcharts from "highcharts";
7
6
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
8
7
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
9
8
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
@@ -11,32 +10,31 @@ import mapColors from "../pb_dashboard/pbChartsColorsHelper";
11
10
  import classnames from "classnames";
12
11
 
13
12
  type BarGraphProps = {
14
- align?: "left" | "right" | "center";
15
- axisTitle: string;
16
- dark?: boolean;
17
- xAxisCategories: [];
18
- yAxisMin: number;
19
- yAxisMax: number;
20
- chartData: { name: string; data: number[] }[];
21
- className?: string;
22
- id: any;
23
- pointStart: number | any;
24
- subTitle?: string;
25
- title: string;
26
- type?: string;
27
- legend?: boolean;
28
- toggleLegendClick?: boolean;
29
- height?: string;
30
- colors: string[];
31
- layout?: "horizontal" | "vertical" | "proximate";
32
- verticalAlign?: "top" | "middle" | "bottom";
33
- x?: number;
34
- y?: number;
35
- aria?: { [key: string]: string };
36
- data?: { [key: string]: string };
13
+ align?: "left" | "right" | "center",
14
+ axisTitle: string,
15
+ dark?: boolean,
16
+ xAxisCategories: [],
17
+ yAxisMin: number,
18
+ yAxisMax: number,
19
+ chartData: { name: string, data: number[] }[],
20
+ className?: string,
21
+ id: any,
22
+ pointStart: number | any,
23
+ subTitle?: string,
24
+ title: string,
25
+ type?: string,
26
+ legend?: boolean,
27
+ toggleLegendClick?: boolean,
28
+ height?: string,
29
+ colors: string[],
30
+ layout?: "horizontal" | "vertical" | "proximate",
31
+ verticalAlign?: "top" | "middle" | "bottom",
32
+ x?: number,
33
+ y?: number,
34
+ aria?: { [key: string]: string },
35
+ data?: { [key: string]: string },
37
36
  };
38
37
 
39
-
40
38
  const BarGraph = ({
41
39
  aria = {},
42
40
  data = {},
@@ -65,12 +63,6 @@ const BarGraph = ({
65
63
  }: BarGraphProps): React.ReactElement => {
66
64
  const ariaProps = buildAriaProps(aria);
67
65
  const dataProps = buildDataProps(data);
68
- const setupTheme = () => {
69
- dark
70
- ? Highcharts.setOptions(highchartsDarkTheme)
71
- : Highcharts.setOptions(highchartsTheme);
72
- };
73
- setupTheme();
74
66
 
75
67
  const staticOptions = {
76
68
  title: {
@@ -123,12 +115,24 @@ const BarGraph = ({
123
115
  }
124
116
 
125
117
  const [options, setOptions] = useState({});
118
+ const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false)
126
119
 
127
120
  useEffect(() => {
128
121
  setOptions({ ...staticOptions });
122
+
123
+ const interval = setInterval(() => {
124
+ if (window.Highcharts) {
125
+ clearInterval(interval)
126
+ dark
127
+ ? window.Highcharts.setOptions(highchartsDarkTheme)
128
+ : window.Highcharts.setOptions(highchartsTheme)
129
+ setIsHighchartsLoaded(true)
130
+ }
131
+ }, 0)
129
132
  }, [chartData]);
130
133
 
131
134
  return (
135
+ isHighchartsLoaded &&
132
136
  <HighchartsReact
133
137
  containerProps={{
134
138
  className: classnames(globalProps(props), className),
@@ -136,7 +140,7 @@ const BarGraph = ({
136
140
  ...ariaProps,
137
141
  ...dataProps,
138
142
  }}
139
- highcharts={Highcharts}
143
+ highcharts={window.Highcharts}
140
144
  options={options}
141
145
  />
142
146
  );
@@ -3,8 +3,6 @@ import classnames from "classnames";
3
3
  import HighchartsReact from "highcharts-react-official";
4
4
  import highchartsMore from "highcharts/highcharts-more";
5
5
 
6
- import Highcharts from "highcharts";
7
-
8
6
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
9
7
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
10
8
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
@@ -12,35 +10,35 @@ import { globalProps } from "../utilities/globalProps";
12
10
  import { buildAriaProps, buildDataProps } from "../utilities/props";
13
11
 
14
12
  type CircleChartProps = {
15
- align?: "left" | "right" | "center";
16
- aria: { [key: string]: string };
17
- chartData?: [];
18
- children?: Node;
19
- className?: string;
20
- colors?: string[];
21
- dark?: Boolean;
22
- data?: Object;
23
- dataLabelHtml?: string;
24
- dataLabels?: boolean;
25
- height?: string;
26
- id?: string;
27
- innerSize?: "sm" | "md" | "lg" | "none";
28
- legend?: boolean;
29
- maxPointSize?: number;
30
- minPointSize?: number;
31
- rounded?: boolean;
32
- startAngle?: number;
33
- style?: string;
34
- title?: string;
35
- tooltipHtml: string;
36
- useHtml?: boolean;
37
- zMin?: number;
38
- layout?: "horizontal" | "vertical" | "proximate";
39
- verticalAlign?: "top" | "middle" | "bottom";
40
- x?: number;
41
- y?: number;
42
- borderColor?: string;
43
- borderWidth?: number;
13
+ align?: "left" | "right" | "center",
14
+ aria: { [key: string]: string },
15
+ chartData?: [],
16
+ children?: Node,
17
+ className?: string,
18
+ colors?: string[],
19
+ dark?: Boolean,
20
+ data?: Object,
21
+ dataLabelHtml?: string,
22
+ dataLabels?: boolean,
23
+ height?: string,
24
+ id?: string,
25
+ innerSize?: "sm" | "md" | "lg" | "none",
26
+ legend?: boolean,
27
+ maxPointSize?: number,
28
+ minPointSize?: number,
29
+ rounded?: boolean,
30
+ startAngle?: number,
31
+ style?: string,
32
+ title?: string,
33
+ tooltipHtml: string,
34
+ useHtml?: boolean,
35
+ zMin?: number,
36
+ layout?: "horizontal" | "vertical" | "proximate",
37
+ verticalAlign?: "top" | "middle" | "bottom",
38
+ x?: number,
39
+ y?: number,
40
+ borderColor?: string,
41
+ borderWidth?: number,
44
42
  };
45
43
 
46
44
  // Adjust Circle Chart Block Kit Dimensions to Match the Chart for Centering
@@ -90,29 +88,11 @@ const CircleChart = ({
90
88
  }: CircleChartProps) => {
91
89
  const ariaProps = buildAriaProps(aria);
92
90
  const dataProps = buildDataProps(data);
93
- highchartsMore(Highcharts);
94
-
95
- const setupTheme = () => {
96
- dark
97
- ? Highcharts.setOptions(highchartsDarkTheme)
98
- : Highcharts.setOptions(highchartsTheme);
99
- };
100
- setupTheme();
101
-
102
- Highcharts.setOptions({
103
- tooltip: {
104
- headerFormat: null,
105
- pointFormat: tooltipHtml ? tooltipHtml : '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' + "<b>{point.y}</b>",
106
- useHTML: useHtml,
107
- },
108
- });
109
-
110
91
  const innerSizes = { sm: "35%", md: "50%", lg: "85%", none: "0%" };
111
- const innerSizeFormat = (size: "sm" | "md" | "lg" | "none") =>
112
- innerSizes[size];
113
-
92
+ const innerSizeFormat = (size: "sm" | "md" | "lg" | "none") => innerSizes[size];
114
93
 
115
94
  const [options, setOptions] = useState({});
95
+ const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
116
96
 
117
97
  useEffect(() => {
118
98
  const formattedChartData = chartData.map((obj: any) => {
@@ -169,26 +149,50 @@ const CircleChart = ({
169
149
  credits: false,
170
150
  };
171
151
  setOptions({ ...staticOptions });
172
- }, [chartData]);
173
152
 
153
+ const interval = setInterval(() => {
154
+ if (window.Highcharts) {
155
+ clearInterval(interval)
156
+ dark
157
+ ? window.Highcharts.setOptions(highchartsDarkTheme)
158
+ : window.Highcharts.setOptions(highchartsTheme)
159
+
160
+ highchartsMore(window.Highcharts);
161
+
162
+ window.Highcharts.setOptions({
163
+ tooltip: {
164
+ headerFormat: null,
165
+ pointFormat: tooltipHtml ? tooltipHtml : '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' + "<b>{point.y}</b>",
166
+ useHTML: useHtml,
167
+ },
168
+ });
169
+
170
+ setIsHighchartsLoaded(true)
171
+ }
172
+ }, 0)
173
+ }, [chartData]);
174
174
 
175
175
  return (
176
176
  <>
177
177
  {children ? (
178
178
  <div id={`wrapper-circle-chart-${id}`}>
179
- <HighchartsReact
180
- containerProps={{
181
- className: classnames("pb_circle_chart", globalProps(props)),
182
- id: id,
183
- ...ariaProps,
184
- ...dataProps,
185
- }}
186
- highcharts={Highcharts}
187
- options={options}
188
- />
179
+ {
180
+ isHighchartsLoaded &&
181
+ <HighchartsReact
182
+ containerProps={{
183
+ className: classnames("pb_circle_chart", globalProps(props)),
184
+ id: id,
185
+ ...ariaProps,
186
+ ...dataProps,
187
+ }}
188
+ highcharts={window.Highcharts}
189
+ options={options}
190
+ />
191
+ }
189
192
  <div className="pb-circle-chart-block">{children}</div>
190
193
  </div>
191
194
  ) : (
195
+ isHighchartsLoaded &&
192
196
  <HighchartsReact
193
197
  containerProps={{
194
198
  className: classnames("pb_circle_chart", globalProps(props)),
@@ -196,7 +200,7 @@ const CircleChart = ({
196
200
  ...ariaProps,
197
201
  ...dataProps,
198
202
  }}
199
- highcharts={Highcharts}
203
+ highcharts={window.Highcharts}
200
204
  options={options}
201
205
  />
202
206
  )}
@@ -3,6 +3,8 @@
3
3
  module Playbook
4
4
  module PbCollapsible
5
5
  class CollapsibleContent < Playbook::KitBase
6
+ prop :collapsed, type: Playbook::Props::Boolean,
7
+ default: true
6
8
  def data
7
9
  Hash(values[:data]).merge(
8
10
  collapsible_content: true
@@ -10,7 +12,7 @@ module Playbook
10
12
  end
11
13
 
12
14
  def classname
13
- generate_classname("pb_collapsible_content_kit", "toggle-content", padding, separator: " ")
15
+ generate_classname("pb_collapsible_content_kit", "toggle-content", collapsed ? nil : "is-visible", padding, separator: " ")
14
16
  end
15
17
  end
16
18
  end
@@ -0,0 +1,22 @@
1
+ <div onclick="toggleCollapsibleById('collapsed-toggle')">
2
+ <%= pb_rails("button", props: { text: "Toggle Collapsible", variant:"link"}) %>
3
+ </div>
4
+
5
+ <%= pb_rails("collapsible", props: { name: "default-example" }) do %>
6
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "md", name: "default-main"}) do %>
7
+ <%= pb_rails("body", props: { text: "Main Section"}) %>
8
+ <% end %>
9
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md", collapsed: false, id:"collapsed-toggle" }) do %>
10
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis, risus a fringilla luctus, sapien eros sodales ex, quis molestie est nulla non turpis. Vestibulum aliquet at ipsum eget posuere. Morbi sed laoreet erat. Sed commodo posuere lectus, at porta nulla ornare a. Suspendisse quam est, sollicitudin ut enim sit amet, commodo placerat enim. Donec laoreet metus ac mauris pellentesque mattis. Pellentesque luctus vel mauris non aliquam. Mauris hendrerit mattis porttitor. Curabitur vehicula justo non ex consectetur commodo. Quisque posuere aliquet quam. Maecenas malesuada magna mauris, ac tempor metus euismod at.
11
+ <br><br>
12
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
13
+ <% end %>
14
+ <% end %>
15
+
16
+
17
+
18
+ <script>
19
+ const toggleCollapsibleById = (id) => {
20
+ document.dispatchEvent(new CustomEvent(id));
21
+ };
22
+ </script>
@@ -0,0 +1,3 @@
1
+ The `collapsed` prop (boolean; default = true) handles the collapsed state of a collapsible. Set it to 'false' and the collapsible will render in an expanded state on page load.
2
+
3
+ You can also control the collapsed state using an external control (like a button). To do this, you must first apply a unique id to the collapsible/collapsible_content child element. You can then attach an eventListner to the external control of your choice, pass it the id as an argument and use `document.dispatchEvent(new CustomEvent(id))` to trigger the action. See the code example below for details.
@@ -0,0 +1,40 @@
1
+ <%= pb_rails("button", props: { variant:"link", text: "Toggle All", id: "toggle-button-example"}) %>
2
+
3
+ <%= pb_rails("collapsible", props: { name: "default-example" }) do %>
4
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "xs", name: "default-main"}) do %>
5
+ <%= pb_rails("body", props: { text: "Main Section"}) %>
6
+ <% end %>
7
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md", id:"collapse-toggle-1" }) do %>
8
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
9
+ <% end %>
10
+ <% end %>
11
+ <%= pb_rails("collapsible", props: { name: "default-example-2" }) do %>
12
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "xs", name: "default-main"}) do %>
13
+ <%= pb_rails("body", props: { text: "Main Section"}) %>
14
+ <% end %>
15
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md", id:"collapse-toggle-2" }) do %>
16
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
17
+ <% end %>
18
+ <% end %>
19
+ <%= pb_rails("collapsible", props: { name: "default-example-3" }) do %>
20
+ <%= pb_rails("collapsible/collapsible_main", props: { padding: "xs", name: "default-main"}) do %>
21
+ <%= pb_rails("body", props: { text: "Main Section"}) %>
22
+ <% end %>
23
+ <%= pb_rails("collapsible/collapsible_content", props: { padding: "md", id:"collapse-toggle-3" }) do %>
24
+ Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
25
+ <% end %>
26
+ <% end %>
27
+
28
+
29
+
30
+ <script>
31
+ window.addEventListener('DOMContentLoaded', () => {
32
+ const collapsibles = document.querySelectorAll('[id^="collapse-toggle"]');
33
+ const button = document.querySelector("#toggle-button-example");
34
+ button.addEventListener("click", () => {
35
+ collapsibles.forEach(collapsible => {
36
+ document.dispatchEvent(new CustomEvent(collapsible.id));
37
+ })
38
+ })
39
+ })
40
+ </script>
@@ -0,0 +1 @@
1
+ The external control functionality can also be used to toggle multiple collapsibles with the same control. See the code example below to see this in action.
@@ -5,6 +5,8 @@ examples:
5
5
  - collapsible_size: Icon Size
6
6
  - collapsible_color: Icon Color
7
7
  - collapsible_icons: Custom Icons
8
+ - collapsible_external_controls: Toggle Collapsible With External Controls
9
+ - collapsible_external_controls_multiple: Toggle All Collapsibles With One Control
8
10
 
9
11
  react:
10
12
  - collapsible_default: Default
@@ -15,6 +15,10 @@ export default class PbCollapsible extends PbEnhancedElement {
15
15
  this.toggleElement(this.target)
16
16
  })
17
17
  this.displayDownArrow()
18
+ // Listen for a custom event to toggle the collapsible
19
+ document.addEventListener(`${this.target.id}`, () => {
20
+ this.toggleElement(this.target)
21
+ })
18
22
  }
19
23
 
20
24
  get target() {
@@ -1,7 +1,6 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import classnames from "classnames";
3
3
  import HighchartsReact from "highcharts-react-official";
4
- import Highcharts from "highcharts";
5
4
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
6
5
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
7
6
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
@@ -14,26 +13,26 @@ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
14
13
  import { globalProps } from "../utilities/globalProps";
15
14
 
16
15
  type GaugeProps = {
17
- aria: { [key: string]: string };
18
- className?: string;
19
- chartData?: { name: string; value: number[] | number }[];
20
- dark?: Boolean;
21
- data?: { [key: string]: string };
22
- disableAnimation?: boolean;
23
- fullCircle?: boolean;
24
- height?: string;
25
- id?: string;
26
- max?: number;
27
- min?: number;
28
- prefix?: string;
29
- showLabels?: boolean;
30
- style?: string;
31
- suffix?: string;
32
- title?: string;
33
- tooltipHtml?: string;
34
- colors: string[];
35
- minorTickInterval: any;
36
- circumference: number[];
16
+ aria: { [key: string]: string },
17
+ className?: string,
18
+ chartData?: { name: string, value: number[] | number }[],
19
+ dark?: Boolean,
20
+ data?: { [key: string]: string },
21
+ disableAnimation?: boolean,
22
+ fullCircle?: boolean,
23
+ height?: string,
24
+ id?: string,
25
+ max?: number,
26
+ min?: number,
27
+ prefix?: string,
28
+ showLabels?: boolean,
29
+ style?: string,
30
+ suffix?: string,
31
+ title?: string,
32
+ tooltipHtml?: string,
33
+ colors: string[],
34
+ minorTickInterval: any,
35
+ circumference: number[],
37
36
  };
38
37
 
39
38
  const Gauge = ({
@@ -62,28 +61,13 @@ const Gauge = ({
62
61
  }: GaugeProps) => {
63
62
  const ariaProps = buildAriaProps(aria);
64
63
  const dataProps = buildDataProps(data);
65
- highchartsMore(Highcharts);
66
- solidGauge(Highcharts);
67
- const setupTheme = () => {
68
- dark
69
- ? Highcharts.setOptions(highchartsDarkTheme)
70
- : Highcharts.setOptions(highchartsTheme);
71
- };
72
- setupTheme();
73
-
74
- //set tooltip directly to prevent being overriden by Highcharts defaults
75
- Highcharts.setOptions({
76
- tooltip: {
77
- pointFormat: tooltipHtml,
78
- followPointer: true,
79
- },
80
- });
81
64
 
82
65
  const css = buildCss({
83
66
  pb_gauge_kit: true,
84
67
  });
85
68
 
86
69
  const [options, setOptions] = useState({});
70
+ const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
87
71
 
88
72
  useEffect(() => {
89
73
  const formattedChartData = chartData.map((obj: any) => {
@@ -174,18 +158,45 @@ const Gauge = ({
174
158
 
175
159
  setOptions({ ...staticOptions });
176
160
 
177
- if (document.querySelector(".prefix")) {
178
- document.querySelectorAll(".prefix").forEach((prefix) => {
179
- prefix.setAttribute("y", "28");
180
- });
181
- document
182
- .querySelectorAll(".fix")
183
- .forEach((fix) => fix.setAttribute("y", "38"));
184
- }
161
+ const interval = setInterval(() => {
162
+ if (window.Highcharts) {
163
+ clearInterval(interval)
164
+
165
+ const gaugeInterval = setInterval(() => {
166
+ if (document.querySelector(".prefix")) {
167
+ clearInterval(gaugeInterval)
168
+ document.querySelectorAll(".prefix").forEach((prefix) => {
169
+ prefix.setAttribute("y", "28");
170
+ });
171
+ document
172
+ .querySelectorAll(".fix")
173
+ .forEach((fix) => fix.setAttribute("y", "38"));
174
+ }
175
+ }, 0)
176
+
177
+ dark
178
+ ? window.Highcharts.setOptions(highchartsDarkTheme)
179
+ : window.Highcharts.setOptions(highchartsTheme)
180
+
181
+ highchartsMore(window.Highcharts);
182
+ solidGauge(window.Highcharts);
183
+
184
+ //set tooltip directly to prevent being overriden by window.Highcharts defaults
185
+ window.Highcharts.setOptions({
186
+ tooltip: {
187
+ pointFormat: tooltipHtml,
188
+ followPointer: true,
189
+ },
190
+ });
191
+
192
+ setIsHighchartsLoaded(true)
193
+ }
194
+ }, 0)
185
195
 
186
196
  }, [chartData]);
187
197
 
188
198
  return (
199
+ isHighchartsLoaded &&
189
200
  <HighchartsReact
190
201
  containerProps={{
191
202
  className: classnames(css, globalProps(props)),
@@ -193,7 +204,7 @@ const Gauge = ({
193
204
  ...ariaProps,
194
205
  ...dataProps,
195
206
  }}
196
- highcharts={Highcharts}
207
+ highcharts={window.Highcharts}
197
208
  options={options}
198
209
  />
199
210
  );
@@ -0,0 +1,7 @@
1
+ ![card-border](https://github.com/powerhome/playbook/assets/92755007/442640c8-1b4f-455d-8517-5ca5cd120664)
2
+
3
+ ```swift
4
+
5
+ PBIcon(FontAwesome.user, border: true)
6
+
7
+ ```
@@ -0,0 +1,7 @@
1
+ ![card-default](https://github.com/powerhome/playbook/assets/92755007/8c7e5454-1d42-4d13-9107-ffc5773a136a)
2
+
3
+ ```swift
4
+
5
+ PBIcon.fontAwesome(.user, size: .x1)
6
+
7
+ ```
@@ -0,0 +1,11 @@
1
+ ![icon-flipped](https://github.com/powerhome/playbook/assets/92755007/2776fb83-942d-4a38-9dff-9dcb73940dfe)
2
+
3
+ ```swift
4
+
5
+ HStack(spacing: Spacing.xSmall) {
6
+ PBIcon(FontAwesome.questionCircle, flipped: [.horizontal])
7
+ PBIcon(FontAwesome.questionCircle, flipped: [.vertical])
8
+ PBIcon(FontAwesome.questionCircle, flipped: [.horizontal, .vertical])
9
+ }
10
+
11
+ ```
@@ -0,0 +1,8 @@
1
+ ### Props
2
+ | Name | Type | Description | Default | Values |
3
+ | --- | ----------- | --------- | --------- | --------- |
4
+ | **Icon** | `PlaybookGenericIcon` | Sets the kit's Icon | | |
5
+ | **Size** | `IconSize` | Changes the size of the Icon | `.x1` | `xSmall` `small` `large` `x1` `x2` `x3` `x4` `x5` `x6` `x7` `x8` `x9` `x10` |
6
+ | **Rotation** | `IconRotation` | Rotates the Icon | `.zero` | `.zero` `.right` `.straight` `.obtuse` |
7
+ | **Border** | `Bool` | Adds a border | `false` | `true` `false` |
8
+ | **Flipped** | `[Axis]` | Flips the Icon | `nil` | `[.horizontal]` `[.vertical]` `[.horizontal, .vertical]` |
@@ -0,0 +1,11 @@
1
+ ![icon-rotate](https://github.com/powerhome/playbook/assets/92755007/29a6c127-a8a0-4dd9-a8cb-6401f772f11e)
2
+
3
+ ```swift
4
+
5
+ HStack(spacing: Spacing.xSmall) {
6
+ PBIcon(FontAwesome.user, rotation: .right)
7
+ PBIcon(FontAwesome.user, rotation: .zero)
8
+ PBIcon(FontAwesome.user, rotation: .obtuse)
9
+ }
10
+
11
+ ```
@@ -0,0 +1,46 @@
1
+ ![icon-size](https://github.com/powerhome/playbook/assets/92755007/b3aa3933-56b1-4fe4-bb8b-00d786abb23a)
2
+
3
+ ```swift
4
+
5
+ HStack(spacing: Spacing.xSmall) {
6
+ PBIcon.fontAwesome(.atlas, size: .xSmall)
7
+ Text("xSmall")
8
+
9
+ PBIcon.fontAwesome(.atlas, size: .small)
10
+ Text("small")
11
+
12
+ PBIcon.fontAwesome(.atlas, size: .large)
13
+ Text("large")
14
+
15
+ PBIcon.fontAwesome(.atlas, size: .x1)
16
+ Text("x1")
17
+
18
+ PBIcon.fontAwesome(.atlas, size: .x2)
19
+ Text("x2")
20
+
21
+ PBIcon.fontAwesome(.atlas, size: .x3)
22
+ Text("x3")
23
+
24
+ PBIcon.fontAwesome(.atlas, size: .x4)
25
+ Text("x4")
26
+
27
+ PBIcon.fontAwesome(.atlas, size: .x5)
28
+ Text("x5")
29
+
30
+ PBIcon.fontAwesome(.atlas, size: .x6)
31
+ Text("x6")
32
+
33
+ PBIcon.fontAwesome(.atlas, size: .x7)
34
+ Text("x7")
35
+
36
+ PBIcon.fontAwesome(.atlas, size: .x8)
37
+ Text("x8")
38
+
39
+ PBIcon.fontAwesome(.atlas, size: .x9)
40
+ Text("x9")
41
+
42
+ PBIcon.fontAwesome(.atlas, size: .x10)
43
+ Text("x10")
44
+ }
45
+
46
+ ```