Current section

Files

Jump to
phoenix_webcomponent lib mix tasks material_design_icons.eex
Raw

lib/mix/tasks/material_design_icons.eex

defmodule Phoenix.WebComponent.MaterialDesignIcons do
@moduledoc """
Render 7000+ Material Design Icons
"""
use Phoenix.WebComponent, :html
# alias Phoenix.LiveView.JS
@icons ~W(<%= icons |> Enum.join(" ") %>)
@spec icons() :: [String.t()]
def icons(), do: @icons
<%= for name <- icons do %>
def <%= String.replace(name, "-", "_") %>(assigns) do
assigns =
assigns
|> assign_new(:id, fn -> false end)
|> assign_new(:class, fn -> false end)
~H"""
<svg xmlns="http://www.w3.org/2000/svg" id={@id} class={@class} viewBox="0 0 24 24">
<%= File.read!(Application.app_dir(:phoenix_webcomponent, "priv/mdi/svg/#{name}.svg")) |> String.replace(~r/<svg[^>]+>/, "") |> String.replace("</svg>", "") %>
</svg>
"""
end
<% end %>
end