|
17 | 17 | </div> |
18 | 18 | <% end %> |
19 | 19 |
|
20 | | - <!-- Construct columns sizes string from individual col_size parameters, include actions if present --> |
21 | | - <% col_list = columns.map { |c| c.col_size || "minmax(0, 1fr)" }.to_a %> |
22 | | - <% col_list << "50px" if has_actions? %> |
23 | | - <% column_sizes = col_list.join(" ") %> |
| 20 | + <!-- Construct columns sizes string from individual col_size parameters --> |
| 21 | + <% column_sizes = columns.map { |c| c.col_size || "minmax(0, 1fr)" }.join(" ") %> |
24 | 22 |
|
25 | 23 | <!-- Each row (including header) is its own rounded box --> |
26 | 24 | <div class="mb-2"> |
27 | 25 | <div class="card ui-enter-item bg-neutral rounded-lg" style="--ui-enter-delay: 80ms;"> |
28 | | - <div class="p-4 grid items-center gap-4" style="grid-template-columns: <%= column_sizes %>"> |
| 26 | + <div class="p-4 grid items-stretch gap-4" style="grid-template-columns: <%= column_sizes %>"> |
29 | 27 | <% columns.each do |column| %> |
30 | | - <div class="text-sm font-semibold text-neutral-content"><%= column.header %></div> |
31 | | - <% end %> |
32 | | - <% if has_actions? %> |
33 | | - <div class="text-sm font-semibold text-neutral-content text-center"><%= t("shared.index_table_component.actions.label") %></div> |
| 28 | + <div class="text-sm font-semibold text-neutral-content flex items-center"><%= column.header %></div> |
34 | 29 | <% end %> |
35 | 30 | </div> |
36 | 31 | </div> |
37 | 32 | </div> |
38 | 33 |
|
39 | | - <div class="space-y-2" data-controller="table-actions-dropdown" data-action="click@window->table-actions-dropdown#handleDocumentClick"> |
| 34 | + <div class="space-y-2"> |
40 | 35 | <% records.each_with_index do |record, index| %> |
41 | | - <% record_actions = actions_for(record) %> |
42 | 36 | <div |
43 | 37 | data-index-table-component-target="row" |
44 | 38 | class="card ui-enter-item bg-white rounded-lg group transition-shadow relative overflow-visible shadow-sm<%= " cursor-pointer hover:shadow-md" if clickable_rows %>" |
45 | | - style="--ui-enter-delay: <%= 120 + ((index % 15) * 35) %>ms;" |
46 | | - <% if clickable_rows %> |
47 | | - data-action="click->table-actions-dropdown#navigateToRecord" |
48 | | - data-record-path="<%= row_path_for(record) %>" |
49 | | - <% end %>> |
50 | | - <div class="p-3 grid items-center gap-4 rounded-lg<%= " group-hover:bg-secondary/30 transition-colors" if clickable_rows %>" style="grid-template-columns: <%= column_sizes %>"> |
51 | | - <% columns.each do |column| %> |
52 | | - <div class="text-sm text-base-content"><%= render_cell_content(record, column) %></div> |
53 | | - <% end %> |
54 | | - <% if has_actions? %> |
55 | | - <button type="button" |
56 | | - class="flex items-center justify-center w-full hover:text-base-content transition-colors" |
57 | | - data-action="click->table-actions-dropdown#openMenu"> |
58 | | - <%= render IconComponent.new(icon: "ellipsis-v", size: :sm, classes: "text-base-content/50 hover:text-base-content transition-colors") %> |
59 | | - </button> |
60 | | - <% end %> |
61 | | - </div> |
62 | | - |
63 | | - <% if has_actions? && record_actions.any? %> |
64 | | - <div class="hidden ui-enter-item absolute top-full right-0 mt-1 z-50 bg-base-100 rounded-lg border border-base-300 shadow-lg min-w-48 py-1" data-table-actions-dropdown-target="menu"> |
65 | | - <% record_actions.each do |action| %> |
66 | | - <% turbo_data = { turbo_method: action[:method] }.compact %> |
67 | | - <% turbo_data[:turbo_confirm] = action[:confirm] if action[:confirm] %> |
68 | | - <% if action[:turbo_stream] %> |
69 | | - <% turbo_data[:turbo_stream] = true %> |
70 | | - <% end %> |
71 | | - <%= link_to(action[:path], data: turbo_data, class: "group/menu-item flex items-center gap-3 px-4 py-2 text-sm text-base-content hover:bg-primary/30 transition-colors") do %> |
72 | | - <% if action[:icon] %> |
73 | | - <%= render IconComponent.new(icon: action[:icon], size: :sm, classes: "text-base-content/50 group-hover/menu-item:text-primary transition-colors") %> |
74 | | - <% end %> |
75 | | - <span><%= action[:label] %></span> |
| 39 | + style="--ui-enter-delay: <%= 120 + ((index % 15) * 35) %>ms;"> |
| 40 | + <div class="p-3 grid items-stretch gap-4 rounded-lg<%= " group-hover:bg-secondary/30 transition-colors" if clickable_rows %>" style="grid-template-columns: <%= column_sizes %>"> |
| 41 | + <% columns.each do |column| %> |
| 42 | + <%= render_cell_wrapper( |
| 43 | + record, |
| 44 | + column, |
| 45 | + classes: class_names( |
| 46 | + "text-sm text-base-content min-w-0 w-full h-full flex items-center", |
| 47 | + row_clickable_for?(record, column) && "block" |
| 48 | + ) |
| 49 | + ) do %> |
| 50 | + <%= render_cell_content(record, column) %> |
76 | 51 | <% end %> |
77 | 52 | <% end %> |
78 | 53 | </div> |
79 | | - <% end %> |
80 | | - </div> |
81 | | - <% end %> |
82 | | - <div data-index-table-component-target="emptyRow" class="card ui-enter-item bg-white rounded-lg shadow-sm <%= "hidden" unless empty? %>" style="--ui-enter-delay: 120ms;"> |
83 | | - <div class="flex justify-center p-3 items-center"> |
84 | | - <div class="text-sm text-base-content/40 font-bold"><%= t("shared.index_table_component.no_entries") %></div> |
| 54 | + </div> |
| 55 | + <% end %> |
| 56 | + <div data-index-table-component-target="emptyRow" class="card ui-enter-item bg-white rounded-lg shadow-sm <%= "hidden" unless empty? %>" style="--ui-enter-delay: 120ms;"> |
| 57 | + <div class="flex justify-center p-3 items-center"> |
| 58 | + <div class="text-sm text-base-content/40 font-bold"><%= t("shared.index_table_component.no_entries") %></div> |
| 59 | + </div> |
85 | 60 | </div> |
86 | 61 | </div> |
87 | | -</div> |
88 | 62 |
|
89 | | -<div class="flex justify-center mt-4"> |
90 | | - <div class="join hidden" data-index-table-component-target="pagination"> |
91 | | - <button class="join-item btn btn-sm" data-action="index-table-component#previousPage" data-prev><</button> |
92 | | - <span class="join-item btn btn-sm no-animation pointer-events-none" data-index-table-component-target="pageInfo"></span> |
93 | | - <button class="join-item btn btn-sm" data-action="index-table-component#nextPage" data-next>></button> |
| 63 | + <div class="flex justify-center mt-4"> |
| 64 | + <div class="join hidden" data-index-table-component-target="pagination"> |
| 65 | + <button class="join-item btn btn-sm" data-action="index-table-component#previousPage" data-prev><</button> |
| 66 | + <span class="join-item btn btn-sm no-animation pointer-events-none" data-index-table-component-target="pageInfo"></span> |
| 67 | + <button class="join-item btn btn-sm" data-action="index-table-component#nextPage" data-next>></button> |
| 68 | + </div> |
94 | 69 | </div> |
95 | 70 | </div> |
96 | | -</div> |
0 commit comments