playbook_ui 14.24.0.pre.alpha.PLAY23139411 → 14.24.0.pre.alpha.play23649479
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/pb_advanced_table/_advanced_table.scss +34 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.html.erb +43 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx +64 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +26 -175
- data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +1 -2
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.html.erb +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +12 -78
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.html.erb +21 -9
- data/app/pb_kits/playbook/pb_date/_date.tsx +5 -3
- data/app/pb_kits/playbook/pb_date/date.html.erb +6 -6
- data/app/pb_kits/playbook/pb_date/date.rb +2 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.html.erb +4 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.jsx +17 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_date/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.test.jsx +212 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +8 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control.jsx +112 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control_react.md +3 -0
- data/app/pb_kits/playbook/pb_pagination/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_pagination/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -1
- data/dist/chunks/_line_graph-BsZ3DcJo.js +1 -0
- data/dist/chunks/{_typeahead-BzYZCpJO.js → _typeahead-CKvqSXWH.js} +2 -2
- data/dist/chunks/{_weekday_stacked-B89kArHY.js → _weekday_stacked-tedYzlIq.js} +2 -2
- data/dist/chunks/{lib-CY5ZPzic.js → lib-BplzvaaY.js} +2 -2
- data/dist/chunks/{pb_form_validation-D3b0JKHH.js → pb_form_validation-CA_noofR.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- data/dist/playbook-doc.js +1 -1
- 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 +15 -7
- data/dist/chunks/_line_graph-D7DgMqnT.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be43cefc6c49eebecc1cc7526b3dd1e7ccf55544dbdc1adf92f81ff22768867
|
4
|
+
data.tar.gz: 85f5fd95aef9a42e578af9a00448e49cb74e3dac79fb6824f0dcc919c257ead6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1261c1fb78b71682d0b4f04b3051def634b429b3915f1566f15ddf6bc3cbcec7508f7d6c1c2dc08ef9a474c918271398a67e74788bb72dd7a599dbe0089a7d6b
|
7
|
+
data.tar.gz: fc343526ed3f7b8d5ba4f1cdcc96b96726e664a47a636627fc9a432b98a28ce32720aca491bf68a5617965aa7133841a589ac1999c63f748bab2c6542e205f71
|
@@ -971,6 +971,40 @@
|
|
971
971
|
}
|
972
972
|
}
|
973
973
|
}
|
974
|
+
|
975
|
+
// Firefox-specific fix for last-header-cell and last-cell vertical borders
|
976
|
+
@-moz-document url-prefix() {
|
977
|
+
.pb_advanced_table_header {
|
978
|
+
.last-header-cell {
|
979
|
+
border-right: none !important;
|
980
|
+
box-shadow: 1px 0 0 0 $border_light !important;
|
981
|
+
}
|
982
|
+
}
|
983
|
+
|
984
|
+
.pb_advanced_table_body {
|
985
|
+
.last-cell {
|
986
|
+
border-right: none !important;
|
987
|
+
box-shadow: 1px 0 0 0 $border_light !important;
|
988
|
+
}
|
989
|
+
}
|
990
|
+
|
991
|
+
// Dark mode Firefox fixes
|
992
|
+
&.dark {
|
993
|
+
.pb_advanced_table_header {
|
994
|
+
.last-header-cell {
|
995
|
+
border-right: none !important;
|
996
|
+
box-shadow: 1px 0 0 0 $border_dark !important;
|
997
|
+
}
|
998
|
+
}
|
999
|
+
|
1000
|
+
.pb_advanced_table_body {
|
1001
|
+
.last-cell {
|
1002
|
+
border-right: none !important;
|
1003
|
+
box-shadow: 1px 0 0 0 $border_dark !important;
|
1004
|
+
}
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
}
|
974
1008
|
}
|
975
1009
|
|
976
1010
|
// Outside of the pb_advanced_table class for popover
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% column_definitions = [
|
2
|
+
{
|
3
|
+
accessor: "year",
|
4
|
+
label: "Year",
|
5
|
+
cellAccessors: ["quarter", "month", "day"],
|
6
|
+
},
|
7
|
+
{
|
8
|
+
label: "Enrollment Data",
|
9
|
+
columns: [
|
10
|
+
{
|
11
|
+
accessor: "newEnrollments",
|
12
|
+
label: "New Enrollments",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
accessor: "scheduledMeetings",
|
16
|
+
label: "Scheduled Meetings",
|
17
|
+
},
|
18
|
+
],
|
19
|
+
},
|
20
|
+
{
|
21
|
+
label: "Performance Data",
|
22
|
+
columns: [
|
23
|
+
{
|
24
|
+
accessor: "attendanceRate",
|
25
|
+
label: "Attendance Rate",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
accessor: "completedClasses",
|
29
|
+
label: "Completed Classes",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
accessor: "classCompletionRate",
|
33
|
+
label: "Class Completion Rate",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
accessor: "graduatedStudents",
|
37
|
+
label: "Graduated Students",
|
38
|
+
},
|
39
|
+
],
|
40
|
+
},
|
41
|
+
] %>
|
42
|
+
|
43
|
+
<%= pb_rails("advanced_table", props: { id: "table_multi_headers_vertical_borders", table_data: @table_data, column_definitions: column_definitions, table_props: { vertical_border: true } }) %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableColumnHeadersVerticalBorder = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: "Enrollment Data",
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
accessor: "newEnrollments",
|
17
|
+
label: "New Enrollments",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
accessor: "scheduledMeetings",
|
21
|
+
label: "Scheduled Meetings",
|
22
|
+
},
|
23
|
+
],
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "Performance Data",
|
27
|
+
columns: [
|
28
|
+
{
|
29
|
+
accessor: "attendanceRate",
|
30
|
+
label: "Attendance Rate",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
accessor: "completedClasses",
|
34
|
+
label: "Completed Classes",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
accessor: "classCompletionRate",
|
38
|
+
label: "Class Completion Rate",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
accessor: "graduatedStudents",
|
42
|
+
label: "Graduated Students",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
];
|
47
|
+
|
48
|
+
const tableProps = {
|
49
|
+
verticalBorder: true
|
50
|
+
}
|
51
|
+
|
52
|
+
return (
|
53
|
+
<>
|
54
|
+
<AdvancedTable
|
55
|
+
columnDefinitions={columnDefinitions}
|
56
|
+
tableData={MOCK_DATA}
|
57
|
+
tableProps={tableProps}
|
58
|
+
{...props}
|
59
|
+
/>
|
60
|
+
</>
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
export default AdvancedTableColumnHeadersVerticalBorder
|
@@ -13,6 +13,7 @@ examples:
|
|
13
13
|
- advanced_table_with_custom_header_rails: Custom Header Cell
|
14
14
|
- advanced_table_column_headers: Multi-Header Columns
|
15
15
|
- advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
|
16
|
+
- advanced_table_column_headers_vertical_border: Multi-Header Columns with Vertical Borders
|
16
17
|
- advanced_table_no_subrows: Table with No Subrows or Expansion
|
17
18
|
- advanced_table_selectable_rows_rails: Selectable Rows
|
18
19
|
- advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
|
@@ -53,6 +54,7 @@ examples:
|
|
53
54
|
- advanced_table_column_headers: Multi-Header Columns
|
54
55
|
- advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
|
55
56
|
- advanced_table_column_headers_custom_cell: Multi-Header Columns with Custom Cells
|
57
|
+
- advanced_table_column_headers_vertical_border: Multi-Header Columns with Vertical Borders
|
56
58
|
- advanced_table_no_subrows: Table with No Subrows or Expansion
|
57
59
|
- advanced_table_pinned_rows: Pinned Rows
|
58
60
|
- advanced_table_selectable_rows: Selectable Rows
|
@@ -21,6 +21,7 @@ export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_
|
|
21
21
|
export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
|
22
22
|
export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
|
23
23
|
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
24
|
+
export { default as AdvancedTableColumnHeadersVerticalBorder } from './_advanced_table_column_headers_vertical_border.jsx'
|
24
25
|
export { default as AdvancedTableInlineEditing } from './_advanced_table_inline_editing.jsx'
|
25
26
|
export { default as AdvancedTableFullscreen } from './_advanced_table_fullscreen.jsx'
|
26
27
|
export { default as AdvancedTableStickyColumns } from './_advanced_table_sticky_columns.jsx'
|
@@ -43,7 +43,7 @@ module Playbook
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def td_classname(column, index)
|
46
|
-
classes = %w[id-cell
|
46
|
+
classes = %w[id-cell]
|
47
47
|
classes << "last-cell" if column[:is_last_in_group]
|
48
48
|
classes << "pinned-left" if index.zero? && is_pinned_left && responsive == "scroll"
|
49
49
|
classes.join(" ")
|
@@ -1,190 +1,41 @@
|
|
1
|
-
import React, {
|
2
|
-
import { globalProps } from "../utilities/globalProps";
|
1
|
+
import React, { useMemo } from "react"
|
3
2
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
3
|
+
import Highcharts from "highcharts"
|
4
|
+
import HighchartsReact from "highcharts-react-official"
|
4
5
|
|
5
|
-
import
|
6
|
-
import Highcharts from "highcharts";
|
7
|
-
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
|
-
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
|
-
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
-
import { merge } from '../utilities/object'
|
11
|
-
|
12
|
-
import classnames from "classnames";
|
6
|
+
import barGraphTheme from "./barGraphTheme"
|
13
7
|
|
14
8
|
type BarGraphProps = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
xAxisCategories: [];
|
19
|
-
yAxisMin: number;
|
20
|
-
yAxisMax: number;
|
21
|
-
chartData: { name: string; data: number[], yAxis: number }[];
|
22
|
-
className?: string;
|
23
|
-
customOptions?: Partial<Highcharts.Options>;
|
24
|
-
id: string;
|
25
|
-
pointStart: number;
|
26
|
-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
27
|
-
subTitle?: string;
|
28
|
-
title: string;
|
29
|
-
type?: string;
|
30
|
-
legend?: boolean;
|
31
|
-
toggleLegendClick?: boolean;
|
32
|
-
height?: string;
|
33
|
-
colors: string[];
|
34
|
-
layout?: "horizontal" | "vertical" | "proximate";
|
35
|
-
verticalAlign?: "top" | "middle" | "bottom";
|
36
|
-
x?: number;
|
37
|
-
y?: number;
|
38
|
-
aria?: { [key: string]: string };
|
39
|
-
data?: { [key: string]: string };
|
40
|
-
stacking?: "normal" | "percent"
|
41
|
-
axisFormat?: { format: string; }[] | string;
|
42
|
-
};
|
43
|
-
|
44
|
-
|
45
|
-
const BarGraph = ({
|
46
|
-
aria = {},
|
47
|
-
data = {},
|
48
|
-
align = "center",
|
49
|
-
axisTitle,
|
50
|
-
dark = false,
|
51
|
-
chartData,
|
52
|
-
className = "pb_bar_graph",
|
53
|
-
colors,
|
54
|
-
htmlOptions = {},
|
55
|
-
customOptions = {},
|
56
|
-
axisFormat,
|
57
|
-
id,
|
58
|
-
pointStart,
|
59
|
-
stacking,
|
60
|
-
subTitle,
|
61
|
-
type = "column",
|
62
|
-
title = "Title",
|
63
|
-
xAxisCategories,
|
64
|
-
yAxisMin,
|
65
|
-
yAxisMax,
|
66
|
-
legend = false,
|
67
|
-
toggleLegendClick = true,
|
68
|
-
height,
|
69
|
-
layout = "horizontal",
|
70
|
-
verticalAlign = "bottom",
|
71
|
-
x = 0,
|
72
|
-
y = 0,
|
73
|
-
...props
|
74
|
-
}: BarGraphProps): React.ReactElement => {
|
75
|
-
const ariaProps = buildAriaProps(aria);
|
76
|
-
const dataProps = buildDataProps(data)
|
77
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
78
|
-
const setupTheme = () => {
|
79
|
-
dark
|
80
|
-
? Highcharts.setOptions(highchartsDarkTheme)
|
81
|
-
: Highcharts.setOptions(highchartsTheme);
|
82
|
-
};
|
83
|
-
setupTheme();
|
84
|
-
|
85
|
-
const staticOptions = {
|
86
|
-
title: {
|
87
|
-
text: title,
|
88
|
-
},
|
89
|
-
chart: {
|
90
|
-
height: height,
|
91
|
-
type: type,
|
92
|
-
},
|
93
|
-
subtitle: {
|
94
|
-
text: subTitle,
|
95
|
-
},
|
96
|
-
yAxis: [{
|
97
|
-
labels: {
|
98
|
-
format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
|
99
|
-
|
100
|
-
},
|
101
|
-
min: yAxisMin,
|
102
|
-
max: yAxisMax,
|
103
|
-
opposite: false,
|
104
|
-
title: {
|
105
|
-
text: Array.isArray(axisTitle) ? (axisTitle.length > 0 ? axisTitle[0].name : null) : axisTitle,
|
106
|
-
},
|
107
|
-
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
108
|
-
value: 0,
|
109
|
-
zIndex: 10,
|
110
|
-
color: "#E4E8F0"
|
111
|
-
}],
|
112
|
-
}],
|
113
|
-
xAxis: {
|
114
|
-
categories: xAxisCategories,
|
115
|
-
},
|
116
|
-
legend: {
|
117
|
-
enabled: legend,
|
118
|
-
align: align,
|
119
|
-
verticalAlign: verticalAlign,
|
120
|
-
layout: layout,
|
121
|
-
x: x,
|
122
|
-
y: y,
|
123
|
-
},
|
124
|
-
colors:
|
125
|
-
colors !== undefined && colors.length > 0
|
126
|
-
? mapColors(colors)
|
127
|
-
: highchartsTheme.colors,
|
128
|
-
plotOptions: {
|
129
|
-
series: {
|
130
|
-
stacking: stacking,
|
131
|
-
pointStart: pointStart,
|
132
|
-
borderWidth: stacking ? 0 : "",
|
133
|
-
events: {},
|
134
|
-
dataLabels: {
|
135
|
-
enabled: false,
|
136
|
-
},
|
137
|
-
},
|
138
|
-
},
|
139
|
-
series: chartData,
|
140
|
-
credits: false,
|
141
|
-
};
|
142
|
-
|
143
|
-
if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
144
|
-
staticOptions.yAxis.push({
|
145
|
-
labels: {
|
146
|
-
format: typeof axisFormat === 'string' ? axisFormat : axisFormat[1].format,
|
147
|
-
},
|
148
|
-
min: yAxisMin,
|
149
|
-
max: yAxisMax,
|
150
|
-
opposite: true,
|
151
|
-
title: {
|
152
|
-
text: axisTitle[1].name,
|
153
|
-
},
|
154
|
-
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
155
|
-
value: 0,
|
156
|
-
zIndex: 10,
|
157
|
-
color: "#E4E8F0"
|
158
|
-
}],
|
159
|
-
});
|
9
|
+
options: Record<string, unknown>
|
10
|
+
containerProps?: React.HTMLProps<HTMLDivElement>
|
11
|
+
data?: Record<string, unknown>
|
160
12
|
}
|
161
13
|
|
162
|
-
|
163
|
-
|
164
|
-
}
|
14
|
+
const BarGraph = ({
|
15
|
+
options,
|
16
|
+
containerProps = {},
|
17
|
+
data = {}
|
18
|
+
}: BarGraphProps): React.ReactElement => {
|
165
19
|
|
166
|
-
const
|
167
|
-
delete filteredProps.verticalAlign;
|
20
|
+
const dataProps = buildDataProps(data)
|
168
21
|
|
169
|
-
const
|
22
|
+
const mergedOptions = useMemo(() => {
|
23
|
+
if (!options || typeof options !== "object") {
|
24
|
+
// eslint-disable-next-line no-console
|
25
|
+
console.error("❌ Invalid options passed to <BarGraph />", options)
|
26
|
+
return {}
|
27
|
+
}
|
170
28
|
|
171
|
-
|
172
|
-
|
173
|
-
}, [chartData]);
|
29
|
+
return Highcharts.merge({}, barGraphTheme, options)
|
30
|
+
}, [options])
|
174
31
|
|
175
32
|
return (
|
176
33
|
<HighchartsReact
|
177
|
-
containerProps={{
|
178
|
-
className: classnames(globalProps(filteredProps), className),
|
179
|
-
id: id,
|
180
|
-
...ariaProps,
|
181
|
-
...dataProps,
|
182
|
-
...htmlProps
|
183
|
-
}}
|
34
|
+
containerProps={{ ...containerProps, ...dataProps }}
|
184
35
|
highcharts={Highcharts}
|
185
|
-
options={
|
36
|
+
options={mergedOptions}
|
186
37
|
/>
|
187
|
-
)
|
188
|
-
}
|
38
|
+
)
|
39
|
+
}
|
189
40
|
|
190
|
-
export default BarGraph
|
41
|
+
export default BarGraph
|
@@ -20,9 +20,8 @@ const testId = 'bargraph1';
|
|
20
20
|
test('bargraph uses exact classname', () => {
|
21
21
|
render(
|
22
22
|
<BarGraph
|
23
|
-
className
|
23
|
+
containerProps={{ className: 'super_important_class' }}
|
24
24
|
data={{ testid: testId }}
|
25
|
-
id='bar-default'
|
26
25
|
/>
|
27
26
|
);
|
28
27
|
|
@@ -1 +1 @@
|
|
1
|
-
<%= react_component('BarGraph', object.
|
1
|
+
<%= react_component('BarGraph', object.react_props) %>
|
@@ -3,91 +3,25 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbBarGraph
|
5
5
|
class BarGraph < Playbook::KitBase
|
6
|
-
prop :
|
7
|
-
|
8
|
-
default: "center"
|
9
|
-
prop :axis_title
|
10
|
-
prop :axis_format
|
11
|
-
prop :chart_data, type: Playbook::Props::Array,
|
12
|
-
default: []
|
13
|
-
prop :custom_options, default: {}
|
14
|
-
prop :orientation, type: Playbook::Props::Enum,
|
15
|
-
values: %w[vertical horizontal],
|
16
|
-
default: "vertical"
|
17
|
-
prop :point_start, type: Playbook::Props::Numeric
|
18
|
-
prop :stacking
|
19
|
-
prop :subtitle
|
20
|
-
prop :title
|
21
|
-
prop :x_axis_categories, type: Playbook::Props::Array,
|
22
|
-
default: []
|
23
|
-
prop :y_axis_min, type: Playbook::Props::Numeric
|
24
|
-
prop :y_axis_max, type: Playbook::Props::Numeric
|
25
|
-
prop :legend, type: Playbook::Props::Boolean,
|
26
|
-
default: false
|
27
|
-
prop :toggle_legend_click, type: Playbook::Props::Boolean,
|
28
|
-
default: true
|
29
|
-
prop :height
|
30
|
-
prop :colors, type: Playbook::Props::Array,
|
31
|
-
default: []
|
32
|
-
prop :layout, type: Playbook::Props::Enum,
|
33
|
-
values: %w[horizontal vertical proximate],
|
34
|
-
default: "horizontal"
|
35
|
-
prop :vertical_align, type: Playbook::Props::Enum,
|
36
|
-
values: %w[top middle bottom],
|
37
|
-
default: "bottom"
|
38
|
-
prop :x, type: Playbook::Props::Numeric
|
39
|
-
prop :y, type: Playbook::Props::Numeric
|
6
|
+
prop :options, default: {}
|
7
|
+
prop :container_props, default: {}
|
40
8
|
|
41
|
-
def
|
42
|
-
|
9
|
+
def chart_options
|
10
|
+
options
|
43
11
|
end
|
44
12
|
|
45
|
-
def
|
13
|
+
def react_props
|
46
14
|
{
|
47
|
-
|
48
|
-
|
49
|
-
className: classname,
|
50
|
-
chartData: chart_data,
|
51
|
-
dark: dark ? "dark" : "",
|
52
|
-
type: chart_type,
|
53
|
-
title: title,
|
54
|
-
stacking: stacking,
|
55
|
-
subTitle: subtitle,
|
56
|
-
axisTitle: axis_title,
|
57
|
-
axisFormat: axis_format,
|
58
|
-
pointStart: point_start,
|
59
|
-
xAxisCategories: x_axis_categories,
|
60
|
-
yAxisMin: y_axis_min,
|
61
|
-
yAxisMax: y_axis_max,
|
62
|
-
legend: legend,
|
63
|
-
toggleLegendClick: toggle_legend_click,
|
64
|
-
height: height,
|
65
|
-
colors: colors,
|
66
|
-
layout: layout,
|
67
|
-
verticalAlign: vertical_align,
|
68
|
-
x: x,
|
69
|
-
y: y,
|
15
|
+
options: options,
|
16
|
+
containerProps: container_props_hash,
|
70
17
|
}
|
71
18
|
end
|
72
19
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
20
|
+
def container_props_hash
|
21
|
+
container_props.merge({
|
22
|
+
id: id,
|
23
|
+
className: classname,
|
24
|
+
}).compact
|
91
25
|
end
|
92
26
|
|
93
27
|
def classname
|
@@ -15,12 +15,24 @@
|
|
15
15
|
data: [1111,677,3245,500,200]
|
16
16
|
}] %>
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
18
|
+
|
19
|
+
<% chart_options = {
|
20
|
+
series: data,
|
21
|
+
title: {
|
22
|
+
text: 'Solar Employment Growth by Sector, 2010-2016',
|
23
|
+
},
|
24
|
+
subtitle: {
|
25
|
+
text: 'Source: thesolarfoundation.com',
|
26
|
+
},
|
27
|
+
xAxis: {
|
28
|
+
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
29
|
+
},
|
30
|
+
yAxis: {
|
31
|
+
title: {
|
32
|
+
text: 'Number of Employees',
|
33
|
+
},
|
34
|
+
},
|
35
|
+
}
|
36
|
+
%>
|
37
|
+
|
38
|
+
<%= pb_rails("bar_graph", props: {options: chart_options}) %>
|
@@ -19,6 +19,7 @@ type PbDateProps = {
|
|
19
19
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
20
20
|
id?: string;
|
21
21
|
showDayOfWeek?: boolean;
|
22
|
+
showCurrentYear?: boolean;
|
22
23
|
showIcon?: boolean;
|
23
24
|
size?: "sm" | "md" | "lg";
|
24
25
|
unstyled?: boolean;
|
@@ -35,6 +36,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
35
36
|
htmlOptions = {},
|
36
37
|
id,
|
37
38
|
showDayOfWeek = false,
|
39
|
+
showCurrentYear = false,
|
38
40
|
showIcon = false,
|
39
41
|
size = "md",
|
40
42
|
unstyled = false,
|
@@ -90,7 +92,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
90
92
|
{month} {day}
|
91
93
|
</span>
|
92
94
|
|
93
|
-
{currentYear
|
95
|
+
{(currentYear !== year || showCurrentYear) && <span>{`, ${year}`}</span>}
|
94
96
|
</span>
|
95
97
|
</>
|
96
98
|
: size == "md" || size == "lg"
|
@@ -124,7 +126,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
124
126
|
<span>
|
125
127
|
{month} {day}
|
126
128
|
</span>
|
127
|
-
{currentYear
|
129
|
+
{(currentYear !== year || showCurrentYear) && <span>{`, ${year}`}</span>}
|
128
130
|
</Title>
|
129
131
|
)
|
130
132
|
: (
|
@@ -158,7 +160,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
158
160
|
<Caption dark={dark}
|
159
161
|
tag="span">
|
160
162
|
{month} {day}
|
161
|
-
{currentYear
|
163
|
+
{(currentYear !== year || showCurrentYear) && <>{`, ${year}`}</>}
|
162
164
|
</Caption>
|
163
165
|
</>
|
164
166
|
)}
|
@@ -13,8 +13,8 @@
|
|
13
13
|
<% end %>
|
14
14
|
|
15
15
|
<!-- month day, year -->
|
16
|
-
<%# if not current year %>
|
17
|
-
<% if object.year.to_s == DateTime.now.year.to_s %>
|
16
|
+
<%# if not current year or show_current_year is false %>
|
17
|
+
<% if object.year.to_s == DateTime.now.year.to_s && !object.show_current_year %>
|
18
18
|
<span><%= "#{object.month} #{object.day}" %></span>
|
19
19
|
<%# if is current year %>
|
20
20
|
<% else %>
|
@@ -44,8 +44,8 @@
|
|
44
44
|
|
45
45
|
<!-- month day, year -->
|
46
46
|
|
47
|
-
<%# if not current year %>
|
48
|
-
<% if object.year.to_s == DateTime.now.year.to_s %>
|
47
|
+
<%# if not current year or show_current_year is false %>
|
48
|
+
<% if object.year.to_s == DateTime.now.year.to_s && !object.show_current_year %>
|
49
49
|
<%= pb_rails("title", props: { tag: "div", text: "#{object.month} #{object.day}", size: 4 }) %>
|
50
50
|
<%# if is current year %>
|
51
51
|
<% else %>
|
@@ -74,8 +74,8 @@
|
|
74
74
|
|
75
75
|
<!-- month day, year -->
|
76
76
|
|
77
|
-
<%# if not current year %>
|
78
|
-
<% if object.year.to_s == DateTime.now.year.to_s %>
|
77
|
+
<%# if not current year or show_current_year is false %>
|
78
|
+
<% if object.year.to_s == DateTime.now.year.to_s && !object.show_current_year %>
|
79
79
|
<%= pb_rails("caption", props: { tag: "span", text: "#{object.month} #{object.day}" }) %>
|
80
80
|
<%# if is current year %>
|
81
81
|
<% else %>
|
@@ -11,6 +11,8 @@ module Playbook
|
|
11
11
|
default: false
|
12
12
|
prop :show_day_of_week, type: Playbook::Props::Boolean,
|
13
13
|
default: false
|
14
|
+
prop :show_current_year, type: Playbook::Props::Boolean,
|
15
|
+
default: false
|
14
16
|
prop :size, type: Playbook::Props::Enum,
|
15
17
|
values: %w[lg md sm xs],
|
16
18
|
default: "md"
|