Make default props available to users of the generated component #924
chriscoomber
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature request
Would it be useful to export the default props of the in some way. E.g.:
to become
This doesn't change functionality at all, but allows a user of this react component to do something like:
Why
My use case for this is that I have several SVGs of different sizes which I would like to scale consistently together. So for example I have the following SVGs:
At their default dimensions, they are at the same scale, i.e. the pizza slices across all the SVGs are the same size.
I would like to display 6 of these SVGs in a row, programatically generated (this is for an elementary maths question). I want the collection of all 6 to be the largest they can be whilst fitting in a known rectangle. However, I additionally want that they all stay at the same scale as each other. This means that I can't naively share out the space evenly, since if vertical space is not a limiting factor the narrower ones will scale more.
These requirements are all easy to meet with a little bit of calculation, but that calculation requires us knowing the default dimensions of each SVG.
In my use-case, I'm actually using react-native-svg-transformer, so I don't have access to the exported react code to fiddle with it. It feels like SVGR is in the right position to add these properties.
Beta Was this translation helpful? Give feedback.
All reactions