-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PBNTR-862]Testing Draggable Kit with Table Kit (#4234)
Testing to see if we can use our Draggable kit with Table kit on Rails side TLDR: - We can use it with the subcomponent structure, but we will need to add a `tag` prop for draggable_container AND draggable_item so we can set it to tbody and tr. - This is a good addition to the kit for the long run, we should add it on the React side as well - We can also build the draggable piece into the Table kit, but this should be enough to allow devs to use it https://github.com/user-attachments/assets/7611c048-ab4b-41dd-a3f0-aa07bd1148a0
- Loading branch information
Showing
7 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
playbook/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<% initial_items = [ | ||
{ | ||
id: "1", | ||
title: "Task 1", | ||
assignee_name: "Terry Miles", | ||
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg", | ||
}, | ||
{ | ||
id: "2", | ||
title: "Task 2", | ||
assignee_name: "Sophia Miles", | ||
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg", | ||
}, | ||
{ | ||
id: "3", | ||
title: "Task 3", | ||
assignee_name: "Alice Jones", | ||
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg", | ||
}, | ||
{ | ||
id: "4", | ||
title: "Task 4", | ||
assignee_name: "Mike James", | ||
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg", | ||
}, | ||
{ | ||
id: "5", | ||
title: "Task 5", | ||
assignee_name: "James Guy", | ||
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg", | ||
} | ||
] %> | ||
|
||
|
||
|
||
<%= pb_rails("draggable", props: {initial_items: initial_items}) do %> | ||
<%= pb_rails("table", props: { size: "sm", responsive:"none" }) do %> | ||
<%= pb_rails("table/table_head") do %> | ||
<%= pb_rails("table/table_row") do %> | ||
<%= pb_rails("table/table_header", props: { text: "id"}) %> | ||
<%= pb_rails("table/table_header", props: { text: "name"}) %> | ||
<%= pb_rails("table/table_header", props: { text: "task number"}) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= pb_rails("draggable/draggable_container", props: {tag:"tbody"}) do %> | ||
<% initial_items.each do |item| %> | ||
<%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id], tag:"tr"}) do %> | ||
<%= pb_rails("table/table_cell", props: { text: item[:id]}) %> | ||
<%= pb_rails("table/table_cell") do %> | ||
<%= pb_rails("flex", props:{align:"center"}) do %> | ||
<%= pb_rails("avatar", props: {size: "xs", image_url: item[:assignee_img]}) %> | ||
<%= pb_rails("body", props: {text: item[:assignee_name], padding_left:"sm"}) %> | ||
<% end %> | ||
<% end %> | ||
<%= pb_rails("table/table_cell", props: { text: item[:title]}) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The draggable kit can also be used in conjunction with the table kit to create draggable table rows. To do this, make use of the `tag` prop on the draggable_container to set it to 'tbody' and the same prop on the draggable_item to set that to 'tr'. This will create the functionality seen here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
playbook/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<%= pb_content_tag do %> | ||
<%= content.presence %> | ||
<% end %> | ||
<%= pb_content_tag(object.tag) do %> | ||
<%= content.presence %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
playbook/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters