Pregenerate the icons with a mix task
This commit is contained in:
19
lib/mix/heroicons/generator_helpers.ex
Normal file
19
lib/mix/heroicons/generator_helpers.ex
Normal file
@ -0,0 +1,19 @@
|
||||
defmodule Mix.Heroicons.GeneratorHelpers do
|
||||
alias Mix.Heroicons.SvgProcessor
|
||||
|
||||
def icon_name(path) do
|
||||
Path.basename(path, ".svg")
|
||||
|> String.replace("-", "_")
|
||||
|> String.to_atom()
|
||||
end
|
||||
|
||||
def icon_body(path, svg_opts) do
|
||||
icon =
|
||||
File.read!(path)
|
||||
|> SvgProcessor.process(svg_opts)
|
||||
|
||||
<<"<svg ", body::binary>> = icon
|
||||
|
||||
body
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user