playbook_ui 15.2.0.pre.alpha.PLAY2428advancedtablerailscellpadding11387 → 15.2.0.pre.alpha.PLAY2542formatasyoutypebug11501
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 +4 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +1 -75
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +8 -6
- 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/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_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_phone_number_input/_phone_number_input.tsx +37 -18
- 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-DY4PK6AH.js → _line_graph-eXNg1pX_.js} +1 -1
- data/dist/chunks/{_typeahead-fQDb_yVO.js → _typeahead-B6jpvyrP.js} +1 -1
- data/dist/chunks/{_weekday_stacked-D_bGbWtk.js → _weekday_stacked-D6SPyi5u.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +6 -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 +40 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66bd84abefa68eb69260d4f315cd027b9109b9271e2ab828e245305934e7b34c
|
|
4
|
+
data.tar.gz: 14d3cfdadac16c1960d4ef5a608d0e95d491cb3e4780fb804f6f778dc2ca0926
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 356228c23803a8da19fdd22c0a7262ddc6e52f826f6eaad2405af0ad6e8c7d474518c32f1594474f46f6c0154cc1d403446e6078dccc39cbc8b047f9dca1f692
|
|
7
|
+
data.tar.gz: 70083aeae526b60e4a38d925b3c2bdea6e307224b5d3cce2544ec756f26aa243f66cf87256af2f5e8dc179feabacab828733f47a86d2f886bc38915bcd9fc4f2
|
|
@@ -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';
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb
CHANGED
|
@@ -36,78 +36,4 @@
|
|
|
36
36
|
<%= pb_rails("advanced_table", props: { id: "padding-control", table_data: @table_data, column_definitions: column_definitions }) do %>
|
|
37
37
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
|
38
38
|
<%= pb_rails("advanced_table/table_body", props: { table_data: @table_data, column_definitions: column_definitions }) %>
|
|
39
|
-
<% end %>
|
|
40
|
-
|
|
41
|
-
<% multi_header_column_definitions = [
|
|
42
|
-
{
|
|
43
|
-
accessor: "year",
|
|
44
|
-
label: "Year",
|
|
45
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
label: "Enrollment Data",
|
|
49
|
-
columns: [
|
|
50
|
-
{
|
|
51
|
-
label: "Enrollment Stats",
|
|
52
|
-
columns: [
|
|
53
|
-
{
|
|
54
|
-
accessor: "newEnrollments",
|
|
55
|
-
label: "New Enrollments",
|
|
56
|
-
column_styling: {
|
|
57
|
-
cell_background_color: ->(row) { row[:newEnrollments].to_i > 20 ? "success_secondary" : "warning_secondary" }
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
accessor: "scheduledMeetings",
|
|
62
|
-
label: "Scheduled Meetings",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: "Performance Data",
|
|
70
|
-
columns: [
|
|
71
|
-
{
|
|
72
|
-
label: "Completion Metrics",
|
|
73
|
-
columns: [
|
|
74
|
-
{
|
|
75
|
-
accessor: "completedClasses",
|
|
76
|
-
label: "Completed Classes",
|
|
77
|
-
column_styling: {
|
|
78
|
-
cell_background_color: ->(row) { row[:completedClasses].to_i > 15 ? "info_secondary" : "neutral_secondary" }
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
accessor: "classCompletionRate",
|
|
83
|
-
label: "Class Completion Rate",
|
|
84
|
-
column_styling: {
|
|
85
|
-
cell_background_color: ->(row) { row[:completedClasses].to_i > 15 ? "neutral_secondary" : "info_secondary" }
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: "Attendance",
|
|
92
|
-
columns: [
|
|
93
|
-
{
|
|
94
|
-
accessor: "attendanceRate",
|
|
95
|
-
label: "Attendance Rate",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
accessor: "graduatedStudents",
|
|
99
|
-
label: "Graduated Students",
|
|
100
|
-
column_styling: {
|
|
101
|
-
cell_background_color: ->(row) { row[:graduatedStudents].to_i > 10 ? "primary_secondary" : "error_secondary" }
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
] %>
|
|
109
|
-
|
|
110
|
-
<%= pb_rails("advanced_table", props: { id: "padding-control-multi-header", table_data: @table_data, column_definitions: multi_header_column_definitions, padding_top: "lg" }) do %>
|
|
111
|
-
<%= pb_rails("advanced_table/table_header", props: { column_definitions: multi_header_column_definitions }) %>
|
|
112
|
-
<%= pb_rails("advanced_table/table_body", props: { table_data: @table_data, column_definitions: multi_header_column_definitions }) %>
|
|
113
|
-
<% end %>
|
|
39
|
+
<% 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
|
|
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,
|
|
@@ -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
|
+
})
|
|
@@ -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,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}) %>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
|
|
3
|
+
|
|
4
|
+
const data = [{
|
|
5
|
+
name: 'Installation',
|
|
6
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
|
7
|
+
}, {
|
|
8
|
+
name: 'Manufacturing',
|
|
9
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
|
10
|
+
}, {
|
|
11
|
+
name: 'Sales & Distribution',
|
|
12
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
|
13
|
+
}, {
|
|
14
|
+
name: 'Project Development',
|
|
15
|
+
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227],
|
|
16
|
+
}, {
|
|
17
|
+
name: 'Other',
|
|
18
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
|
19
|
+
}]
|
|
20
|
+
|
|
21
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
22
|
+
|
|
23
|
+
const chartOptions = {
|
|
24
|
+
series: data,
|
|
25
|
+
title: { text: "Solar Employment Growth by Sector, 2010-2016" },
|
|
26
|
+
subtitle: { text: "Source: thesolarfoundation.com" },
|
|
27
|
+
xAxis: {
|
|
28
|
+
categories: categories,
|
|
29
|
+
},
|
|
30
|
+
yAxis: {
|
|
31
|
+
title: {
|
|
32
|
+
text: "Number of Employees",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
const PbLineGraphDefault = (props) => (
|
|
37
|
+
<div>
|
|
38
|
+
<PbLineGraph
|
|
39
|
+
options={chartOptions}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
export default PbLineGraphDefault
|