[Icons] Add support for int/float attribute to ux_icon function#2149
[Icons] Add support for int/float attribute to ux_icon function#2149smnandre merged 1 commit intosymfony:2.xfrom
ux_icon function#2149Conversation
fca91fe to
328ed8f
Compare
smnandre
left a comment
There was a problem hiding this comment.
It is not a bug fix..
But i'm fully open to discuss the feature if there is a real usage behind :)
Icon componentux_icon function
|
This works already <twig:ux:icon height="48" width="64" />So the problem is when you want to pass some dynamic value (and i really would love to have an example) <twig:ux:icon height="48" width="{{ 64 / 2 }}" />But i'm not ok to change it in Icon ... as a SVG tag does not have "float" or "int" values, but only strings. So maybe we can (string) values in the Renderer :| |
Yes, that's what is described in issue #2148.
In absolute terms, all the values you pass to HTML attributes are strings, but are then interpreted specially. But here, we do not speak about the SVG tag but the #[AsTwigComponent]
final class AutocastInt
{
public string $min;
public int $max;
}<twig:AutocastInt min="1" max="10" />
<twig:AutocastInt :min="1" :max="10" />
<twig:AutocastInt min="{{ 1 }}" max="{{ 10 }}" />Like in Vue or React/JSX, the following codes are correctly interpreted: <input type="range" :min="1" max="120" /><input type="range" min="1" max={10} />Anyway, I don't really understand why do we need such this validation, can't we rely on |
328ed8f to
ef0dad7
Compare
This is not directly related to the UX:Icon But i don't want to store int as "int", but as strings in Icon attributes property.. so what do you prefer ? |
|
As i said, I agree to cast it, just not internally :) |
569cf3e to
5f1e2d3
Compare
|
Thanks for fixing this bug Hugo. |

I'm not really sure why do we have checks on attributes values, do you remember why @kbond? 🙏🏻