Skip to content

Commit 3ff2c31

Browse files
committed
Refactor topic views to avoid inline stylings
1 parent 62972aa commit 3ff2c31

File tree

9 files changed

+178
-257
lines changed

9 files changed

+178
-257
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%= form_for :provider, url: provider_settings_path, method: :put, data: { controller: "topics", topics_target: "chooseForm", turbo_frame: "topics", turbo_action: "advance" } do |f| %>
2-
<div style="display:flex; flex-wrap:wrap; gap:0.75rem; align-items:center;">
3-
<label for="provider_id" class="input-label" style="margin-bottom:0;">Provider</label>
4-
<div style="position:relative; min-width: 220px; max-width: 100%; width: 320px;">
2+
<div class="flex flex-wrap gap-3 items-center">
3+
<label for="provider_id" class="input-label m-0">Provider</label>
4+
<div class="relative min-w-[220px] max-w-full w-80">
55
<%= f.select :id,
66
options_from_collection_for_select(providers, :id, :name),
77
{ prompt: "Change provider" },
@@ -12,8 +12,3 @@
1212
</div>
1313
</div>
1414
<% end %>
15-
16-
<style>
17-
form[data-topics-target="chooseForm"] { max-width: 100%; }
18-
form[data-topics-target="chooseForm"] select { max-width: 100%; }
19-
</style>

app/views/topics/_form.html.erb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,15 @@
141141
</label>
142142

143143

144-
<div style="display: flex; justify-content: space-between; align-items: center; padding-top: 2rem; border-top: 1px solid #f3f4f6; margin-top: 2rem;">
145-
<div style="display: flex; gap: 1rem;">
146-
<%= f.submit "Save Topic", data: { upload_target: "submitButton" }, class: "bg-gradient-green", style: "color: white; font-weight: 600; padding: 0.75rem 2rem; border-radius: 0.5rem; border: none; cursor: pointer; font-size: 0.875rem; box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3); transition: all 0.2s;" %>
144+
<div class="flex justify-between items-center pt-8 border-t border-gray-100 mt-8">
145+
<div class="flex gap-4">
146+
<%= f.submit "Save Topic", data: { upload_target: "submitButton" }, class: "bg-gradient-green text-white font-semibold py-3 px-8 rounded-lg border-0 cursor-pointer text-sm shadow-md transition-all hover:-translate-y-0.5" %>
147147
<%= link_to "Back to Topics", topics_path,
148-
class: "topic-form-cancel-btn",
149-
style: "background: #f3f4f6; color: #6b7280; font-weight: 600; padding: 0.75rem 2rem; border-radius: 0.5rem; text-decoration: none; font-size: 0.875rem; transition: all 0.2s; display: inline-block;" %>
148+
class: "bg-gray-100 text-gray-500 font-semibold py-3 px-8 rounded-lg no-underline text-sm transition-all hover:bg-gray-200" %>
150149
</div>
151150

152151
<% if topic.persisted? %>
153-
<div style="color: #6b7280; font-size: 0.75rem;">
152+
<div class="text-gray-500 text-xs">
154153
Last updated: <%= topic.updated_at.strftime("%B %d, %Y at %I:%M %p") %>
155154
</div>
156155
<% end %>

app/views/topics/_list.html.erb

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
<tbody>
22
<% if @topics.any? %>
33
<% @topics.each do |topic| %>
4-
<tr style="border-bottom: 1px solid #f1f5f9; transition: all 0.2s;" onmouseover="this.style.backgroundColor='#f8fafc'" onmouseout="this.style.backgroundColor='white'">
4+
<tr class="border-b border-gray-100 transition-all hover:bg-gray-50">
55
<!-- Title -->
6-
<td style="padding: 1.25rem 1.5rem;">
7-
<div style="display: flex; flex-direction: column; align-items: center; gap: 0.25rem;">
8-
<div style="font-weight: 600; color: #111827; font-size: 0.95rem;"><%= topic.title %></div>
9-
<div style="color: #6b7280; font-size: 0.75rem;">Published <%= topic.published_at&.strftime('%b %d, %Y') %></div>
6+
<td class="table-cell">
7+
<div class="flex flex-col items-center gap-1">
8+
<div class="font-semibold text-gray-900 text-sm"><%= topic.title %></div>
9+
<div class="text-gray-500 text-xs">Published <%= topic.published_at&.strftime('%b %d, %Y') %></div>
1010
</div>
1111
</td>
1212

