Lattyware / elm-fontawesome

FontAwesome for Elm.
https://package.elm-lang.org/packages/lattyware/elm-fontawesome/latest/
MIT License
33 stars 6 forks source link

Please expose the underlying svg corePath. #6

Closed roSievers closed 4 years ago

roSievers commented 5 years ago

I have a large "editor panel" rendered in svg next to a sidebar where the user can select a tool. Currently the tools each use a font awesome icon and it would be great to use the font awesome icons in the svg editor panel as well. (For example, to show the trash can above a token when you have the "delete" tool activated and hold down the left mouse button.)

For this I need a way to get the svg path element from the libary. It looks like the private function Icon.corePath does essentially what I need, save for the extra fill property.

import ...

trashPath : Svg msg
trashPath = Icon.svgPath [ Svg.Attributes.fill "#F00", .. ] Solid.trash

Do you think exposing a function like this fits your library?

Lattyware commented 5 years ago

I see the use case and supporting it seems valuable, although exposing the path specifically locks you out of a lot of features of the library. Probably the more complete answer would be to expose a viewSvg function that offers a way to render the icon completely to an SVG node rather than an HTML node, probably with some restrictions on features it supports. At the very least, the masking feature is all done in SVG, so that should be viable.

Does that sound reasonable to you?

As a note, if this is urgent, the Icon type is public, so you can access the data to implement this in your own project (e.g: copying in Icon.corePath with a few modifications) if you need to do this before the library has it implemented.

roSievers commented 5 years ago

Yes it does sound good. I didn't use the more sophisticated features of your library yet so I didn't think of that.

It's not urgent :-)

Lattyware commented 4 years ago

I didn't end up being able to get around to this quickly, so I've just implemented the simpler version for now—as of 4.0.0 there is Svg.viewIcon which gives a path for use in an existing SVG node. If someone wants to do something like masking in SVG, please open another issue for it.