Current section
17 Versions
Jump to
Current section
17 Versions
Compare versions
5
files changed
+56
additions
-8
deletions
| @@ -4,18 +4,16 @@ | |
| 4 4 | |
| 5 5 | ## Installation |
| 6 6 | |
| 7 | - If [available in Hex](https://hex.pm/docs/publish), the package can be installed |
| 7 | + [Available in Hex](https://hex.pm/icons), the package can be installed |
| 8 8 | by adding `icons` to your list of dependencies in `mix.exs`: |
| 9 9 | |
| 10 10 | ```elixir |
| 11 11 | def deps do |
| 12 12 | [ |
| 13 | - {:icons, "~> 0.1.0"} |
| 13 | + {:icons, "~> 0.5.0"} |
| 14 14 | ] |
| 15 15 | end |
| 16 16 | ``` |
| 17 17 | |
| 18 | - Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) |
| 19 | - and published on [HexDocs](https://hexdocs.pm). Once published, the docs can |
| 20 | - be found at <https://hexdocs.pm/icons>. |
| 18 | + The docs can be found at <https://hexdocs.pm/icons>. |
| @@ -29,4 +29,4 @@ | |
| 29 29 | {<<"optional">>,false}, |
| 30 30 | {<<"repository">>,<<"hexpm">>}, |
| 31 31 | {<<"requirement">>,<<"~> 0.17.0">>}]]}. |
| 32 | - {<<"version">>,<<"0.3.0">>}. |
| 32 | + {<<"version">>,<<"0.4.0">>}. |
unknownlib/icons/ionicons/filled.ex
File is too large to be displayed (200 KB limit).
| @@ -14,7 +14,9 @@ defmodule Mix.Tasks.Ionicons.Generate do | |
| 14 14 | |
| 15 15 | @shortdoc "Convert source SVG files into HEEX components. Run `git clone https://github.com/ionic-team/ionicons` first." |
| 16 16 | def run(_) do |
| 17 | - Enum.each(["outline", "filled", "sharp"], &loop_by_type/1) |
| 17 | + Enum.each(["outline", "sharp"], &loop_by_type/1) |
| 18 | + |
| 19 | + build_filled() |
| 18 20 | |
| 19 21 | Mix.Task.run("format") |
| 20 22 | end |
| @@ -64,6 +66,54 @@ defmodule Mix.Tasks.Ionicons.Generate do | |
| 64 66 | File.write!(dest_path, file_content) |
| 65 67 | end |
| 66 68 | |
| 69 | + defp build_filled() do |
| 70 | + src_path = "./ionicons/src/svg/" |
| 71 | + namespace = "Ionicons.Filled" |
| 72 | + type = "filled" |
| 73 | + |
| 74 | + file_content = """ |
| 75 | + defmodule Icons.#{namespace} do |
| 76 | + @moduledoc \"\"\" |
| 77 | + Icon name can be the function or passed in as an atom. |
| 78 | + |
| 79 | + ### Examples |
| 80 | + |
| 81 | + <Icons.#{namespace}.home class="w-6 h-6" /> |
| 82 | + <Icons.#{namespace}.render icon="home" class="w-6 h-6" /> |
| 83 | + |
| 84 | + \"\"\" |
| 85 | + use Phoenix.Component |
| 86 | + |
| 87 | + def render(assigns) do |
| 88 | + apply(__MODULE__, assigns.icon, [assigns]) |
| 89 | + end |
| 90 | + """ |
| 91 | + |
| 92 | + functions_content = |
| 93 | + src_path |
| 94 | + |> File.ls!() |
| 95 | + |> Enum.filter(&(Path.extname(&1) == ".svg")) |
| 96 | + |> Enum.filter(fn x -> |
| 97 | + not String.ends_with?(x, "-outline.svg") and not String.ends_with?(x, "-sharp.svg") |
| 98 | + end) |
| 99 | + |> Enum.map_join("\n\n", &create_component(src_path, type, &1)) |
| 100 | + |
| 101 | + file_content = |
| 102 | + file_content <> |
| 103 | + functions_content <> |
| 104 | + """ |
| 105 | + end |
| 106 | + """ |
| 107 | + |
| 108 | + dest_path = "./lib/icons/ionicons/#{type}.ex" |
| 109 | + |
| 110 | + unless File.exists?(dest_path) do |
| 111 | + File.mkdir_p("./lib/icons/ionicons") |
| 112 | + end |
| 113 | + |
| 114 | + File.write!(dest_path, file_content) |
| 115 | + end |
| 116 | + |
| 67 117 | defp create_component(src_path, type, filename) do |
| 68 118 | svg_content = |
| 69 119 | File.read!(Path.join(src_path, filename)) |
| @@ -3,7 +3,7 @@ defmodule Icons.MixProject do | |
| 3 3 | |
| 4 4 | @app :icons |
| 5 5 | @name "Icons" |
| 6 | - @version "0.3.0" |
| 6 | + @version "0.4.0" |
| 7 7 | @description "Icons collections as HEEX components" |
| 8 8 | |
| 9 9 | def project do |