I have some ideas for how to animate svgs using various elm packages. To do this, I need to transform raw svgs made in inkscape into elm source code which uses elm/svg. What tools are people using for stuff like this?
I found a link to an old svg-to-elm project but the link wont load. Also, I cant seem to find anything on github.
I usually do it by hand, but it only works for small files, I guess
Before that, I pass SVGs through this tool, that simplified them a lot: SVGOMG - SVGO's Missing GUI
If an online tool is enough this seems to work just fine: Convert SVG to Elm
https://html-to-elm.com/ works for SVG too. The tool is created by one of the most knowledgeable community members and allows for customization of imports which is a freaking awesome way to avoid name clashes.
I double the suggestion by @lucamug to pass the output of Inkscape through SVGOMG in order to minimize the amount of content you will end up with.
any way to use this from cli?
You can use the same logic from html-to-elm.com as an
elm-review rule (the site and the elm-review rule share the same codebase).
For example, try writing some Elm code like this:
Debug.todo """@html <ul class="flex"><li><a href="/">Home</a></li></ul>"""
And then run this command
npx elm-review@latest --template dillonkearns/elm-review-html-to-elm/example --fix-all
That command will even notice the imports you have for
Html.Styled and use the appropriate import aliases or exposed functions in the generated code. Enjoy!
I was thinking about writing a parcel plugin for this purpose recently. I stopped because it seemed more difficult than I thought but it would to a great thing to finish.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.