Skip to content

Commit 91e8705

Browse files
make the index a table again
1 parent b128001 commit 91e8705

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt

+27-11
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,40 @@
22

33
<div class="w-full">
44
<%% if notice.present? %>
5-
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%%= notice %></p>
5+
<p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-md bg-green-50" id="notice"><%%= notice %></p>
66
<%% end %>
77

8-
<div class="flex justify-between items-center">
9-
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
8+
<div class="flex items-center justify-between">
9+
<h1 class="text-4xl font-bold"><%= human_name.pluralize %></h1>
1010
<%%= link_to "New <%= human_name.downcase %>", new_<%= singular_route_name %>_path, class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white block font-medium" %>
1111
</div>
1212

13-
<div id="<%= plural_table_name %>" class="min-w-full">
13+
<div id="<%= plural_table_name %>" class="inline-block min-w-full mt-10">
1414
<%% if @<%= plural_table_name %>.any? %>
15-
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
16-
<%%= render <%= singular_table_name %> %>
17-
<p>
18-
<%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
19-
</p>
20-
<%% end %>
15+
<table class="min-w-full divide-y divide-gray-300">
16+
<thead>
17+
<tr>
18+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
19+
<th class="py-3.5 text-left font-semibold"><%= attribute.human_name %></th>
20+
<% end -%>
21+
<th class="py-3.5 text-left font-semibold">Actions</th>
22+
</tr>
23+
</thead>
24+
<tbody class="divide-y divide-gray-200">
25+
<%% @users.each do |user| %>
26+
<tr class="border-b">
27+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
28+
<td class="py-4 whitespace-nowrap"><%%= <%= singular_name %>.<%= attribute.column_name %> %></td>
29+
<% end -%>
30+
<td class="py-4 space-x-4 whitespace-nowrap">
31+
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "text-blue-600 hover:text-blue-900" %>
32+
</td>
33+
</tr>
34+
<%% end %>
35+
</tbody>
36+
</table>
2137
<%% else %>
22-
<p class="text-center my-10">No <%= human_name.downcase.pluralize %> found.</p>
38+
<p class="my-10 text-center">No <%= human_name.downcase.pluralize %> found.</p>
2339
<%% end %>
2440
</div>
2541
</div>

test/integration/user_journey_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fi
6868

6969
# TEST: presence of the generated file
7070
bin/rails generate scaffold post title:string body:text published:boolean
71-
grep -q "Show this post" app/views/posts/index.html.erb
71+
grep -q "Show" app/views/posts/index.html.erb
7272

7373
# TEST: contents of the css file
7474
bin/rails tailwindcss:build[verbose]

0 commit comments

Comments
 (0)