playbook_ui 15.7.0.pre.rc.1 → 15.7.0.pre.rc.2
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/Components/RegularTableView.tsx +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +95 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_colors_rails.html.erb +43 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_colors_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +11 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +7 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background.jsx +54 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background.md +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +57 -0
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +51 -24
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +53 -19
- data/app/pb_kits/playbook/pb_contact/contact.rb +11 -1
- data/app/pb_kits/playbook/pb_contact/contact.test.js +76 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.html.erb +33 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.jsx +46 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_rails.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_react.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +2 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +1 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +14 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +5 -4
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.html.erb +24 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.jsx +60 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.md +3 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -1
- data/dist/chunks/vendor.js +2 -2
- data/dist/menu.yml +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +15 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 371d5a4b2875ab575224762ed34aef7597086445494a2785824e9bbf9fff417d
|
|
4
|
+
data.tar.gz: e1738e75556fbb0b0b1682a751adc0d062b0d0bfc9ef02a5aad48f72d0815011
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e63fe0139eb3b4af379fe345fabcd3bbff1cecf8fef4f166b98d3255da33407a65ae8b8aa87e6584a581a13f88333026255d52e01bda184945ff89527a77231
|
|
7
|
+
data.tar.gz: 671a72c82ee54d6050bcb1ff5c76b3b18427e96fe68ef813a28df5aab424607c89f557130f3bcfb0b0b00711df63cfa78624f187e6ed6ed1fc43332d15be3b5b
|
|
@@ -63,10 +63,11 @@ const TableCellRenderer = ({
|
|
|
63
63
|
|
|
64
64
|
const { column } = cell;
|
|
65
65
|
|
|
66
|
-
// Find the
|
|
66
|
+
// Find the "owning" colDefinition by accessor. Needed for multi column logic
|
|
67
67
|
const colDef = findColumnDefByAccessor(columnDefinitions ?? [], column.id)
|
|
68
68
|
const cellAlignment = colDef?.columnStyling?.cellAlignment ?? "right"
|
|
69
69
|
const cellFontColor = colDef?.columnStyling?.fontColor
|
|
70
|
+
const cellBackgroundColor = colDef?.columnStyling?.cellBackgroundColor
|
|
70
71
|
const paddingValue = colDef?.columnStyling?.cellPadding ?? customRowStyle?.cellPadding
|
|
71
72
|
const paddingClass = paddingValue ? `p_${paddingValue}` : undefined
|
|
72
73
|
|
|
@@ -88,7 +89,7 @@ const TableCellRenderer = ({
|
|
|
88
89
|
? '180px'
|
|
89
90
|
: `${column.getStart("left")}px`
|
|
90
91
|
: undefined,
|
|
91
|
-
backgroundColor: i === 0 && customRowStyle?.backgroundColor,
|
|
92
|
+
backgroundColor: cellBackgroundColor || (i === 0 && customRowStyle?.backgroundColor),
|
|
92
93
|
color: cellFontColor || customRowStyle?.fontColor,
|
|
93
94
|
}}
|
|
94
95
|
>
|
|
@@ -90,6 +90,8 @@ export const TableHeaderCell = ({
|
|
|
90
90
|
: undefined
|
|
91
91
|
|
|
92
92
|
const headerAlignment = colDef?.columnStyling?.headerAlignment ?? colDef?.columnStyling?.headerAligment
|
|
93
|
+
const headerBackgroundColor = colDef?.columnStyling?.headerBackgroundColor
|
|
94
|
+
const headerFontColor = colDef?.columnStyling?.headerFontColor
|
|
93
95
|
|
|
94
96
|
const isLeafColumn =
|
|
95
97
|
header?.column.getLeafColumns().length === 1 &&
|
|
@@ -194,6 +196,8 @@ const isToggleExpansionEnabled =
|
|
|
194
196
|
id={cellId}
|
|
195
197
|
key={`${header?.id}-header`}
|
|
196
198
|
style={{
|
|
199
|
+
backgroundColor: headerBackgroundColor,
|
|
200
|
+
color: headerFontColor,
|
|
197
201
|
left: isPinnedLeft
|
|
198
202
|
? header?.index === 1 //Accounting for set min-width for first column
|
|
199
203
|
? '180px'
|
|
@@ -888,3 +888,98 @@ test("Sort icon renders with enableSort on individual columns", () => {
|
|
|
888
888
|
expect(sortButton).toBeInTheDocument();
|
|
889
889
|
});
|
|
890
890
|
|
|
891
|
+
test("columnStyling.backgroundColor works as excpected", () => {
|
|
892
|
+
const styledColumnDefs = [
|
|
893
|
+
{
|
|
894
|
+
accessor: "year",
|
|
895
|
+
label: "Year",
|
|
896
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
accessor: "newEnrollments",
|
|
900
|
+
label: "New Enrollments",
|
|
901
|
+
columnStyling: {
|
|
902
|
+
cellBackgroundColor: colors.error_subtle,
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
accessor: "scheduledMeetings",
|
|
907
|
+
label: "Scheduled Meetings",
|
|
908
|
+
},
|
|
909
|
+
];
|
|
910
|
+
|
|
911
|
+
render(
|
|
912
|
+
<AdvancedTable
|
|
913
|
+
columnDefinitions={styledColumnDefs}
|
|
914
|
+
data={{ testid: testId }}
|
|
915
|
+
tableData={MOCK_DATA}
|
|
916
|
+
/>
|
|
917
|
+
);
|
|
918
|
+
|
|
919
|
+
const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
|
|
920
|
+
expect(firstEnrollmentCell).toHaveStyle({ backgroundColor: colors.error_subtle });
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
test("columnStyling.headerBackgroundColor works as excpected", () => {
|
|
924
|
+
const styledColumnDefs = [
|
|
925
|
+
{
|
|
926
|
+
accessor: "year",
|
|
927
|
+
label: "Year",
|
|
928
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
accessor: "newEnrollments",
|
|
932
|
+
label: "New Enrollments",
|
|
933
|
+
columnStyling: {
|
|
934
|
+
headerBackgroundColor: colors.error_subtle,
|
|
935
|
+
},
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
accessor: "scheduledMeetings",
|
|
939
|
+
label: "Scheduled Meetings",
|
|
940
|
+
},
|
|
941
|
+
];
|
|
942
|
+
|
|
943
|
+
render(
|
|
944
|
+
<AdvancedTable
|
|
945
|
+
columnDefinitions={styledColumnDefs}
|
|
946
|
+
data={{ testid: testId }}
|
|
947
|
+
tableData={MOCK_DATA}
|
|
948
|
+
/>
|
|
949
|
+
);
|
|
950
|
+
|
|
951
|
+
const firstEnrollmentHeader = screen.getAllByText("New Enrollments")[0].closest("th");
|
|
952
|
+
expect(firstEnrollmentHeader).toHaveStyle({ backgroundColor: colors.error_subtle });
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
test("columnStyling.headerFontColor works as excpected", () => {
|
|
956
|
+
const styledColumnDefs = [
|
|
957
|
+
{
|
|
958
|
+
accessor: "year",
|
|
959
|
+
label: "Year",
|
|
960
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
accessor: "newEnrollments",
|
|
964
|
+
label: "New Enrollments",
|
|
965
|
+
columnStyling: {
|
|
966
|
+
headerFontColor: colors.white,
|
|
967
|
+
},
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
accessor: "scheduledMeetings",
|
|
971
|
+
label: "Scheduled Meetings",
|
|
972
|
+
},
|
|
973
|
+
];
|
|
974
|
+
|
|
975
|
+
render(
|
|
976
|
+
<AdvancedTable
|
|
977
|
+
columnDefinitions={styledColumnDefs}
|
|
978
|
+
data={{ testid: testId }}
|
|
979
|
+
tableData={MOCK_DATA}
|
|
980
|
+
/>
|
|
981
|
+
);
|
|
982
|
+
|
|
983
|
+
const firstEnrollmentHeader = screen.getAllByText("New Enrollments")[0].closest("th");
|
|
984
|
+
expect(firstEnrollmentHeader).toHaveStyle({ color: colors.white });
|
|
985
|
+
});
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_colors_rails.html.erb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<% column_definitions = [
|
|
2
|
+
{
|
|
3
|
+
accessor: "year",
|
|
4
|
+
label: "Year",
|
|
5
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
accessor: "newEnrollments",
|
|
9
|
+
label: "New Enrollments",
|
|
10
|
+
column_styling: {
|
|
11
|
+
cell_background_color: ->(row) { row[:newEnrollments].to_i > 20 ? "success_secondary" : "warning_secondary" }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
accessor: "scheduledMeetings",
|
|
16
|
+
label: "Scheduled Meetings",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
accessor: "attendanceRate",
|
|
20
|
+
label: "Attendance Rate",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
accessor: "completedClasses",
|
|
24
|
+
label: "Completed Classes",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
accessor: "classCompletionRate",
|
|
28
|
+
label: "Class Completion Rate",
|
|
29
|
+
column_styling: {
|
|
30
|
+
cell_background_color: "category_1",
|
|
31
|
+
font_color: "white"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
accessor: "graduatedStudents",
|
|
36
|
+
label: "Graduated Students",
|
|
37
|
+
}
|
|
38
|
+
] %>
|
|
39
|
+
|
|
40
|
+
<%= pb_rails("advanced_table", props: { id: "background-control", table_data: @table_data, column_definitions: column_definitions }) do %>
|
|
41
|
+
<%= pb_rails("advanced_table/table_header", props: { table_id: "background-control", column_definitions: column_definitions }) %>
|
|
42
|
+
<%= pb_rails("advanced_table/table_body", props: { table_id: "background-control", table_data: @table_data, column_definitions: column_definitions }) %>
|
|
43
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
`column_styling` can also be used to control the background color on individual cells in a given column as shown here.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb
CHANGED
|
@@ -8,16 +8,26 @@
|
|
|
8
8
|
accessor: "newEnrollments",
|
|
9
9
|
label: "New Enrollments",
|
|
10
10
|
column_styling: {
|
|
11
|
-
cell_background_color:
|
|
11
|
+
cell_background_color: "error_subtle",
|
|
12
|
+
header_background_color: "error_subtle"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
16
|
accessor: "scheduledMeetings",
|
|
16
17
|
label: "Scheduled Meetings",
|
|
18
|
+
column_styling: {
|
|
19
|
+
cell_background_color: "info_subtle",
|
|
20
|
+
}
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
accessor: "attendanceRate",
|
|
20
24
|
label: "Attendance Rate",
|
|
25
|
+
column_styling: {
|
|
26
|
+
cell_background_color: "info",
|
|
27
|
+
header_background_color: "info",
|
|
28
|
+
header_font_color: "white",
|
|
29
|
+
font_color: "white"
|
|
30
|
+
}
|
|
21
31
|
},
|
|
22
32
|
{
|
|
23
33
|
accessor: "completedClasses",
|
|
@@ -26,10 +36,6 @@
|
|
|
26
36
|
{
|
|
27
37
|
accessor: "classCompletionRate",
|
|
28
38
|
label: "Class Completion Rate",
|
|
29
|
-
column_styling: {
|
|
30
|
-
cell_background_color: "category_1",
|
|
31
|
-
font_color: "white"
|
|
32
|
-
}
|
|
33
39
|
},
|
|
34
40
|
{
|
|
35
41
|
accessor: "graduatedStudents",
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
`column_styling` can also be used to control the background color on all cells in a given column
|
|
1
|
+
`column_styling` can also be used to control the background color on all cells in a given column. Use the following key/values pairs to achieve this:
|
|
2
|
+
|
|
3
|
+
1) `cell_background_color`: use this to control the background color of all cells in the given column
|
|
4
|
+
2) `font_color`: use this to control font color for all cells in the given column if needed, for example if using a darker background color
|
|
5
|
+
3) `header_background_color`: use this to control the background color of the column header
|
|
6
|
+
4) `header_font_color`: use this to control font color for the header in the given column if needed, for example if using a darker background color.
|
|
7
|
+
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background.jsx
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import AdvancedTable from '../_advanced_table'
|
|
3
|
+
import colors from '../../tokens/exports/_colors.module.scss'
|
|
4
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const AdvancedTableColumnStylingBackground = (props) => {
|
|
8
|
+
const columnDefinitions = [
|
|
9
|
+
{
|
|
10
|
+
accessor: "year",
|
|
11
|
+
label: "Year",
|
|
12
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
accessor: "newEnrollments",
|
|
16
|
+
label: "New Enrollments",
|
|
17
|
+
columnStyling:{cellBackgroundColor: colors.error_subtle, headerBackgroundColor: colors.error_subtle},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
accessor: "scheduledMeetings",
|
|
21
|
+
label: "Scheduled Meetings",
|
|
22
|
+
columnStyling:{cellBackgroundColor: colors.info_subtle},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
accessor: "attendanceRate",
|
|
26
|
+
label: "Attendance Rate",
|
|
27
|
+
columnStyling:{cellBackgroundColor: colors.info, headerBackgroundColor: colors.info, fontColor: colors.white, headerFontColor: colors.white},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
accessor: "completedClasses",
|
|
31
|
+
label: "Completed Classes",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
accessor: "classCompletionRate",
|
|
35
|
+
label: "Class Completion Rate",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
accessor: "graduatedStudents",
|
|
39
|
+
label: "Graduated Students",
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<AdvancedTable
|
|
46
|
+
columnDefinitions={columnDefinitions}
|
|
47
|
+
tableData={MOCK_DATA}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default AdvancedTableColumnStylingBackground
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The `columnStyling` prop can also be used to set background color for entire columns.As stated above, `columnStyling` is an object that has several optional key/value pairs, here are the options highlighted in this doc:
|
|
2
|
+
|
|
3
|
+
1) `cellBackgroundColor`: use this to control the background color of all cells in the given column
|
|
4
|
+
2) `headerBackgroundColor`: use this to control the background color of the column header
|
|
5
|
+
3) `fontColor`: use this to control font color for all cells in the given column if needed, for example if using a darker background color.
|
|
6
|
+
4) `headerFontColor`: use this to control font color for the header in the given column if needed, for example if using a darker background color.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.jsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import AdvancedTable from '../_advanced_table'
|
|
3
|
+
import colors from '../../tokens/exports/_colors.module.scss'
|
|
4
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const AdvancedTableColumnStylingBackgroundMulti = (props) => {
|
|
8
|
+
const columnDefinitions = [
|
|
9
|
+
{
|
|
10
|
+
accessor: "year",
|
|
11
|
+
label: "Year",
|
|
12
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Enrollment Data",
|
|
16
|
+
columns: [
|
|
17
|
+
{
|
|
18
|
+
label: "Enrollment Stats",
|
|
19
|
+
columns: [
|
|
20
|
+
{
|
|
21
|
+
accessor: "newEnrollments",
|
|
22
|
+
label: "New Enrollments",
|
|
23
|
+
columnStyling:{cellBackgroundColor: colors.error_subtle, headerBackgroundColor: colors.error_subtle},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
accessor: "scheduledMeetings",
|
|
27
|
+
label: "Scheduled Meetings",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Performance Data",
|
|
35
|
+
columns: [
|
|
36
|
+
{
|
|
37
|
+
label: "Completion Metrics",
|
|
38
|
+
columns: [
|
|
39
|
+
{
|
|
40
|
+
accessor: "completedClasses",
|
|
41
|
+
label: "Completed Classes",
|
|
42
|
+
columnStyling:{cellBackgroundColor: colors.info, headerBackgroundColor: colors.info, fontColor: colors.white, headerFontColor: colors.white},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
accessor: "classCompletionRate",
|
|
46
|
+
label: "Class Completion Rate",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "Attendance",
|
|
52
|
+
columns: [
|
|
53
|
+
{
|
|
54
|
+
accessor: "attendanceRate",
|
|
55
|
+
label: "Attendance Rate",
|
|
56
|
+
columnStyling:{cellBackgroundColor: colors.info_subtle},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
accessor: "scheduledMeetings",
|
|
60
|
+
label: "Scheduled Meetings",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<AdvancedTable
|
|
72
|
+
columnDefinitions={columnDefinitions}
|
|
73
|
+
tableData={MOCK_DATA}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default AdvancedTableColumnStylingBackgroundMulti
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `columnStyling` prop can also be used to set background color for entire columns for the multi header variant as well.
|
|
2
|
+
|
|
3
|
+
It should be noted that `headerFontColor` and `headerBackgroundColor` in the multi header variant will only apply to the immediate header for the given column as shown here.
|
|
@@ -26,7 +26,8 @@ examples:
|
|
|
26
26
|
- advanced_table_column_styling_rails: Column Styling
|
|
27
27
|
- advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
|
|
28
28
|
- advanced_table_padding_control_rails: Padding Control using Column Styling
|
|
29
|
-
- advanced_table_background_control_rails:
|
|
29
|
+
- advanced_table_background_control_rails: Column Styling Background Color
|
|
30
|
+
- advanced_table_background_colors_rails: Column Styling Individual Cell Background Color
|
|
30
31
|
- advanced_table_column_border_color_rails: Column Group Border Color
|
|
31
32
|
|
|
32
33
|
|
|
@@ -75,6 +76,8 @@ examples:
|
|
|
75
76
|
- advanced_table_padding_control_per_row: Padding Control using Row Styling
|
|
76
77
|
- advanced_table_column_styling: Column Styling
|
|
77
78
|
- advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
|
|
79
|
+
- advanced_table_column_styling_background: Column Styling Background Color
|
|
80
|
+
- advanced_table_column_styling_background_multi: Column Styling Background Color with Multiple Headers
|
|
78
81
|
- advanced_table_padding_control: Padding Control using Column Styling
|
|
79
82
|
- advanced_table_column_border_color: Column Group Border Color
|
|
80
83
|
- advanced_table_fullscreen: Fullscreen
|
|
@@ -45,4 +45,6 @@ export { default as AdvancedTableWithCustomHeaderMultiHeader } from './_advanced
|
|
|
45
45
|
export { default as AdvancedTableSortPerColumn } from './_advanced_table_sort_per_column.jsx'
|
|
46
46
|
export { default as AdvancedTableSortPerColumnForMultiColumn } from './_advanced_table_sort_per_column_for_multi_column.jsx'
|
|
47
47
|
export { default as AdvancedTablePaddingControl } from './_advanced_table_padding_control.jsx'
|
|
48
|
-
export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
|
|
48
|
+
export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
|
|
49
|
+
export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
|
|
50
|
+
export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<%= object.render_select_all_header %>
|
|
6
6
|
<% end %>
|
|
7
7
|
<% header_row.each_with_index do |cell, cell_index| %>
|
|
8
|
-
<%
|
|
9
|
-
<%= pb_rails(
|
|
8
|
+
<% header_component = object.header_component_info(cell, cell_index, row_index) %>
|
|
9
|
+
<%= pb_rails(header_component[:name], props: header_component[:props]) do %>
|
|
10
10
|
<%= pb_rails("flex", props: { align: "center", justify: cell_index.zero? ? "start" : row_index === header_rows.size - 1 ? "end" : "center", text_align: (cell[:header_alignment] || "end") }) do %>
|
|
11
11
|
<% if cell_index.zero? && row_index === header_rows.size - 1 %>
|
|
12
12
|
<% if object.selectable_rows && object.enable_toggle_expansion != "none" %>
|
|
@@ -119,6 +119,59 @@ module Playbook
|
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
+
# Get header background color from column styling
|
|
123
|
+
def header_background_color(cell)
|
|
124
|
+
original_def = find_original_column_def_for_cell(cell)
|
|
125
|
+
return nil unless original_def
|
|
126
|
+
|
|
127
|
+
original_def.dig(:column_styling, :header_background_color)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Get header font color from column styling
|
|
131
|
+
def header_font_color(cell)
|
|
132
|
+
original_def = find_original_column_def_for_cell(cell)
|
|
133
|
+
return nil unless original_def
|
|
134
|
+
|
|
135
|
+
original_def.dig(:column_styling, :header_font_color)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Check if header has custom background color
|
|
139
|
+
def has_custom_header_background_color?(cell)
|
|
140
|
+
cell[:header_background_color].present?
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns component info for header cell (uses background kit if custom bg color)
|
|
144
|
+
def header_component_info(cell, cell_index, row_index)
|
|
145
|
+
header_id = cell[:accessor].present? ? cell[:accessor] : "header_#{row_index}_#{cell_index}"
|
|
146
|
+
classname = [th_classname(is_first_column: cell_index.zero?), ("last-header-cell" if cell[:is_last_in_group] && cell_index != 0)].compact.join(" ")
|
|
147
|
+
|
|
148
|
+
if has_custom_header_background_color?(cell)
|
|
149
|
+
component_name = "background"
|
|
150
|
+
component_props = {
|
|
151
|
+
background_color: cell[:header_background_color],
|
|
152
|
+
tag: "th",
|
|
153
|
+
classname: classname,
|
|
154
|
+
}
|
|
155
|
+
component_props[:html_options] = {
|
|
156
|
+
id: header_id,
|
|
157
|
+
colspan: cell[:colspan],
|
|
158
|
+
style: { color: cell[:header_font_color] },
|
|
159
|
+
}
|
|
160
|
+
component_props[:html_options][:style].delete(:color) unless cell[:header_font_color].present?
|
|
161
|
+
else
|
|
162
|
+
component_name = "table/table_header"
|
|
163
|
+
component_props = {
|
|
164
|
+
id: header_id,
|
|
165
|
+
colspan: cell[:colspan],
|
|
166
|
+
classname: classname,
|
|
167
|
+
sort_menu: cell[:accessor] ? cell[:sort_menu] : nil,
|
|
168
|
+
}
|
|
169
|
+
component_props[:html_options] = { style: { color: cell[:header_font_color] } } if cell[:header_font_color].present?
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
{ name: component_name, props: component_props }
|
|
173
|
+
end
|
|
174
|
+
|
|
122
175
|
private
|
|
123
176
|
|
|
124
177
|
# Find the original column definition for a cell
|
|
@@ -163,6 +216,8 @@ module Playbook
|
|
|
163
216
|
else
|
|
164
217
|
raw_styling = col[:column_styling] || {}
|
|
165
218
|
header_alignment = raw_styling[:header_alignment]
|
|
219
|
+
header_background_color = raw_styling[:header_background_color]
|
|
220
|
+
header_font_color = raw_styling[:header_font_color]
|
|
166
221
|
|
|
167
222
|
colspan = 1
|
|
168
223
|
cell_hash = {
|
|
@@ -172,6 +227,8 @@ module Playbook
|
|
|
172
227
|
sort_menu: col[:sort_menu],
|
|
173
228
|
is_last_in_group: is_last && current_depth.positive?,
|
|
174
229
|
header_alignment: header_alignment,
|
|
230
|
+
header_background_color: header_background_color,
|
|
231
|
+
header_font_color: header_font_color,
|
|
175
232
|
}
|
|
176
233
|
cell_hash[:id] = col[:id] if col[:id].present?
|
|
177
234
|
rows[current_depth] << cell_hash
|
|
@@ -61,7 +61,9 @@ type ContactProps = {
|
|
|
61
61
|
data?: { [key: string]: string }
|
|
62
62
|
dark?: boolean
|
|
63
63
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) }
|
|
64
|
+
iconEnabled?: boolean
|
|
64
65
|
id?: string
|
|
66
|
+
unstyled?: boolean
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
const Contact = (props: ContactProps): React.ReactElement => {
|
|
@@ -74,7 +76,9 @@ const Contact = (props: ContactProps): React.ReactElement => {
|
|
|
74
76
|
data = {},
|
|
75
77
|
dark = false,
|
|
76
78
|
htmlOptions = {},
|
|
79
|
+
iconEnabled = true,
|
|
77
80
|
id,
|
|
81
|
+
unstyled = false,
|
|
78
82
|
} = props
|
|
79
83
|
const ariaProps = buildAriaProps(aria)
|
|
80
84
|
const dataProps = buildDataProps(data)
|
|
@@ -85,6 +89,51 @@ const Contact = (props: ContactProps): React.ReactElement => {
|
|
|
85
89
|
className
|
|
86
90
|
)
|
|
87
91
|
|
|
92
|
+
const formattedValue = formatContact(contactValue, contactType)
|
|
93
|
+
const content = (
|
|
94
|
+
<>
|
|
95
|
+
{iconEnabled && (contactType === 'email' ? (
|
|
96
|
+
<Icon
|
|
97
|
+
className="svg-inline--fa envelope"
|
|
98
|
+
customIcon={envelopeIcon}
|
|
99
|
+
dark={dark}
|
|
100
|
+
fixedWidth
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<Icon
|
|
104
|
+
dark={dark}
|
|
105
|
+
fixedWidth
|
|
106
|
+
icon={contactTypeMap[contactType] || 'phone'}
|
|
107
|
+
/>
|
|
108
|
+
))}
|
|
109
|
+
{iconEnabled ? ` ${formattedValue} ` : formattedValue}
|
|
110
|
+
{contactDetail && (
|
|
111
|
+
<Caption
|
|
112
|
+
dark={dark}
|
|
113
|
+
size="xs"
|
|
114
|
+
tag="span"
|
|
115
|
+
text={contactDetail}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
</>
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
// When unstyled, render just the content without Body wrapper
|
|
122
|
+
if (unstyled) {
|
|
123
|
+
return (
|
|
124
|
+
<span
|
|
125
|
+
{...ariaProps}
|
|
126
|
+
{...dataProps}
|
|
127
|
+
{...htmlProps}
|
|
128
|
+
className={classes}
|
|
129
|
+
id={id}
|
|
130
|
+
>
|
|
131
|
+
{content}
|
|
132
|
+
</span>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Default styled mode with Body wrapper
|
|
88
137
|
return (
|
|
89
138
|
<div
|
|
90
139
|
{...ariaProps}
|
|
@@ -95,33 +144,11 @@ const Contact = (props: ContactProps): React.ReactElement => {
|
|
|
95
144
|
>
|
|
96
145
|
<Body
|
|
97
146
|
className="pb_contact_kit"
|
|
98
|
-
color=
|
|
147
|
+
color="light"
|
|
99
148
|
dark={dark}
|
|
100
149
|
tag="span"
|
|
101
150
|
>
|
|
102
|
-
|
|
103
|
-
<Icon
|
|
104
|
-
className="svg-inline--fa envelope"
|
|
105
|
-
customIcon={envelopeIcon}
|
|
106
|
-
dark={dark}
|
|
107
|
-
fixedWidth
|
|
108
|
-
/>
|
|
109
|
-
) : (
|
|
110
|
-
<Icon
|
|
111
|
-
dark={dark}
|
|
112
|
-
fixedWidth
|
|
113
|
-
icon={contactTypeMap[contactType] || 'phone'}
|
|
114
|
-
/>
|
|
115
|
-
)}
|
|
116
|
-
{` ${formatContact(contactValue, contactType)} `}
|
|
117
|
-
{contactDetail && (
|
|
118
|
-
<Caption
|
|
119
|
-
dark={dark}
|
|
120
|
-
size="xs"
|
|
121
|
-
tag="span"
|
|
122
|
-
text={contactDetail}
|
|
123
|
-
/>
|
|
124
|
-
)}
|
|
151
|
+
{content}
|
|
125
152
|
</Body>
|
|
126
153
|
</div>
|
|
127
154
|
)
|