Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add material design icons community version.
- Loading branch information
Showing
7,207 changed files
with
7,328 additions
and
7 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule Mix.Tasks.PhxWc.GenIcons do | ||
# Generate Material Design Icons | ||
# try to define with macro, it's too slow | ||
|
||
@moduledoc """ | ||
Generate Phoenix.WebComponent.MaterialDesignIcons fron 7000+ svg files | ||
""" | ||
use Mix.Task | ||
|
||
@shortdoc "Generate Phoenix.WebComponent.MaterialDesignIcons.ex file" | ||
def run(_) do | ||
Mix.Task.run("app.start") | ||
|
||
icons = | ||
File.ls!(Application.app_dir(:phoenix_webcomponent, "priv/mdi/svg")) | ||
|> Enum.filter(&String.ends_with?(&1, ".svg")) | ||
|> Enum.map(&String.trim(&1, ".svg")) | ||
|
||
quoted = EEx.compile_file("#{__DIR__}/material_design_icons.eex") | ||
{result, _bindings} = Code.eval_quoted(quoted, icons: icons) | ||
|
||
fl = Path.expand("../../phoenix_webcomponent/material_design_icons.ex", __DIR__) | ||
|
||
File.write!(fl, result) | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
apps/phoenix_webcomponent/lib/mix/tasks/material_design_icons.eex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/phoenix_webcomponent/lib/phoenix_webcomponent/icons.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule Phoenix.WebComponent.Icons do | ||
@moduledoc """ | ||
Render 7000+ Material Design Icons | ||
""" | ||
use Phoenix.WebComponent, :html | ||
|
||
# alias Phoenix.LiveView.JS | ||
|
||
@icons File.ls!(Application.app_dir(:phoenix_webcomponent, "priv/mdi/svg")) | ||
|> Enum.filter(&String.ends_with?(&1, ".svg")) | ||
|> Enum.map(&String.trim(&1, ".svg")) | ||
|> Enum.sort(:asc) | ||
|
||
@spec mdi_icons() :: [String.t()] | ||
def mdi_icons(), do: @icons | ||
|
||
@doc """ | ||
Render 7000+ Material Design Icons | ||
""" | ||
def wc_mdi(assigns) do | ||
assigns = | ||
assigns | ||
|> assign_new(:id, fn -> false end) | ||
|> assign_new(:class, fn -> false end) | ||
|
||
name = assigns.name | ||
|
||
inner_svg = | ||
File.read!(Application.app_dir(:phoenix_webcomponent, "priv/mdi/svg/#{name}.svg")) | ||
|> String.replace(~r/<svg[^>]+>/, "") | ||
|> String.replace("</svg>", "") | ||
|
||
assigns = assigns |> assign(:inner_svg, inner_svg) | ||
|
||
~H""" | ||
<svg xmlns="http://www.w3.org/2000/svg" id={@id} class={@class} viewBox="0 0 24 24"> | ||
<%= raw(@inner_svg) %> | ||
</svg> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/access-point-network-off.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/access-point-network.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-alert-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-arrow-down-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-arrow-left-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-arrow-right-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-arrow-up-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-badge-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-box-multiple-outline.svg
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-box-multiple.svg
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
apps/phoenix_webcomponent/priv/mdi/svg/account-cancel-outline.svg
Oops, something went wrong.
Oops, something went wrong.