playbook_ui 13.28.0.pre.alpha.play829selectablecardalignment2978 → 13.29.0.pre.alpha.PBNTR329draggablev33059

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -3
  3. data/app/pb_kits/playbook/index.js +2 -0
  4. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +4 -1
  5. data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +31 -0
  6. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +16 -0
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +2 -1
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/{_bar_graph_custom.html.erb → _bar_graph_custom_rails.html.erb} +3 -3
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom_rails.md +2 -0
  10. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -1
  11. data/app/pb_kits/playbook/pb_card/_card.scss +5 -0
  12. data/app/pb_kits/playbook/pb_card/_card.tsx +56 -9
  13. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +9 -3
  14. data/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js +45 -0
  15. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +24 -1
  16. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +53 -0
  17. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +14 -8
  18. data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +24 -0
  19. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +7 -1
  20. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +9 -1
  21. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +13 -0
  22. data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +53 -0
  23. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +92 -0
  24. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +53 -0
  25. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +4 -0
  26. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +158 -0
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +101 -0
  28. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +50 -0
  29. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +1 -0
  30. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +51 -0
  31. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +11 -0
  32. data/app/pb_kits/playbook/pb_draggable/docs/index.js +5 -0
  33. data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +63 -0
  34. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +54 -0
  35. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +57 -0
  36. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +2 -2
  37. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +4 -1
  38. data/app/pb_kits/playbook/pb_gauge/gauge.rb +6 -1
  39. data/app/pb_kits/playbook/pb_gauge/gauge.test.js +35 -0
  40. data/app/pb_kits/playbook/pb_icon/icon.rb +3 -2
  41. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +8 -2
  42. data/app/pb_kits/playbook/pb_line_graph/lineGraph.test.js +52 -0
  43. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +22 -1
  44. data/app/pb_kits/playbook/pb_list/_list.tsx +43 -2
  45. data/app/pb_kits/playbook/pb_list/_list_item.tsx +46 -10
  46. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +1 -1
  47. data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +35 -28
  48. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +5 -1
  49. data/app/pb_kits/playbook/pb_table/_table.tsx +5 -0
  50. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column.jsx +33 -32
  51. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column.md +1 -1
  52. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column_rails.md +2 -0
  53. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row.jsx +33 -33
  54. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row.md +1 -1
  55. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row_rails.html.erb +34 -0
  56. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row_rails.md +2 -0
  57. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.jsx +51 -50
  58. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.md +1 -1
  59. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data_rails.html.erb +54 -0
  60. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data_rails.md +2 -0
  61. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.jsx +37 -38
  62. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.md +1 -0
  63. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row_rails.html.erb +53 -0
  64. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row_rails.md +1 -0
  65. data/app/pb_kits/playbook/pb_table/docs/{_table_alignment_row.html.erb → _table_outer_padding.html.erb} +7 -7
  66. data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.jsx +76 -0
  67. data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.md +1 -0
  68. data/app/pb_kits/playbook/pb_table/docs/example.yml +9 -9
  69. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  70. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  71. data/app/pb_kits/playbook/pb_table/styles/_outer_padding.scss +21 -0
  72. data/app/pb_kits/playbook/pb_table/table.rb +14 -1
  73. data/app/pb_kits/playbook/pb_table/table.test.js +5 -1
  74. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +12 -9
  75. data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +61 -0
  76. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +6 -1
  77. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  78. data/app/pb_kits/playbook/tokens/_vertical_align.scss +18 -0
  79. data/app/pb_kits/playbook/utilities/_vertical_align.scss +16 -0
  80. data/app/pb_kits/playbook/utilities/globalProps.ts +12 -1
  81. data/dist/menu.yml +5 -2
  82. data/dist/playbook-rails.js +7 -7
  83. data/lib/playbook/classnames.rb +1 -0
  84. data/lib/playbook/kit_base.rb +2 -0
  85. data/lib/playbook/version.rb +2 -2
  86. data/lib/playbook/vertical_align.rb +37 -0
  87. metadata +41 -7
  88. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.html.erb +0 -63
  89. data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.html.erb +0 -52
  90. /data/app/pb_kits/playbook/pb_table/docs/{_table_alignment_column.html.erb → _table_alignment_column_rails.html.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2ea0b161920a1666fef468539f56e8185b902f0fe7b31969a8ee2d761a64b59
4
- data.tar.gz: 2a85f19f34fea779816b46739f34f643fa2def667bce1194e678a32f0eb67e0d
3
+ metadata.gz: 15e8f4bc66591135abee36bd3c787bba5634a05f9946a633b65f30442b6b67ed
4
+ data.tar.gz: 746c09e0b3ff3376ee961b903fc843a2fbba545b68eb5ded7cdcf491e264d654
5
5
  SHA512:
6
- metadata.gz: f383ffb93e9d97358349b13cc4f3a282b140ecc628fba9c097dd652ba6c0a824efaa1f796b932b165cd38b326899d0c6875d96b6f731858824bbdf42687d956f
7
- data.tar.gz: ea09734e0f9abbc10a328f6b5e5b0c8248f1df495dc33abf14ea96cfb2f90e97aeb92f6e6ec0512fe2ffa3212fb4c8543cf9a187afd3e84c383a0f0b93a87f41
6
+ metadata.gz: 847a815f0747e139ae0b55e187a6c19e1e351e69f202ad55f832254375b4a64b87ffa14f9ac5f534a80e391904c57de7c793b5762e0a5cea4094e1fc04e3190e
7
+ data.tar.gz: 55b27592b147d0b565538a7fc0f4441b3663074413e2e4e78d97510511a3f634f92d530866780953121b9dc5e710464677a1bf5fa75045568dda50c48e9407a1
@@ -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_avatar_action_button/avatar_action_button';
@@ -31,6 +28,7 @@
31
28
  @import 'pb_detail/detail';
32
29
  @import 'pb_dialog/dialog';
33
30
  @import 'pb_distribution_bar/distribution_bar';
31
+ @import 'pb_draggable/draggable';
34
32
  @import 'pb_dropdown/dropdown';
35
33
  @import 'pb_file_upload/file_upload';
36
34
  @import 'pb_filter/filter';
@@ -121,3 +119,4 @@
121
119
  @import './utilities/text_align';
122
120
  @import './utilities/overflow';
123
121
  @import './utilities/truncate';
122
+ @import './utilities/vertical_align';
@@ -35,6 +35,8 @@ export { default as DateYearStacked } from './pb_date_year_stacked/_date_year_st
35
35
  export { default as Detail} from './pb_detail/_detail'
36
36
  export { default as Dialog } from './pb_dialog/_dialog'
37
37
  export { default as DistributionBar } from './pb_distribution_bar/_distribution_bar'
38
+ export { default as Draggable} from './pb_draggable/_draggable'
39
+ export { DraggableProvider} from './pb_draggable/context'
38
40
  export { default as Dropdown} from './pb_dropdown/_dropdown'
39
41
  export { default as FileUpload } from './pb_file_upload/_file_upload'
40
42
  export { default as Filter } from './pb_filter/_filter'
@@ -163,6 +163,9 @@ if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
163
163
  staticOptions.plotOptions.series.events = { legendItemClick: () => false };
164
164
  }
