defmodule Box do @moduledoc """ Boxicon Heex is a Phoenix component library that wraps the amazing boxicons library. Usage: defmodule MyComponent do @impl true def render(assigns) do ~H"\"" "\"" end end To get a full list of all the available icons, go to https://boxicons.com/ """ require Logger use Phoenix.Component @icons Box.Source.get_icons() def icons(assigns) do assigns = assigns |> assign_new(:class, fn -> nil end) |> assign_new(:size, fn -> nil end) |> assign_new(:type, fn -> nil end) ~H[<%= render_content(get_type(@type), @name) %>] end Logger.debug(" - Compiling #{Enum.count(@icons)} boxicons.") for %Box.Source{type: type, name: name, content: content} <- @icons do defp render_content(unquote(Atom.to_string(type)), unquote(name)), do: unquote(Phoenix.HTML.raw(content)) end defp render_content(_, _), do: "<404>" def get_size(nil), do: Application.get_env(:boxicons_heex, :default_size, 24) def get_size(size), do: size def get_class(nil), do: Application.get_env(:boxicons_heex, :default_class, "icon") def get_class(class), do: class def get_type(nil), do: Application.get_env(:boxicons_heex, :default_type, "regular") def get_type(type), do: type end