fix(icon): set outline/solid styles correctly.

On version 0.5.0, each outline style (`outline`, `solid`, `mini`,
`micro`) is defined by individual attributes.

So, the `icon` component uses these new attributes in the
place of `Heroicons.Solid` and `Heroicons.Outline`.
This commit is contained in:
Joao P Dubas 2024-06-20 15:00:52 +00:00
parent 94814ce86f
commit a2954526af
No known key found for this signature in database

View file

@ -149,14 +149,15 @@ defmodule LiveBeatsWeb.CoreComponents do
attr :rest, :global, default: %{class: "w-4 h-4 inline-block"}
def icon(assigns) do
assigns = assign_new(assigns, :"aria-hidden", fn -> !Map.has_key?(assigns, :"aria-label") end)
key = if Map.get(assigns, :outlined, false), do: :outline, else: :solid
assigns =
assigns
|> assign_new(:"aria-hidden", fn -> !Map.has_key?(assigns, :"aria-label") end)
|> assign(key, true)
~H"""
<%= if @outlined do %>
<%= apply(Heroicons.Outline, @name, [Map.to_list(@rest)]) %>
<% else %>
<%= apply(Heroicons.Solid, @name, [Map.to_list(@rest)]) %>
<% end %>
<%= apply(Heroicons, @name, [assigns]) %>
"""
end