165
165
 
166
+ const filteredProps: any = {...props};
167
+ delete filteredProps.verticalAlign;
168
+
166
169
  const [options, setOptions] = useState({});
167
170
 
168
171
  useEffect(() => {
@@ -172,7 +175,7 @@ if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
172
175
  return (
173
176
  <HighchartsReact
174
177
  containerProps={{
175
- className: classnames(globalProps(props), className),
178
+ className: classnames(globalProps(filteredProps), className),
176
179
  id: id,
177
180
  ...ariaProps,
178
181
  ...dataProps,
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { render, screen } from '../utilities/test-utils';
3
+ import BarGraph from './_bar_graph';
4
+
5
+ beforeEach(() => {
6
+ // Silences error logs within the test suite.
7
+ jest.spyOn(console, 'error');
8
+ jest.spyOn(console, 'warn');
9
+ console.error.mockImplementation(() => {});
10
+ console.warn.mockImplementation(() => {});
11
+ });
12
+
13
+ afterEach(() => {
14
+ console.error.mockRestore();
15
+ console.warn.mockRestore();
16
+ });
17
+
18
+ const testId = 'bargraph1';
19
+
20
+ test('bargraph uses exact classname', () => {
21
+ render(
22
+ <BarGraph
23
+ className='super_important_class'
24
+ data={{ testid: testId }}
25
+ id='bar-default'
26
+ />
27
+ );
28
+
29
+ const kit = screen.getByTestId(testId);
30
+ expect(kit).toHaveClass('super_important_class');
31
+ });
@@ -74,6 +74,22 @@ module Playbook
74
74
  standard_options.deep_merge(custom_options)
75
75
  end
76
76
 
77
+ def vertical_align_props
78
+ if vertical_align
79
+ if object.vertical_align
80
+ original_result = super
81
+ class_to_remove = "vertical_align_#{object.vertical_align}"
82
+
83
+ modified_result = original_result.gsub(class_to_remove, "").strip
84
+ modified_result.empty? ? nil : modified_result
85
+ else
86
+ super
87
+ end
88
+ else
89
+ super
90
+ end
91
+ end
92
+
77
93
  def classname
78
94
  generate_classname("pb_bar_graph")
79
95
  end
@@ -1 +1,2 @@
1
- See https://api.highcharts.com/highcharts/ for a comprehensive list of available options.
1
+ The `customOptions` prop provides comprehensive access to additional [Highcharts options](https://api.highcharts.com/highcharts/) that are not explicitly defined as props.
2
+ It's important to note that certain options may require specific script imports to function properly.
@@ -15,7 +15,7 @@
15
15
  data: [1111,677,3245,500,200]
16
16
  }] %>
17
17
 
18
- <% custom_options = {
18
+ <% bar_graph_options = {
19
19
  customOptions: {
20
20
  subtitle: {
21
21
  text: "Overwritten subtitle",
@@ -45,5 +45,5 @@
45
45
  y_axis_min: 0,
46
46
  subtitle: 'Subtitle to replace',
47
47
  title: 'Bar Graph with Custom Overrides',
48
- custom_options: custom_options
49
- }) %>
48
+ custom_options: bar_graph_options
49
+ }) %>
@@ -0,0 +1,2 @@
1
+ The `custom_options` prop provides comprehensive access to additional [Highcharts options](https://api.highcharts.com/highcharts/) that are not explicitly defined as props.
2
+ It's important to note that certain options may require specific script imports to function properly.
@@ -8,7 +8,7 @@ examples:
8
8
  - bar_graph_height: Height
9
9
  - bar_graph_spline: Spline
10
10
  - bar_graph_colors: Color Overrides
11
- - bar_graph_custom: Custom Overrides
11
+ - bar_graph_custom_rails: Custom Overrides
12
12
  - bar_graph_stacked: Stacked
13
13
  - bar_graph_negative_numbers: Negative Numbers
14
14
  - bar_graph_secondary_y_axis: Secondary Y-Axis
@@ -81,4 +81,9 @@
81
81
  }
82
82
  }
83
83
  }
84
+
85
+ .card_draggable_handle {
86
+ align-self: center;
87
+ color: $text_lt_light;
88
+ }
84
89
  }
@@ -8,6 +8,10 @@ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../uti
8
8
  import { GlobalProps, globalProps } from '../utilities/globalProps'
9
9
  import type { ProductColors, CategoryColors, BackgroundColors } from '../types/colors'
10
10
 
11
+ import Icon from '../pb_icon/_icon'
12
+ import Flex from '../pb_flex/_flex'
13
+ import Draggable from '../pb_draggable/_draggable'
14
+
11
15
  type CardPropTypes = {
12
16
  aria?: {[key: string]: string},
13
17
  background?: BackgroundColors | ProductColors | "none",
@@ -16,11 +20,14 @@ type CardPropTypes = {
16
20
  children: React.ReactChild[] | React.ReactChild | number,
17
21
  className?: string,
18
22
  data?: {[key: string]: string},
23
+ draggableItem?: boolean,
24
+ dragHandle?: boolean,
19
25
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
20
26
  highlight?: {
21
27
  position?: "side" | "top",
22
28
  color?: string,
23
29
  },
30
+ id?: string,
24
31
  length?: number,
25
32
  padding?: string,
26
33
  selected?: boolean,
@@ -78,8 +85,11 @@ const Card = (props: CardPropTypes): React.ReactElement => {
78
85
  children,
79
86
  className,
80
87
  data = {},
88
+ dragHandle = false,
89
+ draggableItem = false,
81
90
  highlight = {},
82
91
  htmlOptions = {},
92
+ id,
83
93
  selected = false,
84
94
  tag = 'div',
85
95
  } = props
@@ -113,15 +123,52 @@ const Card = (props: CardPropTypes): React.ReactElement => {
113
123
  const Tag = tagOptions.includes(tag) ? tag : 'div'
114
124
 
115
125
  return (
116
- <Tag
117
- {...ariaProps}
118
- {...dataProps}
119
- {...htmlProps}
120
- className={classnames(cardCss, globalProps(props), className)}
121
- >
122
- {subComponentTags('Header')}
123
- {nonHeaderChildren}
124
- </Tag>
126
+ <>
127
+ {
128
+ draggableItem ? (
129
+ <Draggable.Item id={id}
130
+ key={id}
131
+ >
132
+ <Tag
133
+ {...ariaProps}
134
+ {...dataProps}
135
+ {...htmlProps}
136
+ className={classnames(cardCss, globalProps(props), className)}
137
+ >
138
+ {subComponentTags('Header')}
139
+ {
140
+ dragHandle ? (
141
+ <Flex>
142
+ <span className="card_draggable_handle">
143
+ <Icon
144
+ icon="grip-dots-vertical"
145
+ paddingRight="xs"
146
+ verticalAlign="middle"
147
+ />
148
+ </span>
149
+ <div>
150
+ {nonHeaderChildren}
151
+ </div>
152
+ </Flex>
153
+ ) : (
154
+ nonHeaderChildren
155
+ )
156
+ }
157
+ </Tag>
158
+ </Draggable.Item>
159
+ ) : (
160
+ <Tag
161
+ {...ariaProps}
162
+ {...dataProps}
163
+ {...htmlProps}
164
+ className={classnames(cardCss, globalProps(props), className)}
165
+ >
166
+ {subComponentTags('Header')}
167
+ {nonHeaderChildren}
168
+ </Tag>
169
+ )
170
+ }
171
+ </>
125
172
  )
126
173
  }
127
174
 
@@ -10,6 +10,7 @@ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
10
10
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
11
11
  import { globalProps } from "../utilities/globalProps";
12
12
  import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
13
+ import { merge } from 'lodash'
13
14
 
14
15
  type CircleChartProps = {
15
16
  align?: "left" | "right" | "center";
@@ -18,6 +19,7 @@ type CircleChartProps = {
18
19
  children?: Node;
19
20
  className?: string;
20
21
  colors?: string[];
22
+ customOptions?: Partial<Highcharts.Options>;
21
23
  dark?: boolean;
22
24
  data?: {[key: string]: string},
23
25
  dataLabelHtml?: string;
@@ -67,6 +69,7 @@ const CircleChart = ({
67
69
  children,
68
70
  className,
69
71
  colors = [],
72
+ customOptions = {},
70
73
  dark = false,
71
74
  data = {},
72
75
  dataLabelHtml = "<div>{point.name}</div>",
@@ -115,6 +118,9 @@ const CircleChart = ({
115
118
  innerSizes[size];
116
119
 
117
120
 
121
+ const filteredProps: any = {...props};
122
+ delete filteredProps.verticalAlign;
123
+
118
124
  const [options, setOptions] = useState({});
119
125
 
120
126
  useEffect(() => {
@@ -171,7 +177,7 @@ const CircleChart = ({
171
177
  ],
172
178
  credits: false,
173
179
  };
174
- setOptions({ ...staticOptions });
180
+ setOptions(merge(staticOptions, customOptions));
175
181
  }, [chartData]);
176
182
 
177
183
 
@@ -181,7 +187,7 @@ const CircleChart = ({
181
187
  <div id={`wrapper-circle-chart-${id}`}>
182
188
  <HighchartsReact
183
189
  containerProps={{
184
- className: classnames("pb_circle_chart", globalProps(props)),
190
+ className: classnames("pb_circle_chart", globalProps(filteredProps)),
185
191
  id: id,
186
192
  ...ariaProps,
187
193
  ...dataProps,
@@ -195,7 +201,7 @@ const CircleChart = ({
195
201
  ) : (
196
202
  <HighchartsReact
197
203
  containerProps={{
198
- className: classnames("pb_circle_chart", globalProps(props)),
204
+ className: classnames("pb_circle_chart", globalProps(filteredProps)),
199
205
  id: id,
200
206
  ...ariaProps,
201
207
  ...dataProps,
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { render, screen } from '../utilities/test-utils';
3
+ import CircleChart from './_circle_chart';
4
+
5
+ beforeEach(() => {
6
+ // Silences error logs within the test suite.
7
+ jest.spyOn(console, 'error');
8
+ jest.spyOn(console, 'warn');
9
+ console.error.mockImplementation(() => {});
10
+ console.warn.mockImplementation(() => {});
11
+ });
12
+
13
+ afterEach(() => {
14
+ console.error.mockRestore();
15
+ console.warn.mockRestore();
16
+ });
17
+
18
+ const testId = 'circlechart1';
19
+
20
+ test('uses exact classname', () => {
21
+ const data = [
22
+ {
23
+ name: 'Waiting for Calls',
24
+ value: 41,
25
+ },
26
+ {
27
+ name: 'On Call',
28
+ value: 49,
29
+ },
30
+ {
31
+ name: 'After call',
32
+ value: 10,
33
+ },
34
+ ]
35
+ render(
36
+ <CircleChart
37
+ chartData={data}
38
+ data={{ testid: testId }}
39
+ id='circlechartid'
40
+ />
41
+ );
42
+
43
+ const kit = screen.getByTestId(testId);
44
+ expect(kit).toHaveClass('pb_circle_chart');
45
+ });
@@ -6,8 +6,10 @@ module Playbook
6
6
  prop :align, type: Playbook::Props::Enum,
7
7
  values: %w[left right center],
8
8
  default: "center"
9
+ prop :border_width, type: Playbook::Props::Numeric
9
10
  prop :chart_data, type: Playbook::Props::Array,
10
11
  default: []
12
+ prop :custom_options, default: {}
11
13
  prop :style, type: Playbook::Props::Enum,
12
14
  values: %w[pie],
13
15
  default: "pie"
@@ -40,9 +42,10 @@ module Playbook
40
42
  prop :x, type: Playbook::Props::Numeric
41
43
  prop :y, type: Playbook::Props::Numeric
42
44
 
43
- def chart_options
45
+ def standard_options
44
46
  {
45
47
  align: align,
48
+ borderWidth: border_width,
46
49
  id: id,
47
50
  colors: colors,
48
51
  chartData: chart_data,
@@ -68,6 +71,26 @@ module Playbook
68
71
  }
69
72
  end
70
73
 
74
+ def chart_options
75
+ standard_options.deep_merge(custom_options)
76
+ end
77
+
78
+ def vertical_align_props
79
+ if vertical_align
80
+ if object.vertical_align
81
+ original_result = super
82
+ class_to_remove = "vertical_align_#{object.vertical_align}"
83
+
84
+ modified_result = original_result.gsub(class_to_remove, "").strip
85
+ modified_result.empty? ? nil : modified_result
86
+ else
87
+ super
88
+ end
89
+ else
90
+ super
91
+ end
92
+ end
93
+
71
94
  def classname
72
95
  generate_classname("pb_circle_chart")
73
96
  end
@@ -0,0 +1,53 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`html structure is correct 1`] = `
4
+ <div>
5
+ <div
6
+ class="pb_collapsible_kit additional_class"
7
+ data-testid="collapsible1"
8
+ >
9
+ <div
10
+ class="pb_collapsible_main_kit cursor_pointer"
11
+ >
12
+ <div>
13
+ <div
14
+ class="pb_flex_kit_orientation_row_justify_content_left_align_items_center_spacing_between"
15
+ >
16
+ <div
17
+ class="pb_flex_item_kit"
18
+ >
19
+ <div>
20
+ Main Section
21
+ </div>
22
+ </div>
23
+ <div
24
+ class="pb_flex_item_kit"
25
+ >
26
+ <div
27
+ class="icon_wrapper"
28
+ style="vertical-align: middle; color: rgb(193, 205, 214);"
29
+ >
30
+ <i
31
+ class="pb_icon_kit far fa-fw fa-lg fa-chevron-down"
32
+ />
33
+ <span
34
+ aria-label="chevron-down icon"
35
+ hidden=""
36
+ />
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <div
43
+ class="pb_collapsible_content_kit toggle-content"
44
+ data-collapsible-content="true"
45
+ style="height: 0px;"
46
+ >
47
+ <div>
48
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit. Nulla facilisi. Vestibulum quis pretium nulla. Nulla ut accumsan velit. Duis varius urna sed sem tempor, sit amet fermentum nibh auctor. Praesent lorem arcu, egestas non ante quis, placerat pellentesque lectus.Vestibulum lacinia ipsum quis venenatis tristique. Vivamus suscipit, libero eu fringilla egestas, orci urna commodo arcu, vel gravida turpis ipsum molestie nibh. Donec cursus eu ante sagittis ultrices. Phasellus id sagittis risus. Mauris dapibus neque faucibus, tempor ligula vel, cursus ante. Donec faucibus gravida porta. Nullam egestas est quis aliquam feugiat. Sed eget metus diam. Cras eget placerat libero.
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ `;
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react'
1
+ import React, { useEffect, ReactElement } from 'react'
2
2
  import classnames from 'classnames'
3
3
  import useCollapsible from './useCollapsible'
4
4
 
@@ -11,9 +11,16 @@ import CollapsibleContext from './context'
11
11
  import { IconSizes } from "../pb_icon/_icon"
12
12
  import CollapsibleIcon from './child_kits/CollapsibleIcon'
13
13
 
14
+ type CollapsibleMainProps = {
15
+ children: React.ReactNode
16
+ }
17
+
18
+ type CollapsibleContentProps = {
19
+ children: React.ReactNode
20
+ }
14
21
 
15
22
  type CollapsibleProps = {
16
- children?: React.ReactElement | [] | any,
23
+ children?: [ReactElement<CollapsibleMainProps>, ReactElement<CollapsibleContentProps>],
17
24
  aria?: {[key: string]: string},
18
25
  className?: string,
19
26
  collapsed?: boolean,
@@ -30,7 +37,7 @@ type CollapsibleProps = {
30
37
  const Collapsible = ({
31
38
  aria = {},
32
39
  className,
33
- children = [],
40
+ children,
34
41
  collapsed = true,
35
42
  data = {},
36
43
  htmlOptions = {},
@@ -48,13 +55,12 @@ const Collapsible = ({
48
55
  setIsCollapsed(collapsed)
49
56
  },[collapsed])
50
57
 
51
- const CollapsibleParent = React.Children.toArray(children) as React.ReactElement[]
52
-
53
- if (CollapsibleParent.length !== 2) {
58
+ if (children.length !== 2) {
54
59
  throw new Error('Collapsible requires <CollapsibleMain> and <CollapsibleContent> to function properly.')
55
60
  }
56
- const FirstChild = CollapsibleParent[0]
57
- const SecondChild = CollapsibleParent[1]
61
+
62
+ const FirstChild = children[0]
63
+ const SecondChild = children[1]
58
64
 
59
65
  const Main = FirstChild.type === CollapsibleMain ? FirstChild : null
60
66
  const Content = SecondChild.type === CollapsibleContent ? SecondChild : null
@@ -48,3 +48,27 @@ test('returns namespaced additional_class class name', () => {
48
48
  const kit = screen.getByTestId(testId)
49
49
  expect(kit).toHaveClass(`${kitClass} additional_class`)
50
50
  })
51
+
52
+ test('html structure is correct', () => {
53
+ const { container } = render(
54
+ <Collapsible
55
+ className="additional_class"
56
+ data={{ testid: testId }}
57
+ iconColor='lighter'
58
+ iconSize="lg"
59
+ >
60
+ <Collapsible.Main>
61
+ <div>{'Main Section'}</div>
62
+ </Collapsible.Main>
63
+ <Collapsible.Content>
64
+ <div>
65
+ {
66
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit. Nulla facilisi. Vestibulum quis pretium nulla. Nulla ut accumsan velit. Duis varius urna sed sem tempor, sit amet fermentum nibh auctor. Praesent lorem arcu, egestas non ante quis, placerat pellentesque lectus.Vestibulum lacinia ipsum quis venenatis tristique. Vivamus suscipit, libero eu fringilla egestas, orci urna commodo arcu, vel gravida turpis ipsum molestie nibh. Donec cursus eu ante sagittis ultrices. Phasellus id sagittis risus. Mauris dapibus neque faucibus, tempor ligula vel, cursus ante. Donec faucibus gravida porta. Nullam egestas est quis aliquam feugiat. Sed eget metus diam. Cras eget placerat libero.'
67
+ }
68
+ </div>
69
+ </Collapsible.Content>
70
+ </Collapsible>
71
+ )
72
+
73
+ expect(container).toMatchSnapshot()
74
+ })
@@ -3,6 +3,12 @@ import typography from '../tokens/exports/_typography.scss'
3
3
 
4
4
  import { ThemeProps } from './themeTypes'
5
5
 
6
+ interface CustomTreemapOptions extends Highcharts.SeriesTreemapOptions {
7
+ traverseUpButton?: {
8
+ position: { y: number };
9
+ };
10
+ }
11
+
6
12
  const highchartsDarkTheme: ThemeProps = {
7
13
  lang: {
8
14
  thousandsSep: ',',
@@ -200,7 +206,7 @@ const highchartsDarkTheme: ThemeProps = {
200
206
  traverseUpButton: {
201
207
  position: { y: -50 },
202
208
  },
203
- },
209
+ } as CustomTreemapOptions,
204
210
  },
205
211
  credits: {
206
212
  enabled: false
@@ -3,6 +3,13 @@ import typography from '../tokens/exports/_typography.scss'
3
3
 
4
4
  import { ThemeProps } from './themeTypes'
5
5
 
6
+ interface CustomTreemapOptions extends Highcharts.SeriesTreemapOptions {
7
+ traverseUpButton?: {
8
+ position: { y: number };
9
+ };
10
+ }
11
+
12
+
6
13
  const highchartsTheme: ThemeProps = {
7
14
  lang: {
8
15
  thousandsSep: ',',
@@ -150,6 +157,7 @@ const highchartsTheme: ThemeProps = {
150
157
  fontSize: typography.text_smaller,
151
158
  color: colors.text_lt_light,
152
159
  fontWeight: typography.regular,
160
+ textOutline: '2px $white',
153
161
  },
154
162
  },
155
163
  },
@@ -198,7 +206,7 @@ const highchartsTheme: ThemeProps = {
198
206
  traverseUpButton: {
199
207
  position: { y: -50 },
200
208
  },
201
- },
209
+ } as CustomTreemapOptions,
202
210
  },
203
211
  credits: {
204
212
  enabled: false
@@ -0,0 +1,13 @@
1
+ @import "../tokens/colors";
2
+
3
+ .pb_draggable_container {
4
+ .is_dragging {
5
+ opacity: 40%;
6
+ }
7
+ .active {
8
+ opacity: 60%;
9
+ }
10
+ .pb_draggable_item:hover {
11
+ cursor: grab;
12
+ }
13
+ }
@@ -0,0 +1,53 @@
1
+ import React from "react";
2
+ import classnames from "classnames";
3
+ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
4
+ import { globalProps } from "../utilities/globalProps";
5
+ import DraggableContainer from "./subcomponents/DraggableContainer";
6
+ import DraggableItem from "./subcomponents/DraggableItem";
7
+
8
+ type DraggableProps = {
9
+ aria?: { [key: string]: string };
10
+ className?: string;
11
+ children?: React.ReactNode;
12
+ data?: { [key: string]: string };
13
+ htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
14
+ id?: string;
15
+ };
16
+
17
+ const Draggable = (props: DraggableProps) => {
18
+ const {
19
+ aria = {},
20
+ className,
21
+ children,
22
+ data = {},
23
+ htmlOptions = {},
24
+ id,
25
+ } = props;
26
+
27
+
28
+ const ariaProps = buildAriaProps(aria);
29
+ const dataProps = buildDataProps(data);
30
+ const htmlProps = buildHtmlProps(htmlOptions);
31
+
32
+ const classes = classnames(
33
+ buildCss("pb_draggable"),
34
+ globalProps(props),
35
+ className
36
+ );
37
+
38
+ return (
39
+ <div {...ariaProps}
40
+ {...dataProps}
41
+ {...htmlProps}
42
+ className={classes}
43
+ id={id}
44
+ >
45
+ {children}
46
+ </div>
47
+ );
48
+ };
49
+
50
+ Draggable.Container = DraggableContainer;
51
+ Draggable.Item = DraggableItem;
52
+
53
+ export default Draggable;