Some arguments for UI components are optional, so we don't have to provide all of them when using them. I had added a `defined?(name)` check to use default values when an argument is not provided. Jeremy pointed out that it was working by accident. In the code `name = defined?(name)`, `defined?(name)` always returns `local-variable` because it’s on the right-hand side of the assignment, while the local variable is on the left-hand side. When we remove the `defined?` calls, the remaining code is equivalent to `||=`.
19 lines
610 B
Plaintext
19 lines
610 B
Plaintext
<% case state %>
|
|
<% when "running" %>
|
|
<% color = "bg-green-100 text-green-800" %>
|
|
<% when "creating", "rebooting", "starting", "waiting for capacity" %>
|
|
<% color = "bg-yellow-100 text-yellow-800" %>
|
|
<% when "deleting", "deleted" %>
|
|
<% color = "bg-red-100 text-red-800" %>
|
|
<% else %>
|
|
<% color = "bg-slate-100 text-slate-800" %>
|
|
<% end %>
|
|
<% extra_class ||= nil %>
|
|
|
|
<span
|
|
class="inline-flex items-baseline rounded-full px-2 text-xs font-semibold leading-5 <%= color %> <%= extra_class %>"
|
|
>
|
|
<%== render("components/icon", locals: { name: "dot", classes: "mr-1.5 h-2 w-2" }) %>
|
|
<%= state %>
|
|
</span>
|