nice
This commit is contained in:
@ -41,6 +41,49 @@ icon_data = Jason.decode!(rm_trailing_commas)
|
||||
icon_map =
|
||||
Enum.map(icon_data, fn %{"icon_path" => path} = icon ->
|
||||
svg = File.read!("./priv/system-uicons/src/images/icons/#{path}.svg")
|
||||
|
||||
Map.put_new(icon, "icon_svg", svg)
|
||||
|> Map.new(fn {k, v} -> {String.to_atom(k), v} end)
|
||||
end)
|
||||
```
|
||||
|
||||
## Component template
|
||||
|
||||
```elixir
|
||||
defmodule Templates do
|
||||
def svg(name, contents, path, keywords) do
|
||||
"""
|
||||
@doc "Name: #{name} Keywords: #{keywords}"
|
||||
def icon_#{path}(assigns) do
|
||||
\"\"\"<i class="svg">
|
||||
""" <>
|
||||
contents <>
|
||||
"""
|
||||
|
||||
</i>
|
||||
\"\"\"
|
||||
end
|
||||
|
||||
"""
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
```elixir
|
||||
icon = Enum.at(icon_map, 0)
|
||||
Templates.svg(icon.icon_name, icon.icon_svg, icon.icon_path, icon.icon_keywords)
|
||||
icon
|
||||
```
|
||||
|
||||
## Create module file
|
||||
|
||||
```elixir
|
||||
funs =
|
||||
for %{icon_name: name, icon_path: path, icon_svg: svg, icon_keywords: tags} <- icon_map do
|
||||
Templates.svg(name, svg, path, tags)
|
||||
end
|
||||
|> Enum.join()
|
||||
|
||||
content = "defmodule do\n" <> funs <> "\nend\n"
|
||||
File.write!("./icons.ex", content)
|
||||
```
|
||||
|
Reference in New Issue
Block a user