colored_pill avec classes explicites pour JIT Tailwind
This commit is contained in:
parent
7dba35c320
commit
17c08306b3
|
@ -5,8 +5,18 @@ module ApplicationHelper
|
||||||
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
|
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
color = options.fetch(:color).presence || "gray"
|
color_classes = case options.fetch(:color)
|
||||||
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-#{color}-100 text-#{color}-800"
|
when "red"
|
||||||
|
"bg-red-100 text-red-800"
|
||||||
|
when "green"
|
||||||
|
"bg-green-100 text-green-800"
|
||||||
|
when "orange"
|
||||||
|
"bg-orange-100 text-orange-800"
|
||||||
|
else
|
||||||
|
"bg-gray-100 text-gray-800"
|
||||||
|
end
|
||||||
|
|
||||||
|
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full #{color_classes}"
|
||||||
|
|
||||||
if block_given?
|
if block_given?
|
||||||
content_tag(:span, class: classes, &block)
|
content_tag(:span, class: classes, &block)
|
||||||
|
|
|
@ -55,14 +55,14 @@
|
||||||
<% if user.confirmed? %>
|
<% if user.confirmed? %>
|
||||||
<%= colored_pill_tag("Confirmed", color: "green") %>
|
<%= colored_pill_tag("Confirmed", color: "green") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= colored_pill_tag("Unconfirmed", color: "yellow") %>
|
<%= colored_pill_tag("Unconfirmed", color: "orange") %>
|
||||||
<% 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? %>
|
||||||
<%= colored_pill_tag("Yes", color: "green") %>
|
<%= colored_pill_tag("Yes", color: "green") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= colored_pill_tag("No", color: "yellow") %>
|
<%= colored_pill_tag("No", color: "gray") %>
|
||||||
<% 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