Skip to content

Commit 427c728

Browse files
committed
refactor: 非アクティブ項目のスタイルを共通CSSクラスに抽出
- custom.scssに.stats-table .inactive-itemクラスを追加 - background-color: gainsboroスタイルを一元管理 - /dojosと/stats#prefecturesの両方で同じクラスを使用 - 将来的に他のテーブルでも再利用可能
1 parent 277cef0 commit 427c728

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

app/assets/stylesheets/custom.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,3 +1072,10 @@ section {
10721072
line-height: 1.7em;
10731073
color: #909090;
10741074
}
1075+
1076+
/* Stats and Dojos table styling */
1077+
.stats-table {
1078+
td.inactive-item {
1079+
background-color: gainsboro;
1080+
}
1081+
}

app/views/dojos/index.html.erb

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
</style>
8888

8989
<div style="margin-top: 20px;" align="center">
90-
<table border="1">
90+
<table border="1" class="stats-table">
9191
<tr>
9292
<th>
9393
<small>
@@ -113,26 +113,49 @@
113113
</tr>
114114
<% @dojos.each do |dojo| %>
115115
<tr>
116-
<td>
117-
<small>
118-
<%= link_to dojo_path(dojo[:id]) do %>
119-
<%= dojo[:name] %><br>
120-
<small>(ID: <%= dojo[:id] %>)</small>
121-
<% end %>
122-
</small>
123-
</td>
124-
<td>
125-
<small><%= dojo[:created_at].strftime("%F") %></small>
126-
</td>
127-
<td class="url-cell">
128-
<small>
129-
<a href='<%= dojo[:url] %>'>
130-
<span title="<%= dojo[:url] %>">
131-
<%= CGI.unescape dojo[:url].gsub('https://', '').gsub('http://', '').gsub('www.', '').chomp('/') %>
132-
</span>
133-
</a>
134-
</small>
135-
</td>
116+
<% if dojo[:is_active] %>
117+
<td>
118+
<small>
119+
<%= link_to dojo_path(dojo[:id]) do %>
120+
<%= dojo[:name] %><br>
121+
<small>(ID: <%= dojo[:id] %>)</small>
122+
<% end %>
123+
</small>
124+
</td>
125+
<td>
126+
<small><%= dojo[:created_at].strftime("%F") %></small>
127+
</td>
128+
<td class="url-cell">
129+
<small>
130+
<a href='<%= dojo[:url] %>'>
131+
<span title="<%= dojo[:url] %>">
132+
<%= CGI.unescape dojo[:url].gsub('https://', '').gsub('http://', '').gsub('www.', '').chomp('/') %>
133+
</span>
134+
</a>
135+
</small>
136+
</td>
137+
<% else %>
138+
<td class="inactive-item">
139+
<small>
140+
<%= link_to dojo_path(dojo[:id]) do %>
141+
<%= dojo[:name] %><br>
142+
<small>(ID: <%= dojo[:id] %>)</small>
143+
<% end %>
144+
</small>
145+
</td>
146+
<td class="inactive-item">
147+
<small><%= dojo[:created_at].strftime("%F") %></small>
148+
</td>
149+
<td class="url-cell inactive-item">
150+
<small>
151+
<a href='<%= dojo[:url] %>'>
152+
<span title="<%= dojo[:url] %>">
153+
<%= CGI.unescape dojo[:url].gsub('https://', '').gsub('http://', '').gsub('www.', '').chomp('/') %>
154+
</span>
155+
</a>
156+
</small>
157+
</td>
158+
<% end %>
136159
</tr>
137160
<% end %>
138161
</table>

app/views/stats/show.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@
361361
</div>
362362
</h2>
363363
<div style="margin-top: 20px;" align="center">
364-
<table border="1">
364+
<table border="1" class="stats-table">
365365
<tr>
366366
<th style="padding: 10px;">
367367
<small><%= @lang == 'en' ? 'Prefecture' : '都道府県名' %></small>
@@ -373,10 +373,10 @@
373373
<% @data_by_prefecture.each_with_index do |(prefecture, count), index| %>
374374
<tr>
375375
<% if count == 0 %>
376-
<td style="background-color: gainsboro; padding: 0px;">
376+
<td class="inactive-item" style="padding: 0px;">
377377
<small><%= prefecture %></small>
378378
</td>
379-
<td style="background-color: gainsboro; padding: 0px;">
379+
<td class="inactive-item" style="padding: 0px;">
380380
<small><%= count %></small>
381381
</td>
382382
<% else %>

0 commit comments

Comments
 (0)