Repository navigation
Icons: Scale artwork to better fill the 24×24 canvas - #84105
jameskoster wants to merge 9 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: -2.99 kB (-0.03%) Total Size: 8.97 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Regression: updating a specific option will only change its value and will not corrupt others in
|
ciampo
left a comment
There was a problem hiding this comment.
We'll need to update snapshots, too.
Apart from that, I believe this will mostly need a design approval, more than code/technical approval.
|
|
||
| ### Enhancements | ||
|
|
||
| - Scale icon artwork by up to 1.25× so icons better fill their 24×24 canvas. `*-small` variants and the WordPress mark are unchanged. |
|
@ciampo you're too quick, I'm still working on this haha. But since you commented; I agree we need a thorough design review. The larger icons look a little off in the Editor which was expected. I'm going to try reducing from 24px to 20px icons which should produce something closer to the existing appearance while fixing the bounding box issue. |
Sorry, didn't mean to review too early. I got the ping while I was going through my queue and I took a look 😅
Nice! I guess one thing to keep in mind is to optimize for the size that gives us the shapes that we want with the less need for a lot of SVG decimals and rescaling? Ie. if we use our icons at 20px for the majority of time, there could be added value in defining them at 20px viewbox to avoid re-sizing them (which could introduce subpixel artefacts). Is the stroke width changing to 1.25px too, to keep the same proportions? Assuming we'll enable stroke width scaling? |
|
#84081 has landed.
If we rewrite the icons to use a 20x20 viewport and a 1.25 stroke width, won't they continue to render at 24/1.5px anyway, thus keeping the same behaviour as on trunk?
If the point above makes sense, this would have been an aspect to consider regardless of this PR? |
4096586 to
f908140
Compare
|
I would love @mattmiklic's eye on this as far as bringing these back into Figma. I'm a bit concerned that we are changing every single icon dimensions and sizes, I think it's a larger visual change than we might think. Every vector handle across all the icons I hand-placed on precise integer coordinates so as to alias the best across the set. |
|
There's a Figma here. Also dropping a summary from a lengthy conversation with AI about icon crispness: Conversation with AI**Icons are slightly soft at the sizes we use, and one shared drawing cannot be crisp at 16px, 20px, and 24px without changing the stroke weight.**A crisp line fills whole physical pixels. Ours is 1.5 units thick in a 24-unit box, so the painted thickness depends on the render size: 1px at 16, 1.25px at 20, and 1.5px at 24. A fractional thickness fades at the edge.
Trunk and this branch are the same in this respect. Scaling the artwork does not fix it or make it worse. Those are still one drawing scaled to fit. Sharp at all three sizes means a separate drawing for each size, with a 1px or 2px stroke snapped to that grid. Curves will still fade a little. The other option is to keep one drawing and round the stroke to a whole pixel at the size we use most:
The TLDR is that icons are slightly soft on trunk and on this PR. Making them crisp would be a separate effort. So for now the review task is:
And to re-iterate; the main objective of this work is to achieve better alignment of text and icons on the vertical axis without resorting to hacks. It's not perfect, but it's about as good as it can be while leaving some space for optical balance. Top is trunk, bottom is this PR:
|
I don't think updating the Icons figma library would be difficult. It sounds like the changes would have a broad reach, but be fairly mechanical. Once the code is settled, we’d import the drawings, scale affected instances to 20px, and mirror the specified spacing changes. The main effort is finding all affected consumers and verifying that updates preserve overrides and layout. |
b443e69 to
f8930ef
Compare
ciampo
left a comment
There was a problem hiding this comment.
More snapshots needing updating
|
|
||
| .components-color-list-picker__swatch-color { | ||
| // Match the 24px size of the `swatch` icon (used when no color is set) | ||
| // Match the 20px size of the `swatch` icon (used when no color is set) |
There was a problem hiding this comment.
From what I gather, ColorIndicator is already 20px wide, so these margins still reserve 24px while the unset icon now reserves 20px. We may be able to remove the margins so the label doesn't move 4px when a color is set or cleared
8e46e96 to
0af0ffa
Compare
ciampo
left a comment
There was a problem hiding this comment.
It looks like the Site Tagline and Icon block glyphs omit viewBox, so the new 20px dimensions leave their artwork centered at 12px instead of 10px. Could we add viewBox="0 0 24 24" to those two SVGs so they scale and stay centered?
Also, existing Icon blocks also pick up the larger drawings while keeping their saved width. Could we include frontend Icon blocks in the design review and note this effect in the PR description?
|
I'll reshare that I'm a little concerned with the approach generally taken here. I think if we are to scale up the icons, we should do it manually, and review it overall. A reflection from the recent merge of a stroke-redesign of 300+ icons was that, only the icons that did not receive any visual changes at all still felt coherent at the end of the effort: icons around headings, typography, bold, italic, even if the updates were relatively minuscule, their impact felt substantial, so I scrambled to address it. I worry that even if we mechanicaly think of these changes as being small, the holistic impact hasn't been fully measured. Still not sharing that in a blocking sense, because I'm simultaneously convinced that there's some technical nuance to all this that I'm missing, so if anything it's mostly: proceed with caution! |
|
How can we proceed, though? Merge early in the 7.3 cycle, gather feedback, address? |
As the resident "concerned contributor", it's only fair that I elaborate on what concerns me so we can actually act on it. Apologies if I've been fuzzy, so let me clear my thoughts. The icons have all been deliberately designed on a 24px canvas over several years. Even if they were adjusted to be stroke-based recently, much of the initial character has remained, and the major changes have been to address optical balancing and inconsistencies, where we are now closer to a very coherent set than we've been for ages. We still have balancing and improvement work to do, including decisions on fills vs. strokes-only as well as some deprecations, so making the set coherent and better remains an ongoing task. So I think the main concern I have really is about that unfinished maintenance task. Every code-point of the 300+ vectors were manually placed on rounded coordinates so as to alias the best they could in the 24px artboard. It's ongoing, but now that the conversion is complete, it's easier to adjust those coordinates if we have to. I think that's my main concern: if we use a bulk script to convert every codepoint, the source files will be changed in a way where I worry maintenance will go from where it is at present: organised and understandable as far as math values, to one of confusion and harder maintenance. I have heard the counter-argument: the block toolbar after this change will look identical, because even if the artwork is scaled up to use more of the artboard, the artboard itself will be scaled down by the same factor, and combined with consistent stroke scaling it means icons should theoretically be identical. But I guess I mostly don't trust that they will alias the same when actually changing the artwork: there are subtle alignment pieces across rows of icons where fuzz on just one edge of a stroke will suddenly stand out in contrast to more deliberately placed fuzz. To be fair, I could be overly concerned about a non-issue. Maybe it's fine? But it goes back to: I don't understand what problem this is solving through scaling the artwork. If the challenge is to provide the icons "without bounding box spacing", are there not ways where we can much less destructively change the bounding box itself? It seems like we're looking at a relatively impactful change for consumers, and let me know if the following is not correctly understood:
In both cases, this would require some migration. So what I'm saying is that if there are any ways we can accomplish the bounding box challenge without script-changing the artwork, I'd personally feel safer. Is there an option for a prop on the bounding box? That's still not a blocker, so if we do proceed with this, if there's broad agreement and I'm the only voice against it, then I ask we proceed very carefully so that if visual regressions or trickier Figma editing of new source files emerges as a problem, we can carefully revert. Is that fair? I'm happy to hop on a call if I'm still missing nuance, and I appreciate your patience with this. |
|
@joen potentially we could work on preparing (visual) tests to render before/after icons at multiple sizes to uncover any px differences on this PR ? Would that help us to gain confidence about this change? |
Maybe. Don't do it just for me if I'm the only one being concerned here, or if there's something I've fundamentally misunderstood. To be reductive, I'm worried about having to draw new icons like I have to in a moment, opening the Figma source file, and finding box corners aligned to odd numbers like 3.43 rather than rounder numbers like 4.75. |
|
@jasmussen the problem we're solving is covered in this comment, and in #65786 originally. I understand the concerns, but like @ciampo says it's difficult to know how to proceed until those concerns are more concrete/specific. If you have time please take a look at the Figma, and ideally build this branch and check UIs that make use of the icons. If anything specific stands out please leave details in a comment for me to investigate. |
|
I'll do a deep dive later today. 🙏 |
Most icons sat at about 16 units across, which made flush alignment with nearby text harder than it needs to be. Scale each drawing by up to 1.25 about the canvas centre, keeping stroke width and the small variants unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
…vious visual size. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…con. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…on are both 20px. Co-authored-by: Cursor <cursoragent@cursor.com>
…entered at 20px. Co-authored-by: Cursor <cursoragent@cursor.com>
|
OK, reviewed all the material. I'll be as clear as I can, then I'll step away. The problem is real, this image shows it well. The approach taken, to scale up the artwork and subsequently scale down the icon can work. Shown here, 1/original, 2/new icon, 3/new icon scaled back down.
I'm not quite sure about the exact scale factor to scale the icon down again, shown here at 20x20, The problem becomes clearer when turning on pixel-preview:
It's valid to argue this fuzz is effectively negligible on modern screens, and that the behavior is similar to that of fonts: any scale should be possible and there will always be fuzz on some non-integer scales. So let's compare the branch (top) with trunk (bottom):
You can ignore the plus change, trunk has some tweaks to its behavior. It looks close. And maybe the fuzz I'm seeing is just me holding this work to unreasonable standards. But the image is a good comparison, because when we zoom in, we see the tiniest differences in edge enhancement notably on the alignment icons which are meant to be carved from the same stone:
It's clearer still if we go to 1x screens—which yes we can choose to ignore—but it is to say, embracing this means a deliberate tradeoff in default fidelity in the editor:
The above tickles my inner "paint the back of the fence" perfectionist which is why I'm advocating for a viewbox/artboard change instead of artwork scale change. But, it is not a hill I want to die on, let alone fight on, so I invite you all to dismiss all of the above. I now have it out of my system, the demons are exorcised, and this room is clear. But if you do choose to proceed in this fashion, I do have one conundrum I'd love to solve if we can. One that I am realising also applies to the current
After:
The corner radius is now baked into the SVG itself. Of course it has to be in the shipping SVG icons, but it means the source files are now harder to maintain. And it's not just the corners on the outer boxes, it's also the curvature of the mountain range in the above image, all square lines with radii in Figma, multiple lines with curvature in the SVG. It's used in a lot of the icons:
Is there any way this tooling can retain those Figma corner radii? Those corner radii are intact in this file (from my drafts so if a reader of this thread without access wants to see that particular file you can download this copy). Tooling is magical these days, so I imagine it might be possible. 🤞 Where does that leave us? My apprehension remains, I feel there is a better approach, and those opinions are okay to ignore if you still feel this is the correct path forward. But if we do move forward, let's explore if we can retain the Figma corner radius. Is that fair? |
ed77483 to
b31ebba
Compare
|
Thanks for taking the time to review in detail. What I'm seeing is a little softness on trunk, and slightly increased softness on this PR. So it's a question of whether the slightly increased softness is worth it to fix #73784, or if we should manually redraw the entire set again 🙈 I don't see another option that doesn't involve imperfect/confusing hacks. To my eye, at 100% zoom I don't see any meaningful difference, so I'd argue it is worth it. But I appreciate this is highly subjective so welcome more feedback from more sets of eyes :) |
If that's an option you would entertain, I'd genuinely gladly help do that, 300+ icons once more. It's easier the second time because they're strokebased now. The thought scares me less than the alternative, honestly. Not saying anything definitive one way or the other, I've had plent of say now, so I'll also simply invite more eyes. |
Just want to mention you're not alone on this point. Pixel hinting was non-negotiable before hi-dpi displays, but there's still value in it because differences in resolution, screen size, and viewing distance all mean that the fuzziness can be amplified in some circumstances. I'm not super opinionated on the method used to get there, but I'd hope the any changes keep them as sharp as they currently are, since so much care was put into that.
This is a good point, and I don't want to get too into something that may be tangential to this discussion. But in the |
|
If y'all have the time/will/energy to redraw the icons again please go ahead 🙏 Pending that I'll set this PR as a draft, feel free to takeover. Or if you prefer to start a new branch then I'll close this PR. |
|
It seems that redrawing the icons is the preference here so I'm going to close this PR. |









What?
See #73784. Scale
@wordpress/iconsdrawings by up to 1.25× about the 24×24 canvas centre so typical icons fill more of their artboard, and render icons at 20px by default so that larger artwork stays close to its previous visual size.This does not add a cropped/
IconUnboxedexport. TheviewBoxstays0 0 24 24andstroke-widthstays1.5. The empty padding inside the artboard shrinks, and the rendered size shrinks with it.Why?
Most icons sat at about 16 units across on the 24 canvas. With a colour background that extra space is invisible; without one, left-aligning an icon with text below it is hard because the visible path starts several units in from the SVG edge.
Leaving the drawings at 1.25× and still painting them at 24px would make every icon look larger than on trunk.
20/24 × 1.25is about 1.04, so a 20px render keeps the visible size about the same. Once #84081 removesvector-effect="non-scaling-stroke", a 1.5 stroke in this viewBox paints at 1.25px at 20px, 1px at 16px, and 1.5px at 24px.How?
(12, 12). Cap each icon so stroked artwork stays within 22 units. About 80 icons already filled more of the canvas and grew by less than 1.25×. Seven already reached the cap and were left unchanged:addCard,addTemplate,html,insertBefore,postComments,postCommentsCount,postCommentsForm.*-smallvariants and thewordpressmark unchanged.cog: its inner ring is a second overlapping stroke, so after scaling the two strokes no longer met. The inner radius is now the outer radius minus 1.25 so they overlap again.Iconsize from 24 to 20 in@wordpress/icons,@wordpress/components, and@wordpress/ui, and set$icon-sizeto 20px. Hardcoded 24px icon sizes in the component packages, the block editor, the editor, and the site editor move to 20px with them.viewBox="0 0 24 24"to the Site Tagline and Icon block glyphs. They omitted a view box, so the 20px size left the artwork centered at 12px instead of 10px.Testing Instructions
packages/icons) and scan the full library. The default render is now 20px.closeSmall,chevronDownSmall, and other*Smallicons are still distinctly smaller than their regular versions.Testing Instructions for Keyboard
No interaction changes. Tab through a toolbar and a menu that contain icons and confirm focus rings and hit targets are unchanged.
Screenshots or screencast
Library before
Library after
Editor before
Editor after
Reviewers: please look especially at
cog(inner ring), letterform icons (headingLevel*,typography), frontend Icon blocks (saved width, larger drawing), and any consumer that used a negative margin to optically balance an icon.components-menu-itemstill appliesmargin-left: -2pxfor that reason.For anyone keen to visually inspect the vectors here's a Figma.
Use of AI Tools
A Cursor agent wrote the one-off scaling script, ran it over the library, updated the default render size and the call sites that hardcoded 24px, updated snapshots, and drafted this PR. The
coginner-ring fix and the decision to use a uniform 1.25× factor with a 22-unit cap were reviewed against a full contact sheet of original vs scaled icons.