1313
<!-- Description -->
14-
<td class="hide-mobile" style="padding: 1.25rem 1.5rem; color: #374151; font-size: 0.875rem;">
14+
<td class="hide-mobile table-cell text-gray-700 text-sm">
1515
<% if topic.description.present? %>
1616
<%= truncate(topic.description, length: 60, omission: '…') %>
1717
<% else %>
18-
<span style="color: #94a3b8; font-style: italic;">No description</span>
18+
<span class="text-gray-400 italic">No description</span>
1919
<% end %>
2020
</td>
2121

2222
<!-- UID -->
23-
<td class="hide-mobile" style="padding: 1.25rem 1.5rem; color: #6b7280; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem;">
23+
<td class="hide-mobile table-cell text-gray-500 font-mono text-xs">
2424
<%= topic.uid.present? ? truncate(topic.uid, length: 12, omission: '…') : '-' %>
2525
</td>
2626

2727
<!-- Language -->
28-
<td style="padding: 1.25rem 1.5rem;">
29-
<span style="background: #e0e7ff; color: #3730a3; padding: 0.25rem 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600;">
28+
<td class="table-cell">
29+
<span class="bg-indigo-100 text-indigo-900 py-1 px-2 rounded-md text-xs font-semibold">
3030
<%= topic.language.name %>
3131
</span>
3232
</td>
3333

3434
<!-- Provider -->
35-
<td class="hide-mobile" style="padding: 1.25rem 1.5rem; color: #374151; font-size: 0.875rem;">
35+
<td class="hide-mobile table-cell text-gray-700 text-sm">
3636
<%= topic.provider.name %>
3737
</td>
3838

3939
<!-- Documents count -->
40-
<td style="padding: 1.25rem 1.5rem;">
41-
<span class="bg-gradient-amber" style="color: white; padding: 0.25rem 0.5rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 700;">
40+
<td class="table-cell">
41+
<span class="bg-gradient-amber text-white py-1 px-2 rounded-md text-xs font-bold">
4242
<%= topic.documents.size %>
4343
</span>
4444
</td>
4545

4646
<!-- State -->
47-
<td style="padding: 1.25rem 1.5rem;">
47+
<td class="table-cell">
4848
<% if topic.active? %>
49-
<span style="background: #dcfce7; color: #166534; padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600;">Active</span>
49+
<span class="bg-green-100 text-green-800 py-1 px-2 rounded-full text-xs font-semibold">Active</span>
5050
<% else %>
51-
<span style="background: #fee2e2; color: #991b1b; padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600;">Archived</span>
51+
<span class="bg-red-100 text-red-800 py-1 px-2 rounded-full text-xs font-semibold">Archived</span>
5252
<% end %>
5353
</td>
5454

5555
<!-- Actions -->
56-
<td class="actions-col" style="padding: 1.25rem 1.5rem; text-align: right;">
57-
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
58-
<%= link_to topic_path(topic, search: search_params), style: "background: #3b82f6; color: white; padding: 0.5rem 0.75rem; border-radius: 0.375rem; text-decoration: none; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.375rem; transition: all 0.2s;", data: { turbo: false } do %>
59-
<svg style="width: 0.875rem; height: 0.875rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
56+
<td class="actions-col table-cell text-right">
57+
<div class="flex gap-2 justify-end">
58+
<%= link_to topic_path(topic, search: search_params), class: "btn-view", data: { turbo: false } do %>
59+
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
6060
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
6161
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
6262
</svg>
6363
<span>View</span>
6464
<% end %>
65-
<%= link_to edit_topic_path(topic), style: "background: #6b7280; color: white; padding: 0.5rem 0.75rem; border-radius: 0.375rem; text-decoration: none; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.375rem; transition: all 0.2s;", data: { testid: topic.id, turbo: false } do %>
66-
<svg style="width: 0.875rem; height: 0.875rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
65+
<%= link_to edit_topic_path(topic), class: "btn-edit", data: { testid: topic.id, turbo: false } do %>
66+
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
6767
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
6868
</svg>
6969
<span>Edit</span>
@@ -76,22 +76,14 @@
7676
</tbody>
7777

