Skip to content

Commit

Permalink
[PLAY]-1741 Advanced Table Highlight In Rails (#4180)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
cmhorsey authored Jan 30, 2025
1 parent 33d89fb commit 9a4932a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
}
}


.table-header-cells-active:first-child {
color: $primary !important;
}
Expand Down Expand Up @@ -179,7 +178,7 @@
}

// Responsive Styles
@media only screen and (max-width: $screen-xl-min) {
@media only screen and (max-width: $screen-xl-min) {
&[class*="advanced-table-responsive-scroll"] {
border-radius: 4px;
box-shadow: 1px 0 0 0px $border_light,
Expand Down Expand Up @@ -215,7 +214,7 @@
.bg-white td:first-child {
background-color: $white;
}

}
}
@media only screen and (min-width: $screen-xl-min) {
Expand Down Expand Up @@ -306,4 +305,4 @@
}
}
}
}
}
15 changes: 9 additions & 6 deletions playbook/app/pb_kits/playbook/pb_advanced_table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,18 @@ export default class PbAdvancedTable extends PbEnhancedElement {
if (!elements.length) return;

const isVisible = elements[0].classList.contains("is-visible");
if (isVisible) {
this.hideElement(elements);
this.displayDownArrow();
} else {
this.showElement(elements);
this.displayUpArrow();

isVisible ? this.hideElement(elements) : this.showElement(elements);
isVisible ? this.displayDownArrow() : this.displayUpArrow();

const row = this.element.closest("tr");
if (row) {
row.classList.toggle("bg-silver", !isVisible);
row.classList.toggle("bg-white", isVisible);
}
}


displayDownArrow() {
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
"inline-block";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
<div style="padding-left: <%= depth * 1.25 %>em">
<%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
<% if index.zero? && object.row[:children].present? %>
<button id="<%= "#{object.id}_#{object.row.object_id}" %>" class="gray-icon expand-toggle-icon" data-advanced-table="true" >
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
</button>
<button
id="<%= "#{object.id}_#{object.row.object_id}" %>"
class="gray-icon expand-toggle-icon"
data-advanced-table="true">
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
</button>
<% end %>
<%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
<% if column[:custom_renderer].present? %>
Expand All @@ -42,4 +45,4 @@
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>

0 comments on commit 9a4932a

Please sign in to comment.