-
-
Notifications
You must be signed in to change notification settings - Fork 364
[Icons] Allow to add custom pre-renderers #2157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1353faa
to
bd38bb4
Compare
This is the thing i was going to do after #2156 😄 ... but i'm not sure we want to open / tag this to be honest. There is a big performance goal with ux:icons... and i'd like to not reproduce the Twig/Live component problem. |
Not sure how can you make a difference here,you still need to collect them,and with tag at least it's an easy way |
I don't understand this.
I know. If that becomes a problem then dev can override renderer and do all the things there,like I've done now. |
The event system cannot be changed on Twig/Live component for BC reasons, and this make things hard for a lot of people. So we'll see after we discuss and/or merge the icon configuration PR. But i'm really not sure we would like to open to extensions in this place.. |
Yeah, I had to add multiple prerenderer's to avoid making many changes in migration. Basically without this it's not possible to have this functionality without overriding main renderer |
I guess we will find a way to open while not slowing everything down :) Couple of questions to precise the needs:
|
As i said I check kernel env determining If data-test-id must be rendered, so it cannot be static :)
Currently doesn't remove anything
Currently only attributes, but I see use-cases also with name |
I was going to hard-code one method to add "icone identity"-attribute (data-id="lu:circle") with some options to configure. Still thinking to do it, but this is not your need here, clearly :) |
But this would increase output size if will be rendered always :) it could replace our |
Yes no worry i now understand your needs :) |
|
||
interface IconPreRendererInterface | ||
{ | ||
public function __invoke(string $name, Icon $icon): Icon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not possible, there is no plan to expose the Icon object for now :/
Do you see another way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icon object is currrntly passed down to prerenders without my changes,so I don't understand you and the reasoning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "prerenders" are currently internal functions hard-coded in the renderer. Currently again, this is nothing else than an implementation detail, that could change at any time.
So i'm open to discuss both, but it's not at all a minor thing
And if we expose the Icon object (internal for now) here, we both know this is a question of days before beeing asked, logically, to expose it elsewhere..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so what do you prefer to expose if not the icon object? Why current prerenderers are getting the icon object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry this is me not understanding right now...
You are talking about prerenderers like it was a thing documented, exposed, etc.
This "current prerender" (no plural) is right now one callable that is part of the internal mecanism of the IconRenderer, in a private
method.
Again, i'm not against discussing it, but it seems fair to describe the current state objectively :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can live with it if you decide to pass only attributes,but I see no harm if we'd have like I've suggested.
function __invoke(array $attributes) {
$attributes['test'] = 'something';
return $attributes;
}
vs
function __invoke(Icon $icon) {
return $icon->withAttributes(['test' => 'something']);
}
To me the second solution looks more appealing than the first one, because intention is to modify the icon :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry this is me not understanding right now...
You are talking about prerenderers like it was a thing documented, exposed, etc.
This "current prerender" (no plural) is right now one callable that is part of the internal mecanism of the IconRenderer, in a
private
method.Again, i'm not against discussing it, but it seems fair to describe the current state objectively :)
Yeah, but you decided to pass the Icon, not me:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To a private internal function ;) And i know you know very well the difference 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So indeed it would probably be (not saying "ok" for now, we need to discuss the impacts with the team) something like
callable(string, array): array
with the icon name and the attributes passed during runtime
These attributes would then be added to the current ones..
But i'm realizing.... why don't just decorate the IconRenderer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed this example of decoration (i'm sure you don't need an example to know how to do this, but if anyone comes reading this exchange ;) )
bd38bb4
to
d810fe1
Compare
I want to add
data-test-id="icon_name"
attribute to all used icons, but there is no easy way without overriding wholeIconRenderer
and then duplicating the logic.But
IconRendererInterface
andIcon
is marked as internal and IDE complains..I think adding
ux_icons.pre_renderer
tag is a nice extension point where you can control them.