From db15e1342a1013347054247da2328aa3e4c45b3f Mon Sep 17 00:00:00 2001 From: Max Veytsman Date: Sun, 17 Mar 2024 23:18:06 -0400 Subject: [PATCH] Handle case where micro style is missing --- assets/heroicons.exs | 4 +++- lib/heroicons.ex | 4 +++- test/heroicons_test.exs | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/assets/heroicons.exs b/assets/heroicons.exs index 9a55ac62..2b289939 100644 --- a/assets/heroicons.exs +++ b/assets/heroicons.exs @@ -52,7 +52,9 @@ defmodule Heroicons do use Phoenix.Component defp svg(assigns) do - case assigns do + # Not all styles have the micro attribute + Map.merge(%{micro: false}, assigns) + |> case do %{mini: false, solid: false, micro: false} -> ~H"<.svg_outline {@rest}><%%= {:safe, @paths[:outline]} %>" diff --git a/lib/heroicons.ex b/lib/heroicons.ex index b475f770..127e631b 100644 --- a/lib/heroicons.ex +++ b/lib/heroicons.ex @@ -52,7 +52,9 @@ defmodule Heroicons do use Phoenix.Component defp svg(assigns) do - case assigns do + # Not all styles have the micro attribute + Map.merge(%{micro: false}, assigns) + |> case do %{mini: false, solid: false, micro: false} -> ~H"<.svg_outline {@rest}><%= {:safe, @paths[:outline]} %>" diff --git a/test/heroicons_test.exs b/test/heroicons_test.exs index 8c81d81d..4802544b 100644 --- a/test/heroicons_test.exs +++ b/test/heroicons_test.exs @@ -21,6 +21,13 @@ defmodule HeroiconsTest do ~s|| end + test "default when it has no micro" do + class = "w-6 h-6 mr-2 inline" + + assert render_component(&Heroicons.arrow_right_on_rectangle/1, %{class: class}) == + ~s|| + end + test "solid" do assert render_component(&Heroicons.cake/1, %{solid: true}) == ~s||