Skip to content

Commit 9a4932a

Browse files
authored
[PLAY]-1741 Advanced Table Highlight In Rails (#4180)
**What does this PR do?** A clear and concise description with your runway ticket url. Allows the expanded rows on the Rails Advanced Table to be highlighted, so that the user can visibly tell which rows are expanded and which are not. [[PLAY]-1741](https://runway.powerhrg.com/backlog_items/PLAY-1741) **Screenshots:** Screenshots to visualize your addition/change <img width="1016" alt="Screenshot 2025-01-28 at 8 26 26 AM" src="https://github.com/user-attachments/assets/c2fa742c-1757-4ea4-9e8d-fca53de4a389" /> <img width="1017" alt="Screenshot 2025-01-28 at 8 26 59 AM" src="https://github.com/user-attachments/assets/05f18e91-ff39-4c9c-99e8-234027309c2d" /> **How to test?** Steps to confirm the desired behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See addition/change #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [ ] **TESTS** I have added test coverage to my code.
1 parent 33d89fb commit 9a4932a

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

playbook/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
}
9090
}
9191

92-
9392
.table-header-cells-active:first-child {
9493
color: $primary !important;
9594
}
@@ -179,7 +178,7 @@
179178
}
180179

181180
// Responsive Styles
182-
@media only screen and (max-width: $screen-xl-min) {
181+
@media only screen and (max-width: $screen-xl-min) {
183182
&[class*="advanced-table-responsive-scroll"] {
184183
border-radius: 4px;
185184
box-shadow: 1px 0 0 0px $border_light,
@@ -215,7 +214,7 @@
215214
.bg-white td:first-child {
216215
background-color: $white;
217216
}
218-
217+
219218
}
220219
}
221220
@media only screen and (min-width: $screen-xl-min) {
@@ -306,4 +305,4 @@
306305
}
307306
}
308307
}
309-
}
308+
}

playbook/app/pb_kits/playbook/pb_advanced_table/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ export default class PbAdvancedTable extends PbEnhancedElement {
133133
if (!elements.length) return;
134134

135135
const isVisible = elements[0].classList.contains("is-visible");
136-
if (isVisible) {
137-
this.hideElement(elements);
138-
this.displayDownArrow();
139-
} else {
140-
this.showElement(elements);
141-
this.displayUpArrow();
136+
137+
isVisible ? this.hideElement(elements) : this.showElement(elements);
138+
isVisible ? this.displayDownArrow() : this.displayUpArrow();
139+
140+
const row = this.element.closest("tr");
141+
if (row) {
142+
row.classList.toggle("bg-silver", !isVisible);
143+
row.classList.toggle("bg-white", isVisible);
142144
}
143145
}
144146

147+
145148
displayDownArrow() {
146149
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
147150
"inline-block";

playbook/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
<div style="padding-left: <%= depth * 1.25 %>em">
1515
<%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
1616
<% if index.zero? && object.row[:children].present? %>
17-
<button id="<%= "#{object.id}_#{object.row.object_id}" %>" class="gray-icon expand-toggle-icon" data-advanced-table="true" >
18-
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
19-
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
20-
</button>
17+
<button
18+
id="<%= "#{object.id}_#{object.row.object_id}" %>"
19+
class="gray-icon expand-toggle-icon"
20+
data-advanced-table="true">
21+
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
22+
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
23+
</button>
2124
<% end %>
2225
<%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
2326
<% if column[:custom_renderer].present? %>
@@ -42,4 +45,4 @@
4245
<% end %>
4346
<% end %>
4447
<% end %>
45-
<% end %>
48+
<% end %>

0 commit comments

Comments
 (0)