-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
[v4] Icon extensions viewBox inconsistent #5492
Comments
We could also try to auto-detect the viewBox. If I put the example SVG from above into the DOM and call
So if we assume that the "intended"
Maybe a bit of a hack, but for icons that are centered in a I've tried it with a few other Remix Icons as well, including very tall or very wide ones (like |
You are right, I had feared weird edge cases. Good catch! :) I like the idea to support full
Using DOM methods would allow us to avoid any custom parsing. |
But wouldn't that leave the default at 16px? I think with switching to remix icons, we must make the default (the option with the least markup) correspond to those / 24px. |
Or we make the viewing 24px and scale icons up with the math @lukasbestle suggested above. I think old non-24px icons that get a little wrongly centered would be the least issue. |
We could also use the math to sort the icons into two buckets. Either it's roughly 16 px and gets the In practice we could use a calculation like this: const bbox = svg.getBBox();
const width = bbox.width + bbox.x * 2;
const height = bbox.height + bbox.y * 2;
const average = (width + height) / 2;
const distanceTo16 = Math.abs(average - 16);
const distanceTo24 = Math.abs(average - 24);
const viewBox = distanceTo16 < distanceTo24 ? "0 0 16 16" : "0 0 24 24"; |
I still think that having it explicit would cause the least amount of problems or surprises, with really no real downside other than a few bytes of easily compressed overhead. As well as just permitting a designer to use their icons in random 192x136 format, maybe the same assets they also use on the frontend, without much thought. Being able to just give it the contents of an SVG would also make automation way easier. Like I could imagine an easy build step passing a bunch of SVG files through svgo and then into a JSON string which the plugin can import. A pipeline which is made harder when you also need to parse the contents (in node, so without native Dom functions) to remove |
We could switch to full |
This can be an additional supported way but we should not add so much overhead for the most common use case especially now that people will much more use the one single remix library: and that is adding another 24px viewbox icon from remix. So I'm up for having all the suggested different ways, explicit viewbox option, supporting passing svg element... but the default one should clearly be the short definition as it has been with 24px viewbox. |
TBH I'm not even sure the short definition is the best way. If you download or copy a SVG from https://remixicon.com, you get a full SVG: For the short definition you would have to specifically remove the wrapping |
All arguments that make sense to also allow |
But if we keep the shorter version in the long run, we need to switch to 24 px, which is a breaking change. Is there a way to avoid the breaking change? |
Yes, but as I said I think it's a totally acceptable breaking change to have 16px icons rendered in 24px a bit off-centered. They'll still be visible. And if we'd add the math you mentioned above, we could fix most of this even more. I don't think the costs of trying to avoid this outweighs the benefit of trying not to have any breaking change. |
If you have an old 16 px icon and place it in a 24 px viewbox, the right and bottom thirds will be empty. It's not just a bit off-centered. So we would need the detection logic, which would introduce a lot of magic. If we don't deprecate 16 px icons, we would also have to carry this solution with us for a long time. Maybe as a compromise, what about this: v4
v5
|
Yeah, so... As bnomei found out on discord, you can actually put Obviously this results in a: <svg>
<symbol viewBox="0 0 16 16">
<svg viewBox="0 0 48 48">
...
</svg>
</symbol>
</svg> I just imagined that this would be invalid SVG, but it turns out it's actually not. Symbols can contain "structural elements", and I don't know where this leaves this issue. |
@rasteiner and in this case the 48px view box works even if nested inside a 16/24px view box? |
I've created a PR as suggestion based on how I understood our discussion: #5510 |
I haven't tried it and don't have a computer handy, but bnomei says so. |
I guess this is more an enhancement than a bug, but I think it's a missed opportunity when switching to a free icon set.
Description
With the new icon set of alpha.7, the viewBox of the included icons has changed from the 16x16px format of Nucleo to the 24x24 of remix icon.
The "icons" extension of plugins however is still putting them into a 16x16 viewBox, cutting a great portion of the remix icons off.
Expected behavior
Either change the viewBox of plugin icons to 24x24, so that we can use the remix icons, too (without having to manually resize them in something like Illustrator), or offer an option to specify the viewBox when declaring icons.
Screenshots
To reproduce
<path/>
Your setup
Kirby Version
V4 - alpha 7
Additional context
What about a new interface so to avoid a breaking change?
The text was updated successfully, but these errors were encountered: