init
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/priv
|
46
livebook.livemd
Normal file
46
livebook.livemd
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Function components from systemuicons
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
Mix.install([
|
||||||
|
{:jason, "~> 1.3"}
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
## Clone git repo
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
System.cmd("git", ["clone", "--depth=1", "https://github.com/CoreyGinnivan/system-uicons.git"],
|
||||||
|
cd: "./priv"
|
||||||
|
)
|
||||||
|
|
||||||
|
{output, _} = System.cmd("ls", ["./priv/system-uicons/src/images/icons"])
|
||||||
|
IO.puts(output)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get icon data
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
path = "./priv/system-uicons/src/js/data.js"
|
||||||
|
source_data = File.read!(path)
|
||||||
|
cl = String.to_charlist(source_data)
|
||||||
|
|
||||||
|
<<"var sourceData = "::utf8, rest::binary>> = source_data
|
||||||
|
# remove trailing semicolon
|
||||||
|
sslice = String.slice(rest, 0..-3//1)
|
||||||
|
# quote object keys
|
||||||
|
quote_keys = Regex.replace(~r/([\w_]+):/, sslice, "\"\\1\":")
|
||||||
|
# remove trailing commas
|
||||||
|
rm_trailing_commas = Regex.replace(~r/,\s+(}|])/, quote_keys, "\\1")
|
||||||
|
|
||||||
|
icon_data = Jason.decode!(rm_trailing_commas)
|
||||||
|
```
|
||||||
|
|
||||||
|
## fetch svg contents
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
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)
|
||||||
|
end)
|
||||||
|
```
|
3
systemuicons_ex.exs
Normal file
3
systemuicons_ex.exs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Mix.install([
|
||||||
|
|
||||||
|
])
|
Reference in New Issue
Block a user