Skip to content

Commit

Permalink
[PBNTR-703] Add Expandable/Collapsible Rows to Basic Table Component …
Browse files Browse the repository at this point in the history
…- RAILS only (#4122)

[PBNTR-703](https://runway.powerhrg.com/backlog_items/PBNTR-703)

This PR adds the ability to add the collapsible kit to a table row on
the rails side! All new rails props match the react side.

<img width="842" alt="Screenshot 2025-01-14 at 9 56 51 AM"
src="https://github.com/user-attachments/assets/4904418f-5dab-4e0b-9774-6010fd46f58d"
/>


**How to test?** Steps to confirm the desired behavior:
1. Go to the table kit


#### 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.

---------

Co-authored-by: Carlos Lima <[email protected]>
  • Loading branch information
nickamantia and carloslimasd authored Jan 23, 2025
1 parent 8ef9bba commit 471dc72
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= pb_content_tag do %>
<%= pb_content_tag(
object.tag
) do %>
<%= content.presence %>
<% end %>
3 changes: 3 additions & 0 deletions playbook/app/pb_kits/playbook/pb_collapsible/collapsible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
module Playbook
module PbCollapsible
class Collapsible < Playbook::KitBase
prop :tag, type: Playbook::Props::Enum,
values: %w[h1 h2 h3 h4 h5 h6 p div span tr th td thead col],
default: "div"
def classname
generate_classname("pb_collapsible_kit")
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<% content = capture do %>
<%= pb_rails("card", props: { border_none: true, border_radius: "none", padding: "md" }) do %>
<%= pb_rails("body", props: { text: "Nested content inside a Table Row" }) %>
<% end %>
<% end %>

<%= pb_rails("table", props: { size: "sm" }) do %>
<%= pb_rails("table/table_head") do %>
<%= pb_rails("table/table_row") do %>
<%= pb_rails("table/table_header", props: { text: "Column 1"}) %>
<%= pb_rails("table/table_header", props: { text: "Column 2"}) %>
<%= pb_rails("table/table_header", props: { text: "Column 3"}) %>
<%= pb_rails("table/table_header", props: { text: "Column 4"}) %>
<%= pb_rails("table/table_header", props: { text: "Column 5"}) %>
<%= pb_rails("table/table_header", props: { text: ""}) %>
<% end %>
<% end %>
<%= pb_rails("table/table_body") do %>
<%= pb_rails("table/table_row", props: { collapsible: true, collapsible_content: content, collapsible_side_highlight: true, id: "1" }) do %>
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
<%= pb_rails("table/table_cell", props: { text_align: "right"}) do %>
<%= pb_rails("icon", props: { icon: "chevron-down", fixed_width: true, color: "primary" }) %>
<% end %>
<% end %>
<%= pb_rails("table/table_row") do %>
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
<%= pb_rails("table/table_cell", props: { text: ""}) %>
<% end %>
<%= pb_rails("table/table_row") do %>
<%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
<%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
<%= pb_rails("table/table_cell", props: { text: ""}) %>
<% end %>
<% end %>
<% end %>

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The `collapsible` prop can be used on any Table Row to add a collapsible area. Use the additional `collapsible_content` prop to add any content to the collapsible Row.
Please be aware that you will need to pass in an `id` to any table rows you want to be collapsible. Make sure every `id` is unique if you are using multipe collapsibles.
1 change: 1 addition & 0 deletions playbook/app/pb_kits/playbook/pb_table/docs/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ examples:
- table_with_subcomponents_rails: Table with Sub Components (Table Elements)
- table_with_subcomponents_as_divs: Table with Sub Components (Divs)
- table_outer_padding: Outer Padding
- table_with_collapsible: Table with Collapsible

react:
- table_sm: Small
Expand Down
Loading

0 comments on commit 471dc72

Please sign in to comment.