mint
mint copied to clipboard
Defining the viewbox property with the SVG directive
One of the only things you can't define in CSS for SVG is the viewbox
property. I'd like to request a feature to pass a (perhaps optional) argument to the @svg directive that lets you define the viewbox
size.
We could also allow overwriting, the width
and height
attributes: https://github.com/mint-lang/mint/blob/master/src/compilers/directives/svg.cr#L18
Are those three the most important, or should we add all possible <svg>
attributes?
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg#Attributes
It seems these six are the most relevant:
preserveAspectRatio
, viewBox
, height
, width
, x
, y
Are those three the most important, or should we add all possible
<svg>
attributes?
Yes we can add other attributes as well, it might come in handy for some use cases.
We currently raise an issue, when the width
, height
, viewBox
attributes are not defined on the SVG, is this required?
We currently raise an issue, when the
width
,height
,viewBox
attributes are not defined on the SVG, is this required?
With the current implementation yes they are required because we use them.
I don't see any reason why we could not make them optional (only use them when they are present), and overridable.
I guess I made them required because it is a good practice to have them.
const ALERT = @svg(../public/tiger.svg,
preserveAspectRatio = "xMidYMid meet",
viewBox = "0 0 100 100",
width = 100,
height = 100,
x = 0,
y = 0)