utilisation d'un helper plutôt qu'un partiel
This commit is contained in:
parent
78926f6a4c
commit
7dba35c320
|
@ -1,2 +1,18 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
|
||||||
|
def colored_pill_tag(content_or_options_with_block = nil, options = nil, &block)
|
||||||
|
if block_given?
|
||||||
|
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
color = options.fetch(:color).presence || "gray"
|
||||||
|
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-#{color}-100 text-#{color}-800"
|
||||||
|
|
||||||
|
if block_given?
|
||||||
|
content_tag(:span, class: classes, &block)
|
||||||
|
else
|
||||||
|
content_tag(:span, content_or_options_with_block, class: classes)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-<%= (defined?(color) && color.presence) || "gray" %>-100 text-<%= (defined?(color) && color.presence) || "gray" %>-800">
|
|
||||||
<%= yield %>
|
|
||||||
</span>
|
|
|
@ -53,24 +53,16 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<% if user.confirmed? %>
|
<% if user.confirmed? %>
|
||||||
<%= render "shared/colored_pill", { color: "green" } do %>
|
<%= colored_pill_tag("Confirmed", color: "green") %>
|
||||||
Confirmed
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render "shared/colored_pill", { color: "yellow" } do %>
|
<%= colored_pill_tag("Unconfirmed", color: "yellow") %>
|
||||||
Unconfirmed
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<% if user.admin? %>
|
<% if user.admin? %>
|
||||||
<%= render "shared/colored_pill", { color: "green" } do %>
|
<%= colored_pill_tag("Yes", color: "green") %>
|
||||||
Yes
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render "shared/colored_pill", { color: "yellow" } do %>
|
<%= colored_pill_tag("No", color: "yellow") %>
|
||||||
No
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||||
|
|
Loading…
Reference in a new issue