elm-community / typed-svg

Typed SVG library written for Elm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot set fill="none"

rupertlssmith opened this issue · comments

TypesSvg.Attritbues.fill takes a Color argument. In SVG it is possible to set fill="none" to have an unfilled shape.

The same effect can be achieved by setting fillOpacity <| Opacity 0.0, so perhaps this is not a problem.

Perhaps the Opacity type could be extended with a convenience case to cover this?

type Opacity
= Opacity Float
| OpacityInherit
| OpacityNone

What do you think of making a Fill type:

type Fill
= Fill Color
| FillNone

?

Yes, that would work. It would be a non-backward compatible API change, so will look for any other similar situations where the value can be "none", and try and package these changes for a 3.x release.

The documentation is a little annoying on this, because it never explicitly states that "none" is an allowed value:

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill

However, there are plenty examples in the docs that do use "none".

Despite this, introducing a fill type with Color and None options seems the most appropriate solution.

The example in README.md is out of date. Also it's sort of awkward to have to dig out a custom type constructor just to specify what is basically Maybe Color.

Thanks. Maybe Color would be so much better, I don't know how that wasn't completely obvious... There might be other cases where a Maybe can be used instead of a custom type too.