playbook_ui 13.19.0.pre.alpha.PBNTR207tabledivsupport2245 → 13.19.0.pre.alpha.PBNTR211tablekitsubcomponentsreact2318

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +1 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +4 -4
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +1 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +1 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +1 -1
  9. data/app/pb_kits/playbook/pb_icon/_icon.tsx +28 -16
  10. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +5 -11
  11. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.jsx +44 -18
  12. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.md +4 -8
  13. data/app/pb_kits/playbook/pb_icon/icon.html.erb +6 -4
  14. data/app/pb_kits/playbook/pb_icon/icon.rb +27 -10
  15. data/app/pb_kits/playbook/pb_table/SubKits/_table_body.tsx +64 -0
  16. data/app/pb_kits/playbook/pb_table/SubKits/_table_cell.tsx +66 -0
  17. data/app/pb_kits/playbook/pb_table/SubKits/_table_head.tsx +64 -0
  18. data/app/pb_kits/playbook/pb_table/SubKits/_table_header.tsx +66 -0
  19. data/app/pb_kits/playbook/pb_table/SubKits/_table_row.tsx +74 -0
  20. data/app/pb_kits/playbook/pb_table/SubKits/index.tsx +5 -0
  21. data/app/pb_kits/playbook/pb_table/_table.tsx +99 -67
  22. data/app/pb_kits/playbook/pb_table/docs/_table_div.html.erb +26 -26
  23. data/app/pb_kits/playbook/pb_table/docs/_table_div.jsx +27 -26
  24. data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.jsx +24 -25
  25. data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents.html.erb +34 -0
  26. data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents.jsx +47 -0
  27. data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents_as_divs.html.erb +34 -0
  28. data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents_as_divs.jsx +48 -0
  29. data/app/pb_kits/playbook/pb_table/docs/example.yml +7 -2
  30. data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
  31. data/app/pb_kits/playbook/pb_table/styles/_all.scss +0 -1
  32. data/app/pb_kits/playbook/pb_table/styles/_content.scss +3 -3
  33. data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +15 -15
  34. data/app/pb_kits/playbook/pb_table/styles/_headers.scss +3 -3
  35. data/app/pb_kits/playbook/pb_table/styles/_hover.scss +11 -11
  36. data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +15 -15
  37. data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +15 -15
  38. data/app/pb_kits/playbook/pb_table/styles/_reset.scss +3 -3
  39. data/app/pb_kits/playbook/pb_table/styles/_side_highlight.scss +2 -2
  40. data/app/pb_kits/playbook/pb_table/styles/_single-line.scss +4 -4
  41. data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +2 -2
  42. data/app/pb_kits/playbook/pb_table/styles/_striped.scss +4 -4
  43. data/app/pb_kits/playbook/pb_table/styles/_structure.scss +22 -8
  44. data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +7 -7
  45. data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +14 -14
  46. data/app/pb_kits/playbook/pb_table/styles/_table_header.scss +2 -2
  47. data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +15 -15
  48. data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +3 -3
  49. data/app/pb_kits/playbook/pb_table/table.html.erb +1 -3
  50. data/app/pb_kits/playbook/pb_table/table.test.js +142 -1
  51. data/app/pb_kits/playbook/pb_table/table_body.html.erb +17 -0
  52. data/app/pb_kits/playbook/pb_table/table_body.rb +15 -0
  53. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +17 -0
  54. data/app/pb_kits/playbook/pb_table/table_cell.rb +17 -0
  55. data/app/pb_kits/playbook/pb_table/table_head.html.erb +17 -0
  56. data/app/pb_kits/playbook/pb_table/table_head.rb +15 -0
  57. data/app/pb_kits/playbook/pb_table/table_header.html.erb +49 -39
  58. data/app/pb_kits/playbook/pb_table/table_header.rb +8 -1
  59. data/app/pb_kits/playbook/pb_table/table_row.html.erb +17 -7
  60. data/app/pb_kits/playbook/pb_table/table_row.rb +8 -1
  61. data/dist/playbook-rails.js +6 -6
  62. data/lib/playbook/version.rb +1 -1
  63. metadata +18 -4
  64. data/app/pb_kits/playbook/pb_table/_table_row.tsx +0 -47
  65. data/app/pb_kits/playbook/pb_table/styles/_div_support.scss +0 -22
