2

So I'd like to use githubs octicons in Elm as svg nodes. Although I'm not sure that this is a good idea but I figured here is one way I could do it:

I could do pass the svg tags as string with flags to an Elm app calling:

   const octicons = require('octicons');
   const plusIcon = octicons.plus.toSVG();

And then just put that as a flag. But then how can I parse that string as an svg node?

I couldn't find any way to do that.

Although I don't really need to have it as an svg node. I just need the tag in my view to use that icon. So any solution to show those octicon icons would suffice. I just thought it would neat to have those as svg nodes in Elm.

In any case, maybe there is a better/easier way to use octicons in Elm?

Any ideas would be much appreciated.

Jukka Puranen
  • 8,026
  • 6
  • 27
  • 25

1 Answers1

1

I think instead of returning an svg string you could return an object with all necessary attributes. In opticons you have options and path. In case of path you can either parse the tag yourself or get something like jQuery.attr do it for you. After that from inside elm elm-lang/svg has all the utility: Svg.svg with Svg.path inside.

lonelyelk
  • 598
  • 9
  • 25