playbook_ui 15.2.0.pre.alpha.testingmanual1 → 15.2.0.pre.alpha.testingquickpick11606
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +5 -5
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +39 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.html.erb +51 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.html.erb +40 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +49 -5
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +11 -30
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +8 -6
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +73 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +47 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.scss +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.tsx +69 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.html.erb +12 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +24 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +5 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.html.erb +45 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +119 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.html.erb +5 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.html.erb +12 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.jsx +24 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.html.erb +23 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +37 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.html.erb +40 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +56 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_live_data.jsx +64 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.html.erb +27 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +40 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.html.erb +19 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.jsx +65 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.md +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.html.erb +14 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.jsx +27 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.html.erb +39 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +58 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/example.yml +29 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/index.js +11 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pbGaugeGraphTheme.ts +91 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.html.erb +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.rb +25 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +80 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +61 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +52 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +5 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +47 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +64 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +24 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +37 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +39 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +86 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +116 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +11 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +20 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +125 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +25 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +110 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +41 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +60 -20
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +36 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +38 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +34 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +37 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +37 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +38 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +69 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +8 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +127 -1
- data/dist/chunks/{_line_graph-DiZsCIbc.js → _line_graph-BnVgr42C.js} +1 -1
- data/dist/chunks/_typeahead-BH_dkgOy.js +6 -0
- data/dist/chunks/{_weekday_stacked-qKBP2x1z.js → _weekday_stacked-Bz13QeMW.js} +1 -1
- data/dist/chunks/{lib-izYrkvOQ.js → lib-QZuu1ltS.js} +2 -2
- data/dist/chunks/{pb_form_validation-Cah5Z5J3.js → pb_form_validation-CleM960_.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +12 -0
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +85 -7
- data/dist/chunks/_typeahead-e_XlDkym.js +0 -6
|
@@ -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
|
|
28
|
-
}
|
|
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 <
|
|
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(
|
|
51
|
+
className: classnames(classes),
|
|
50
52
|
id: id,
|
|
51
53
|
...ariaProps,
|
|
52
54
|
...dataProps,
|
|
@@ -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 specific 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.
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
+
})
|
|
@@ -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 specific 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.
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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,69 @@
|
|
|
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 pbGaugeGraphTheme from './pbGaugeGraphTheme'
|
|
8
|
+
import highchartsMore from "highcharts/highcharts-more";
|
|
9
|
+
import solidGauge from "highcharts/modules/solid-gauge";
|
|
10
|
+
import { globalProps } from '../utilities/globalProps'
|
|
11
|
+
|
|
12
|
+
type PbGaugeChartProps = {
|
|
13
|
+
aria?: { [key: string]: string },
|
|
14
|
+
className?: string,
|
|
15
|
+
data?: { [key: string]: string },
|
|
16
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) | ((arg?: Event) => void) },
|
|
17
|
+
id?: string,
|
|
18
|
+
ref?: React.RefObject<any>,
|
|
19
|
+
options: Record<string, unknown>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const PbGaugeChart = (props: PbGaugeChartProps) => {
|
|
23
|
+
const {
|
|
24
|
+
aria = {},
|
|
25
|
+
className,
|
|
26
|
+
data = {},
|
|
27
|
+
htmlOptions = {},
|
|
28
|
+
id,
|
|
29
|
+
ref,
|
|
30
|
+
options = {},
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
const ariaProps = buildAriaProps(aria)
|
|
34
|
+
const dataProps = buildDataProps(data)
|
|
35
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
|
36
|
+
const classes = classnames(buildCss('pb_pb_gauge_chart'), globalProps(props), className)
|
|
37
|
+
|
|
38
|
+
const mergedOptions = useMemo(() => {
|
|
39
|
+
if (!options || typeof options !== "object") {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.error("❌ Invalid options passed to <PbLineGraph />", options)
|
|
42
|
+
return {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return Highcharts.merge({}, pbGaugeGraphTheme, options)
|
|
46
|
+
}, [options])
|
|
47
|
+
|
|
48
|
+
highchartsMore(Highcharts);
|
|
49
|
+
solidGauge(Highcharts);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<HighchartsReact
|
|
54
|
+
containerProps={{
|
|
55
|
+
className: classnames(classes),
|
|
56
|
+
id: id,
|
|
57
|
+
ref: ref,
|
|
58
|
+
...ariaProps,
|
|
59
|
+
...dataProps,
|
|
60
|
+
...htmlProps
|
|
61
|
+
}}
|
|
62
|
+
highcharts={Highcharts}
|
|
63
|
+
options={mergedOptions}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default PbGaugeChart
|
|
@@ -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 specific 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,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PbGaugeChart from '../../pb_pb_gauge_chart/_pb_gauge_chart'
|
|
3
|
+
import { colors } from 'playbook-ui'
|
|
4
|
+
|
|
5
|
+
const data = [{ name: "Name", y: 67 }]
|
|
6
|
+
|
|
7
|
+
const chartOptions = {
|
|
8
|
+
series: [{ data: data }],
|
|
9
|
+
plotOptions: {
|
|
10
|
+
solidgauge: {
|
|
11
|
+
borderColor: colors.data_7,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const PbGaugeChartColor = (props) => (
|
|
16
|
+
<div>
|
|
17
|
+
<PbGaugeChart
|
|
18
|
+
options={chartOptions}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export default PbGaugeChartColor
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Highcharts allows for any custom colors to be used. Custom data colors allow for color customization to match the needs of business requirements.
|
|
2
|
+
|
|
3
|
+
For React, pass the prop `plotOptions.solidgauge.borderColor` with a Playbook token like `colors.` + `data_1 | data_2 | data_3 | data_4 | data_5 | data_6 | data_7 | data_8`. HEX colors are also available `eg: #CA0095`
|
|
4
|
+
|
|
5
|
+
For Rails, the prop `plotOptions.solidgauge.borderColor` can only be used with HEX values as shown.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<% chart_options = {
|
|
2
|
+
series:[{data:[{ name: "Name", y: 10 }]}],
|
|
3
|
+
chart: {
|
|
4
|
+
height: "150",
|
|
5
|
+
},
|
|
6
|
+
plotOptions: {
|
|
7
|
+
series: {
|
|
8
|
+
animation: false,
|
|
9
|
+
},
|
|
10
|
+
solidgauge: {
|
|
11
|
+
dataLabels: {
|
|
12
|
+
format:
|
|
13
|
+
'<span class="fix">{y:,f}</span>' +
|
|
14
|
+
'<span style="fill: #687887; font-size: 27px;">%</span>',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
} %>
|
|
19
|
+
|
|
20
|
+
<%= pb_rails("flex", props: {wrap: true, padding: "xl", gap: "sm"}) do %>
|
|
21
|
+
<%= pb_rails("flex/flex_item", props: {flex: 1, grow: true }) do %>
|
|
22
|
+
<%= pb_rails("card", props: {max_width: "xs", padding: "md", }) do %>
|
|
23
|
+
<%= pb_rails("title", props: {padding_bottom: "sm", size: 4, text: "Abandoned Calls" })%>
|
|
24
|
+
<%= pb_rails("flex", props: {align: "stretch"}) do %>
|
|
25
|
+
<%= pb_rails("flex", props: {margin_right: "sm", orientation: "column"}) do %>
|
|
26
|
+
<%= pb_rails("body", props: {color: "light", padding_bottom: "sm",text: "Total Abandoned"}) %>
|
|
27
|
+
<%= pb_rails("flex", props: {align: "baseline", padding_bottom: "sx"}) do %>
|
|
28
|
+
<%= pb_rails("title", props: {size: 1, text: "39"})%>
|
|
29
|
+
<%= pb_rails("title", props: {color: "light", size: 3, text: "calls"}) %>
|
|
30
|
+
<% end %>
|
|
31
|
+
<%= pb_rails("caption", props: {size: "xs", text: "of 390" }) %>
|
|
32
|
+
<%end %>
|
|
33
|
+
<%= pb_rails("section_separator", props: {align_self: "stretch", margin_right: "sm", orientation: "vertical" }) %>
|
|
34
|
+
<%= pb_rails("flex", props: {orientation: "column", wrap: true}) do %>
|
|
35
|
+
<%= pb_rails("body", props: {color: "light", text: "% Abandoned"}) %>
|
|
36
|
+
<%= pb_rails("flex", props: {wrap: true}) do %>
|
|
37
|
+
<%= pb_rails("flex/flex_item", props: {fixed_size: "150px", overflow: "hidden", shrink: true}) do %>
|
|
38
|
+
<%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %>
|
|
39
|
+
<% end %>
|
|
40
|
+
<% end %>
|
|
41
|
+
<% end %>
|
|
42
|
+
<%end %>
|
|
43
|
+
<% end %>
|
|
44
|
+
<% end %>
|
|
45
|
+
<% end %>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PbGaugeChart from '../../pb_pb_gauge_chart/_pb_gauge_chart'
|
|
3
|
+
import Flex from '../../pb_flex/_flex'
|
|
4
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
|
5
|
+
import Card from '../../pb_card/_card'
|
|
6
|
+
import Caption from '../../pb_caption/_caption'
|
|
7
|
+
import Body from '../../pb_body/_body'
|
|
8
|
+
import SectionSeparator from '../../pb_section_separator/_section_separator'
|
|
9
|
+
import Title from '../../pb_title/_title'
|
|
10
|
+
import { colors, typography } from 'playbook-ui'
|
|
11
|
+
|
|
12
|
+
const data = [{ name: "Name", y: 10 }];
|
|
13
|
+
|
|
14
|
+
const chartOptions = {
|
|
15
|
+
series: [{ data: data }],
|
|
16
|
+
chart: {
|
|
17
|
+
height: "150",
|
|
18
|
+
},
|
|
19
|
+
plotOptions: {
|
|
20
|
+
series: {
|
|
21
|
+
animation: false,
|
|
22
|
+
},
|
|
23
|
+
solidgauge: {
|
|
24
|
+
dataLabels: {
|
|
25
|
+
format:
|
|
26
|
+
`<span class="fix">{y:,f}</span>` +
|
|
27
|
+
`<span style="fill: ${colors.text_lt_light}; font-size: ${typography.text_larger};">%</span>`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const PbGaugeChartComplex = (props) => (
|
|
34
|
+
<Flex
|
|
35
|
+
gap="sm"
|
|
36
|
+
padding="xl"
|
|
37
|
+
wrap
|
|
38
|
+
>
|
|
39
|
+
<FlexItem
|
|
40
|
+
flex={1}
|
|
41
|
+
grow
|
|
42
|
+
>
|
|
43
|
+
<Card
|
|
44
|
+
maxWidth="xs"
|
|
45
|
+
padding="md"
|
|
46
|
+
>
|
|
47
|
+
<Title
|
|
48
|
+
paddingBottom="sm"
|
|
49
|
+
size={4}
|
|
50
|
+
text="Abandoned Calls"
|
|
51
|
+
/>
|
|
52
|
+
<Flex
|
|
53
|
+
align="stretch"
|
|
54
|
+
>
|
|
55
|
+
<Flex
|
|
56
|
+
marginRight="sm"
|
|
57
|
+
orientation="column"
|
|
58
|
+
>
|
|
59
|
+
<Body
|
|
60
|
+
color="light"
|
|
61
|
+
paddingBottom="sm"
|
|
62
|
+
text="Total Abandoned"
|
|
63
|
+
/>
|
|
64
|
+
<Flex
|
|
65
|
+
align="baseline"
|
|
66
|
+
paddingBottom="xs"
|
|
67
|
+
>
|
|
68
|
+
<Title
|
|
69
|
+
size={1}
|
|
70
|
+
text="39"
|
|
71
|
+
/>
|
|
72
|
+
<Title
|
|
73
|
+
color="light"
|
|
74
|
+
size={3}
|
|
75
|
+
text="calls"
|
|
76
|
+
/>
|
|
77
|
+
</Flex>
|
|
78
|
+
<Caption
|
|
79
|
+
size="xs"
|
|
80
|
+
text="of 390"
|
|
81
|
+
/>
|
|
82
|
+
</Flex>
|
|
83
|
+
|
|
84
|
+
<SectionSeparator
|
|
85
|
+
alignSelf="stretch"
|
|
86
|
+
marginRight="sm"
|
|
87
|
+
orientation="vertical"
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<Flex
|
|
91
|
+
orientation="column"
|
|
92
|
+
wrap
|
|
93
|
+
>
|
|
94
|
+
<Body
|
|
95
|
+
color="light"
|
|
96
|
+
text="% Abandoned"
|
|
97
|
+
/>
|
|
98
|
+
<Flex
|
|
99
|
+
wrap
|
|
100
|
+
>
|
|
101
|
+
<FlexItem
|
|
102
|
+
fixedSize="150px"
|
|
103
|
+
overflow="hidden"
|
|
104
|
+
shrink
|
|
105
|
+
>
|
|
106
|
+
<PbGaugeChart
|
|
107
|
+
options={chartOptions}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
</FlexItem>
|
|
111
|
+
</Flex>
|
|
112
|
+
</Flex>
|
|
113
|
+
</Flex>
|
|
114
|
+
</Card>
|
|
115
|
+
</FlexItem>
|
|
116
|
+
</Flex>
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
export default PbGaugeChartComplex
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
We are able to wrap the Highcharts Gauge kit within Playbook kits (such as Flex and Card components).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PbGaugeChart from '../../pb_pb_gauge_chart/_pb_gauge_chart'
|
|
3
|
+
|
|
4
|
+
const chartOptions = {
|
|
5
|
+
series:[{data:[{ name: "Name", y: 45 }]}]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const PbGaugeChartDefault = (props) => (
|
|
9
|
+
<div>
|
|
10
|
+
<PbGaugeChart
|
|
11
|
+
options={chartOptions}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
export default PbGaugeChartDefault
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PbGaugeChart from '../../pb_pb_gauge_chart/_pb_gauge_chart'
|
|
3
|
+
|
|
4
|
+
const data = [{ name: "Participants", y: 84 }]
|
|
5
|
+
|
|
6
|
+
const chartOptions = {
|
|
7
|
+
series: [{ data: data }],
|
|
8
|
+
plotOptions: {
|
|
9
|
+
series: {
|
|
10
|
+
animation: false,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const PbGaugeChartDisableAnimation = (props) => (
|
|
16
|
+
<div>
|
|
17
|
+
<PbGaugeChart
|
|
18
|
+
options={chartOptions}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export default PbGaugeChartDisableAnimation
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<% data = [{ name: "Capacity", y: 75 }] %>
|
|
2
|
+
|
|
3
|
+
<% chart_options = {
|
|
4
|
+
title: {
|
|
5
|
+
text: "Seating Capacity",
|
|
6
|
+
},
|
|
7
|
+
series: [{ data: data }],
|
|
8
|
+
pane: {
|
|
9
|
+
startAngle: 0,
|
|
10
|
+
endAngle: 360,
|
|
11
|
+
},
|
|
12
|
+
plotOptions: {
|
|
13
|
+
solidgauge: {
|
|
14
|
+
dataLabels: {
|
|
15
|
+
format:
|
|
16
|
+
'<span class="fix">{y:,f}</span>' +
|
|
17
|
+
'<span style="fill: #687887; font-size: 27px;">%</span>',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
} %>
|
|
22
|
+
|
|
23
|
+
<%= pb_rails("pb_gauge_chart", props: { options: chart_options }) %>
|