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 `||=`.
12 lines
487 B
Plaintext
12 lines
487 B
Plaintext
<% progress = [100, 100 * numerator / denominator].min
|
|
color = (progress < 60) ? "bg-blue-500" : (progress < 80) ? "bg-yellow-500" : "bg-red-500" %>
|
|
|
|
<div class="flex justify-between mb-1">
|
|
<span class="text-base font-medium"><%= title %></span>
|
|
<span class="text-sm font-medium"><%= numerator %>/<%= denominator %>
|
|
(<%= progress %>%)</span>
|
|
</div>
|
|
<div class="w-full bg-gray-200 rounded-full h-3">
|
|
<div class="<%= color %> h-3 rounded-full w-[<%= progress %>%]"></div>
|
|
</div>
|