7878
<% unless @topics.any? %>
79-
<!-- Empty state displayed outside the table -->
80-
<div style="padding: 3rem 1.5rem; text-align: center;">
81-
<div style="color: #9ca3af;">
82-
<svg style="width: 3rem; height: 3rem; margin: 0 auto 1rem; color: #d1d5db;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
79+
<!-- Empty state -->
80+
<div class="empty-state">
81+
<div class="text-gray-400">
82+
<svg class="w-12 h-12 mx-auto mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
8383
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
8484
</svg>
85-
<p style="font-size: 1rem; font-weight: 500; color: #6b7280; margin: 0;">No topics found</p>
86-
<p style="font-size: 0.875rem; color: #9ca3af; margin: 0.5rem 0 0 0;">Try adjusting your search filters or create a new topic.</p>
85+
<p class="text-base font-medium text-gray-500 m-0">No topics found</p>
86+
<p class="text-sm text-gray-400 mt-2 m-0">Try adjusting your search filters or create a new topic.</p>
8787
</div>
8888
</div>
8989
<% end %>
90-
91-
<style>
92-
/* Action button hover effects */
93-
a[href*="topics/"]:hover { transform: translateY(-1px); }
94-
a[href*="topics/"][style*="background: #3b82f6"]:hover { background: #2563eb !important; }
95-
a[href*="edit"]:hover { background: #4b5563 !important; }
96-
tbody tr:hover td:first-child > div > div:first-child { transform: scale(1.05); }
97-
</style>

app/views/topics/_search.html.erb

Lines changed: 24 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<div style="background: white; border-radius: 1rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); overflow: hidden;">
2-
<div style="background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); padding: 1.5rem; border-bottom: 1px solid #bae6fd;">
3-
<div style="display: flex; align-items: center; gap: 0.75rem;">
4-
<div style="background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); color: white; padding: 0.5rem; border-radius: 0.5rem;">
5-
<svg style="width: 1.25rem; height: 1.25rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1+
<div class="card-elevated overflow-hidden">
2+
<div class="bg-gradient-to-br from-sky-50 to-cyan-50 p-6 border-b border-sky-200">
3+
<div class="flex-center-sm">
4+
<div class="bg-gradient-to-br from-sky-500 to-sky-600 text-white p-2 rounded-lg">
5+
<svg class="icon-size-md" fill="none" stroke="currentColor" viewBox="0 0 24 24">
66
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
77
</svg>
88
</div>
9-
<h3 style="font-size: 1.125rem; font-weight: 600; color: #0c4a6e; margin: 0;">Search & Filter Topics</h3>
9+
<h3 class="text-lg font-semibold text-sky-900 m-0">Search & Filter Topics</h3>
1010
</div>
1111
</div>
12-
<div style="padding: 1.5rem;">
12+
<div class="card-body-sm">
1313
<%= form_for :search, url: topics_path, method: :get, data: { controller: "topics", topics_target: "searchForm", turbo_frame: "topic-list", turbo_action: "advance" } do |f| %>
14-
<div id="topics-search-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; align-items: start;">
14+
<div id="topics-search-grid" class="form-grid-auto items-start">
1515
<!-- Query -->
1616
<div class="form-grid-full">
1717
<%= f.label :query, class: "input-label" %>
@@ -23,11 +23,11 @@
2323
</div>
2424

2525
<!-- Language & Tags -->
26-
<div style="min-width:0; grid-column: 1 / -1;">
27-
<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:1rem; align-items:start;">
28-
<div style="position:relative;">
26+
<div class="min-w-0 col-span-full">
27+
<div class="grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-4 items-start">
28+
<div class="relative">
2929
<%= f.label :language_id, "Language", class: "input-label" %>
30-
<div style="position:relative;">
30+
<div class="relative">
3131
<%= f.select :language_id,
3232
options_from_collection_for_select(languages, :id, :name, params.dig(:search, :language_id)),
3333
{ prompt: "Select language" },
@@ -37,7 +37,7 @@
3737
</div>
3838
</div>
3939

40-
<div data-controller="select-tags" style="position:relative;">
40+
<div data-controller="select-tags" class="relative">
4141
<%= f.label :tag_list, "Tags", class: "input-label" %>
4242
<%= f.select :tag_list,
4343
options_for_select(Tag.order(:name).pluck(:name), Array(params.dig(:search, :tag_list))),
@@ -51,9 +51,9 @@
5151
</div>
5252

5353
<!-- Year -->
54-
<div style="min-width:0; position:relative;">
54+
<div class="min-w-0 relative">
5555
<%= f.label :year, class: "input-label" %>
56-
<div style="position:relative;">
56+
<div class="relative">
5757
<%= f.select :year,
5858
options_for_select((Date.today.year-10..Date.today.year).to_a, params.dig(:search, :year)),
5959
{ prompt: "Select year" },
@@ -64,9 +64,9 @@
6464
</div>
6565

6666
<!-- Month -->
67-
<div style="min-width:0; position:relative;">
67+
<div class="min-w-0 relative">
6868
<%= f.label :month, class: "input-label" %>
69-
<div style="position:relative;">
69+
<div class="relative">
7070
<%= f.select :month,
7171
options_for_select((1..12).to_a, params.dig(:search, :month)),
7272
{ prompt: "Select month" },
@@ -78,9 +78,9 @@
7878
</div>
7979

8080
<!-- State -->
81-
<div style="min-width:0; position:relative;">
81+
<div class="min-w-0 relative">
8282
<%= f.label :state, class: "input-label" %>
83-
<div style="position:relative;">
83+
<div class="relative">
8484
<%= f.select :state,
8585
options_for_select(Topic::STATES.index_with(&:itself), params.dig(:search, :state)),
8686
{ prompt: "Select state" },
@@ -92,9 +92,9 @@
9292
</div>
9393

9494
<!-- Order -->
95-
<div style="min-width:0; position:relative;">
95+
<div class="min-w-0 relative">
9696
<%= f.label :order, class: "input-label" %>
97-
<div style="position:relative;">
97+
<div class="relative">
9898
<%= f.select :order,
9999
options_for_select(%w[desc asc].map { |o| [o, o] }, params.dig(:search, :order)),
100100
{},
@@ -106,11 +106,10 @@
106106
</div>
107107

108108
<!-- Clear Button -->
109-
<div style="margin-top: 1.25rem; display: flex; justify-content: flex-end;">
109+
<div class="mt-5 flex justify-end">
110110
<%= link_to topics_path,
111-
class: "clear-filters-btn",
112-
style: "background:#6b7280; color:white; padding:0.625rem 1.25rem; border-radius:0.5rem; text-decoration:none; font-weight:600; font-size:0.875rem; display:inline-flex; align-items:center; gap:0.5rem; transition:all 0.2s; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);" do %>
113-
<svg style="width: 1rem; height: 1rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
111+
class: "bg-gray-500 text-white py-2.5 px-5 rounded-lg no-underline font-semibold text-sm inline-flex items-center gap-2 transition-all shadow-sm hover:bg-gray-600 hover:-translate-y-0.5 hover:shadow-md" do %>
112+
<svg class="icon-size" fill="none" stroke="currentColor" viewBox="0 0 24 24">
114113
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
115114
</svg>
116115
<span>Clear Filters</span>
@@ -119,38 +118,3 @@
119118
<% end %>
120119
</div>
121120
</div>
122-
123-
<style>
124-
/* Modern form input and select focus states */
125-
input[type="text"]:focus, select:focus {
126-
outline: none !important;
127-
border-color: #3b82f6 !important;
128-
box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
129-
background: white !important;
130-
}
131-
132-
/* Select hover state */
133-
select:hover:not(:focus) {
134-
border-color: #9ca3af !important;
135-
background: #fafafa !important;
136-
}
137-
138-
/* Clear Filters button hover - specific to search form only */
139-
.clear-filters-btn:hover {
140-
background: #4b5563 !important;
141-
transform: translateY(-1px);
142-
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06) !important;
143-
}
144-
145-
/* Responsive grid collapse */
146-
@media (max-width: 768px) {
147-
div[style*="grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))"] {
148-
grid-template-columns: 1fr !important;
149-
}
150-
}
151-
152-
/* Prevent grid items from forcing overflow */
153-
#topics-search-grid > div { min-width: 0 !important; }
154-
/* Ensure the grid itself can shrink */
155-
#topics-search-grid { min-width: 0; }
156-
</style>

0 commit comments

Comments
 (0)