@@ -7,22 +7,22 @@ $table-dark-card-bg: $card_dark;
7
7
  &.table-md,
8
8
  &.table-lg {
9
9
  &.table-dark {
10
- thead, .thead {
11
- tr, .tr {
10
+ thead, .pb_table_thead {
11
+ tr, .pb_table_tr {
12
12
  border-color: $border_dark !important;
13
13
 
14
- th, .th {
14
+ th, .pb_table_th {
15
15
  border-color: $border_dark !important;
16
16
  color: $text_dk_light;
17
17
  }
18
18
  }
19
19
  }
20
- tbody, .tbody {
21
- tr, .tr {
20
+ tbody, .pb_table_tbody {
21
+ tr, .pb_table_tr {
22
22
  border-color: $border_dark;
23
23
  transition: none !important;
24
24
 
25
- td, .td {
25
+ td, .pb_table_td {
26
26
  border-color: $border_dark !important;
27
27
  color: $white;
28
28
 
@@ -31,7 +31,7 @@ $table-dark-card-bg: $card_dark;
31
31
  }
32
32
  }
33
33
  &:first-child {
34
- td, .td {
34
+ td, .pb_table_td {
35
35
  border-top-width: 0 !important;
36
36
  }
37
37
  }
@@ -54,9 +54,9 @@ $table-dark-card-bg: $card_dark;
54
54
  &.table-dark {
55
55
  background: none !important;
56
56
 
57
- tbody, .tbody {
58
- tr, .tr {
59
- td, .td {
57
+ tbody, .pb_table_tbody {
58
+ tr, .pb_table_tr {
59
+ td, .pb_table_td {
60
60
  background: $table-dark-card-bg !important;
61
61
  }
62
62
  }
@@ -64,15 +64,15 @@ $table-dark-card-bg: $card_dark;
64
64
  }
65
65
  }
66
66
  &.table-dark {
67
- tbody, .tbody {
68
- tr, .tr {
69
- td, .td {
67
+ tbody, .pb_table_tbody {
68
+ tr, .pb_table_tr {
69
+ td, .pb_table_td {
70
70
  &:first-child {
71
71
  border-top-color: $border_dark !important;
72
72
  }
73
73
  }
74
74
  &:first-child {
75
- td, .td {
75
+ td, .pb_table_td {
76
76
  border-top-width: 1px !important;
77
77
  }
78
78
  }
@@ -10,7 +10,7 @@ $text_align_values: (
10
10
  );
11
11
 
12
12
  [class^=pb_table] {
13
- thead, .thead {
13
+ thead, .pb_table_thead {
14
14
  [class^=pb_table_header_kit] {
15
15
  @each $align_name, $align_value in $text_align_values {
16
16
  &[class*=_align_#{$align_name}] {
@@ -32,7 +32,7 @@ $text_align_values: (
32
32
  }
33
33
 
34
34
  [class^=pb_table] {
35
- thead, .thead {
35
+ thead, .pb_table_thead {
36
36
  [class^=pb_th_active] {
37
37
  color: $primary !important;
38
38
  }
@@ -10,21 +10,21 @@
10
10
  width: 100%;
11
11
  background: none !important;
12
12
 
13
- thead, .thead {
14
- tr, .tr {
13
+ thead, .pb_table_thead {
14
+ tr, .pb_table_tr {
15
15
  left: $offscreen;
16
16
  position: absolute;
17
17
  top: $offscreen;
18
18
 
19
- th, .th {
19
+ th, .pb_table_th {
20
20
  display: block;
21
21
  visibility: visible;
22
22
  }
23
23
  }
24
24
  }
25
- tbody, .tbody {
26
- tr, .tr {
27
- td, .td {
25
+ tbody, .pb_table_tbody {
26
+ tr, .pb_table_tr {
27
+ td, .pb_table_td {
28
28
  display: block;
29
29
  visibility: visible;
30
30
  border-left-width: 1px !important;
@@ -63,7 +63,7 @@
63
63
  }
64
64
 
65
65
  &:first-child {
66
- td, .td {
66
+ td, .pb_table_td {
67
67
  &:first-child {
68
68
  margin-top: $space-xs !important;
69
69
  }
@@ -74,9 +74,9 @@
74
74
  &.table-card {
75
75
  background: none !important;
76
76
 
77
- tbody, .tbody {
78
- tr, .tr {
79
- td, .td {
77
+ tbody, .pb_table_tbody {
78
+ tr, .pb_table_tr {
79
+ td, .pb_table_td {
80
80
  background: $white !important;
81
81
  border-left-width: 1px !important;
82
82
  border-right-width: 1px !important;
@@ -98,8 +98,8 @@
98
98
  }
99
99
  @media (hover:hover) {
100
100
  &:hover {
101
- tbody, .tbody {
102
- tr, .tr {
101
+ tbody, .pb_table_tbody {
102
+ tr, .pb_table_tr {
103
103
  box-shadow: 0 0 0 $white !important;
104
104
  }
105
105
  }
@@ -108,9 +108,9 @@
108
108
  // reset the first and last to normalize
109
109
  @each $name, $value in $cell-pad-list {
110
110
  &.#{$name} {
111
- tbody, .tbody {
112
- tr, .tr {
113
- td, .td {
111
+ tbody, .pb_table_tbody {
112
+ tr, .pb_table_tr {
113
+ td, .pb_table_td {
114
114
  &:first-child,
115
115
  &:last-child {
116
116
  padding: $value $cell-gutter !important;
@@ -1,12 +1,12 @@
1
1
  [class^=pb_table] {
2
2
  &.vertical-border {
3
- td, th, .td, .th {
3
+ td, th, .pb_table_td, .pb_table_th {
4
4
  border-right: 1px solid $border_light !important;
5
5
  }
6
6
 
7
7
  @media screen and (min-width: $screen-xs-min) {
8
- tr:hover, .tr:hover {
9
- td:last-child, .td:last-child {
8
+ tr:hover, .pb_table_tr:hover {
9
+ td:last-child, .pb_table_td:last-child {
10
10
  border-right-color: darken($border_light, 10%) !important;
11
11
  }
12
12
  }
@@ -13,9 +13,7 @@
13
13
  class: object.classname,
14
14
  data: object.data,
15
15
  id: object.id) do %>
16
- <%= content_tag(:div, class: "div-table") do %>
17
- <%= content.presence %>
18
- <% end %>
16
+ <%= content.presence %>
19
17
  <% end %>
20
18
  <% end %>
21
19
  <% end %>
@@ -1,7 +1,58 @@
1
- import { ensureAccessible, renderKit } from "../utilities/test-utils"
1
+ import React from "react";
2
+ import { ensureAccessible, renderKit, render, screen } from "../utilities/test-utils"
2
3
 
3
4
  import Table from "./_table"
4
5
 
6
+ const DivsTable = () => {
7
+ return (
8
+ <>
9
+ <Table
10
+ data={{testid: "table"}}
11
+ size="sm"
12
+ tag="div"
13
+ >
14
+ <Table.Head tag="div">
15
+ <Table.Row tag="div">
16
+ <Table.Header tag="div">{"Column 1"}</Table.Header>
17
+ <Table.Header tag="div">{"Column 2"}</Table.Header>
18
+ </Table.Row>
19
+ </Table.Head>
20
+ <Table.Body tag="div">
21
+ <Table.Row tag="div">
22
+ <Table.Cell tag="div">{"Value 1"}</Table.Cell>
23
+ <Table.Cell tag="div">{"Value 2"}</Table.Cell>
24
+ </Table.Row>
25
+ </Table.Body>
26
+ </Table>
27
+ </>
28
+ );
29
+ };
30
+
31
+ const TableTagTable = () => {
32
+ return (
33
+ <>
34
+ <Table
35
+ data={{testid: "table"}}
36
+ size="sm"
37
+ >
38
+ <Table.Head>
39
+ <Table.Row>
40
+ <Table.Header>{"Column 1"}</Table.Header>
41
+ <Table.Header>{"Column 2"}</Table.Header>
42
+ </Table.Row>
43
+ </Table.Head>
44
+ <Table.Body>
45
+ <Table.Row>
46
+ <Table.Cell>{"Value 1"}</Table.Cell>
47
+ <Table.Cell>{"Value 2"}</Table.Cell>
48
+ </Table.Row>
49
+ </Table.Body>
50
+ </Table>
51
+ </>
52
+ );
53
+ };
54
+
55
+
5
56
  const props = {
6
57
  data: { testid: "table" },
7
58
  sticky: false
@@ -20,3 +71,93 @@ test("when striped is true", () => {
20
71
  const kit = renderKit(Table, props, { striped: true })
21
72
  expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card striped table-collapse-sm")
22
73
  })
74
+
75
+ test("Renders Table.Head subkit for Div Table", () => {
76
+ render (<DivsTable/>)
77
+
78
+ const kit = screen.getByTestId("table")
79
+ const head = kit.querySelector(".pb_table_thead")
80
+ expect(head).toBeInTheDocument()
81
+ expect(head.tagName).toBe("DIV")
82
+ })
83
+
84
+ test("Renders Table.Header subkit for Div Table", () => {
85
+ render (<DivsTable/>)
86
+
87
+ const kit = screen.getByTestId("table")
88
+ const head = kit.querySelector(".pb_table_th")
89
+ expect(head).toBeInTheDocument()
90
+ expect(head.tagName).toBe("DIV")
91
+ })
92
+
93
+ test("Renders Table.Body subkit for Div Table", () => {
94
+ render (<DivsTable/>)
95
+
96
+ const kit = screen.getByTestId("table")
97
+ const head = kit.querySelector(".pb_table_tbody")
98
+ expect(head).toBeInTheDocument()
99
+ expect(head.tagName).toBe("DIV")
100
+ })
101
+
102
+ test("Renders Table.Row subkit for Div Table", () => {
103
+ render (<DivsTable/>)
104
+
105
+ const kit = screen.getByTestId("table")
106
+ const head = kit.querySelector(".pb_table_tr")
107
+ expect(head).toBeInTheDocument()
108
+ expect(head.tagName).toBe("DIV")
109
+ })
110
+
111
+ test("Renders Table.Cell subkit for Div Table", () => {
112
+ render (<DivsTable/>)
113
+
114
+ const kit = screen.getByTestId("table")
115
+ const head = kit.querySelector(".pb_table_td")
116
+ expect(head).toBeInTheDocument()
117
+ expect(head.tagName).toBe("DIV")
118
+ })
119
+
120
+ test("Renders Table.Head subkit for HTML Table elements Table", () => {
121
+ render (<TableTagTable/>)
122
+
123
+ const kit = screen.getByTestId("table")
124
+ const head = kit.querySelector(".pb_table_thead")
125
+ expect(head).toBeInTheDocument()
126
+ expect(head.tagName).toBe("THEAD")
127
+ })
128
+
129
+ test("Renders Table.Header subkit for HTML Table elements Table", () => {
130
+ render (<TableTagTable/>)
131
+
132
+ const kit = screen.getByTestId("table")
133
+ const head = kit.querySelector(".pb_table_th")
134
+ expect(head).toBeInTheDocument()
135
+ expect(head.tagName).toBe("TH")
136
+ })
137
+
138
+ test("Renders Table.Body subkit for HTML Table elements Table", () => {
139
+ render (<TableTagTable/>)
140
+
141
+ const kit = screen.getByTestId("table")
142
+ const head = kit.querySelector(".pb_table_tbody")
143
+ expect(head).toBeInTheDocument()
144
+ expect(head.tagName).toBe("TBODY")
145
+ })
146
+
147
+ test("Renders Table.Row subkit for HTML Table elements Table", () => {
148
+ render (<TableTagTable/>)
149
+
150
+ const kit = screen.getByTestId("table")
151
+ const head = kit.querySelector(".pb_table_tr")
152
+ expect(head).toBeInTheDocument()
153
+ expect(head.tagName).toBe("TR")
154
+ })
155
+
156
+ test("Renders Table.Cell subkit for HTML Table elements Table", () => {
157
+ render (<TableTagTable/>)
158
+
159
+ const kit = screen.getByTestId("table")
160
+ const head = kit.querySelector(".pb_table_td")
161
+ expect(head).toBeInTheDocument()
162
+ expect(head.tagName).toBe("TD")
163
+ })
@@ -0,0 +1,17 @@
1
+ <% if object.tag == "table" %>
2
+ <%= content_tag(:tbody,
3
+ aria: object.aria,
4
+ class: object.classname,
5
+ data: object.data,
6
+ id: object.id) do %>
7
+ <%= content.presence %>
8
+ <% end %>
9
+ <% else %>
10
+ <%= content_tag(:div,
11
+ aria: object.aria,
12
+ class: object.classname,
13
+ data: object.data,
14
+ id: object.id) do %>
15
+ <%= content.presence %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbTable
5
+ class TableBody < Playbook::KitBase
6
+ prop :tag, type: Playbook::Props::Enum,
7
+ values: %w[table div],
8
+ default: "table"
9
+
10
+ def classname
11
+ generate_classname("pb_table_tbody")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ <% if object.tag == "table" %>
2
+ <%= content_tag(:td,
3
+ aria: object.aria,
4
+ class: object.classname,
5
+ data: object.data,
6
+ id: object.id) do %>
7
+ <%= content.presence || object.text %>
8
+ <% end %>
9
+ <% else %>
10
+ <%= content_tag(:div,
11
+ aria: object.aria,
12
+ class: object.classname,
13
+ data: object.data,
14
+ id: object.id) do %>
15
+ <%= content.presence || object.text %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbTable
5
+ class TableCell < Playbook::KitBase
6
+ prop :tag, type: Playbook::Props::Enum,
7
+ values: %w[table div],
8
+ default: "table"
9
+ prop :text, type: Playbook::Props::String,
10
+ default: ""
11
+
12
+ def classname
13
+ generate_classname("pb_table_td")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ <% if object.tag == "table" %>
2
+ <%= content_tag(:thead,
3
+ aria: object.aria,
4
+ class: object.classname,
5
+ data: object.data,
6
+ id: object.id) do %>
7
+ <%= content.presence %>
8
+ <% end %>
9
+ <% else %>
10
+ <%= content_tag(:div,
11
+ aria: object.aria,
12
+ class: object.classname,
13
+ data: object.data,
14
+ id: object.id) do %>
15
+ <%= content.presence %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbTable
5
+ class TableHead < Playbook::KitBase
6
+ prop :tag, type: Playbook::Props::Enum,
7
+ values: %w[table div],
8
+ default: "table"
9
+
10
+ def classname
11
+ generate_classname("pb_table_thead")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,47 +1,57 @@
1
- <%= content_tag(:th,
2
- colspan: object.colspan,
3
- aria: object.aria,
4
- class: object.classname,
5
- data: object.data,
6
- id: "pb-th#{object.id}" ) do %>
7
- <% unless sorting_style? %>
8
- <%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_nolink" }) do %>
9
- <%= content.presence || object.text %>
10
- <% end %>
11
- <% else %>
12
- <%= link_to next_link, style: link_style do %>
13
- <%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_link" }) do %>
1
+ <% if object.tag == "table" %>
2
+ <%= content_tag(:th,
3
+ colspan: object.colspan,
4
+ aria: object.aria,
5
+ class: object.classname,
6
+ data: object.data,
7
+ id: "pb-th#{object.id}" ) do %>
8
+ <% unless sorting_style? %>
9
+ <%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_nolink" }) do %>
14
10
  <%= content.presence || object.text %>
15
- <% if sorting_style? %>
16
- <%= pb_rails("icon", props: { icon: object.sort_icon(active_item[:direction], active_item[:active]),
17
- fixed_width: true,
18
- classname: active_item.any? ? "pb_th_active" : "",
19
- padding_left: "xs" }) %>
11
+ <% end %>
12
+ <% else %>
13
+ <%= link_to next_link, style: link_style do %>
14
+ <%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_link" }) do %>
15
+ <%= content.presence || object.text %>
16
+ <% if sorting_style? %>
17
+ <%= pb_rails("icon", props: { icon: object.sort_icon(active_item[:direction], active_item[:active]),
18
+ fixed_width: true,
19
+ classname: active_item.any? ? "pb_th_active" : "",
20
+ padding_left: "xs" }) %>
21
+ <% end %>
20
22
  <% end %>
21
23
  <% end %>
22
- <% end %>
23
- <% if use_dropdown_select %>
24
- <%= pb_rails("popover", props: { classname: "pb_filter_sort_menu",
25
- close_on_click: "outside",
26
- trigger_element_id: "pb-th#{object.id}",
27
- tooltip_id: "sort-filter-btn-tooltip#{object.id}",
28
- position: object.placement ,
29
- padding: 'none'}) do %>
30
- <%= pb_rails("nav", props: {classname: "pb_table_header_dropdown"}) do %>
31
- <% object.sort_items.each do |sort_item| %>
32
- <% item = active_or_first_item(sort_items_for(sort_item)) %>
33
- <%= pb_rails("nav/item", props: {
34
- text: item[:item],
35
- link: next_link(sort_item: sort_item),
36
- highlighted_border: false,
37
- padding: "xs",
38
- icon_right: sort_icon(item[:direction], item[:active]),
39
- active: item[:active],
40
- classname: "header_nav_item"
41
- }) %>
24
+ <% if use_dropdown_select %>
25
+ <%= pb_rails("popover", props: { classname: "pb_filter_sort_menu",
26
+ close_on_click: "outside",
27
+ trigger_element_id: "pb-th#{object.id}",
28
+ tooltip_id: "sort-filter-btn-tooltip#{object.id}",
29
+ position: object.placement ,
30
+ padding: 'none'}) do %>
31
+ <%= pb_rails("nav", props: {classname: "pb_table_header_dropdown"}) do %>
32
+ <% object.sort_items.each do |sort_item| %>
33
+ <% item = active_or_first_item(sort_items_for(sort_item)) %>
34
+ <%= pb_rails("nav/item", props: {
35
+ text: item[:item],
36
+ link: next_link(sort_item: sort_item),
37
+ highlighted_border: false,
38
+ padding: "xs",
39
+ icon_right: sort_icon(item[:direction], item[:active]),
40
+ active: item[:active],
41
+ classname: "header_nav_item"
42
+ }) %>
43
+ <% end %>
42
44
  <% end %>
43
45
  <% end %>
44
46
  <% end %>
45
47
  <% end %>
46
48
  <% end %>
47
- <% end %>
49
+ <% else %>
50
+ <%= content_tag(:div,
51
+ aria: object.aria,
52
+ class: object.classname,
53
+ data: object.data,
54
+ id: object.id) do %>
55
+ <%= content.presence || object.text %>
56
+ <% end %>
57
+ <% end %>
@@ -23,9 +23,16 @@ module Playbook
23
23
  default: ""
24
24
  prop :sort_dropdown, type: Playbook::Props::Boolean,
25
25
  default: false
26
+ prop :tag, type: Playbook::Props::Enum,
27
+ values: %w[table div],
28
+ default: "table"
26
29
 
27
30
  def classname
28
- generate_classname("pb_table_header_kit", align_class)
31
+ generate_classname("pb_table_header_kit", align_class) + tag_class
32
+ end
33
+
34
+ def tag_class
35
+ " pb_table_th"
29
36
  end
30
37
 
31
38
  def align_class
@@ -1,7 +1,17 @@
1
- <%= content_tag(:tr,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id) do %>
6
- <%= content.presence %>
7
- <% end %>
1
+ <% if object.tag == "table" %>
2
+ <%= content_tag(:tr,
3
+ aria: object.aria,
4
+ class: object.classname,
5
+ data: object.data,
6
+ id: object.id) do %>
7
+ <%= content.presence %>
8
+ <% end %>
9
+ <% else %>
10
+ <%= content_tag(:div,
11
+ aria: object.aria,
12
+ class: object.classname,
13
+ data: object.data,
14
+ id: object.id) do %>
15
+ <%= content.presence %>
16
+ <% end %>
17
+ <% end %>
@@ -5,14 +5,21 @@ module Playbook
5
5
  class TableRow < Playbook::KitBase
6
6
  prop :side_highlight_color, type: Playbook::Props::String,
7
7
  default: "none"
8
+ prop :tag, type: Playbook::Props::Enum,
9
+ values: %w[table div],
10
+ default: "table"
8
11
 
9
12
  def classname
10
- generate_classname("pb_table_row_kit", side_highlight_class)
13
+ generate_classname("pb_table_row_kit", side_highlight_class) + tag_class
11
14
  end
12
15
 
13
16
  def side_highlight_class
14
17
  side_highlight_color.present? ? "side_highlight_#{side_highlight_color}" : nil
15
18
  end
19
+
20
+ def tag_class
21
+ " pb_table_tr"
22
+ end
16
23
  end
17
24
  end
18
25
  end