Open Ebmtranceboy opened 6 months ago
Of course, customization is possible with elementify2
but I think those two attributes should be accessible by default.
I ran into this issue too and found some related problems and a workaround for fixed-size rects.
Instead of:
, SA.width_ "500"
, SA.height_ "250"
Give it a class:
, SA.klass_ "my-rect"
And set the size in CSS:
.my-rect {
width: 500px;
height: 250px;
}
This should give the same result because width
and height
are Presentation Attributes:
These are attributes whose name matches (or is similar to) a given CSS property and whose value is parsed as a value of that property.
The px
unit is necessary because nonzero CSS lengths require units, but it should be equivalent because SVG interprets unitless numbers as pixels anyway.
The workaround should be possible to do in code, like this:
, SA.style_ "width: 500px; height: 250px;"
but despite Deku.DOM.SVG.Attributes
exporting a style
attribute, it doesn't appear that any element in Deku.DOM.SVG
can use it!
There are several other elements (foreignObject
, image
, rect
, svg
, symbol
, and use
) listed in the Presentation Attributes table that should also have access to width
and height
, but only svg
does.
There are some other discrepancies between presentation attributes listed in the SVG spec and their usage in Deku. For example, alignment-baseline
should be available to all elements but Deku limits it to text-related elements. Deku makes pathLength
available to all elements but the Regular Attributes table says it only applies to circle
, ellipse
, line
, path
, polygon
, polyline
, and rect
.
(With the caveat that I don't really know how the codegen works)
The quickest solution would probably be to add width
and height
to svgPresentationMembers
in codegen/src/Main.purs
, but it wouldn't really be correct.
Adding width
and height
directly to foreignObject
, image
, rect
, symbol
, and use
like it's currently done with svg
should also work.
I don't know why no SVG elements have access to the style
attribute or where that should be fixed. That may be a separate issue.
@jterbraak , would a good place to tackle this be in the fixSVG
function in the codegen? Reading it over now, that seems to be the spot where you're fixing the broken spec. Lemme know, if so I can take a stab at adding it there.
This code doesn't compile as soon as either one of the two commented lines is uncommented: