-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Custom Block Icons #8916
Custom Block Icons #8916
Conversation
I love that this uses raw SVGs instead of some kind of special icon name thing. Encouraging raw SVGs is great. Hopefully this also opens the door to improving those icons without worrying about matching an icon suite necessarily — that quote icon, for instance, feels like it could use a little love. Because it's raw SVG I imagine it'll be easier to make small case-by-case tweaks rather than trying to get Google to approve a design change upstream. Super cool! |
I think it's not easy to distinguish whether the title applies to the icon above it or under it. I think we can fix this by reducing the padding of the buttons and increasing the margin bottom of the items. (Something like the screenshot above) Also, I don't like the fact that the scrollbars show up surrounded by a padding. I think it's better to avoid the global padding and move it to each child div instead, that way the scrollbars show up at the edge. |
</g> | ||
</svg> | ||
); | ||
|
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 SVG seems to have a bunch of unnecessary IDs and tags.
@youknowriad regarding spacing, the issue and where tightness visually happens is adding background to icons. Here are some explorations: |
I just came across this PR and noted that some of the SVGs use the following pattern:
Note that there is no
for all icons to take advantage of SVGs intrinsic responsiveness, both to enable theming and for the sake of maintainablility. (All you'll ever have to do is adjust sizes in CSS.) As an aside none of the other attributes sprinkled through there are really needed:
|
It might be helpful to run the icons through |
Thanks @ccprog for the tips! This is just a rough prototype at the moment. The default height / width was needed for the branch because in some cases there wasn't one provided by the CSS and it needed a fallback. They are to be removed before merging. @chrisvanpatten I ran them through that tool at some point but it destroyed the shapes. Probably some wrong configuration, but we can probably just do the cleanup manually once we are ready. |
@chrisvanpatten SVGO is a heavily opinonated tool. In this case, it would remove the viewBox as a default. Despite what the GUI seems to claim, it cannot add a missing viewBox. Option "Prefer viewBox to width/height" only means it will dellete width/height if a viewBox is present. If it is not, a conscious designer decision is needed. |
What impact this PR should have on the block switcher's icon and the block style variations panel? (which mimic the inserter design) |
@youknowriad it updates those. |
In 5874f5b I pushed a little polish to focus and hover styles of blocks: |
Oh, better structure for the scrollbar would also be needed. |
I can fix it tomorrow so the scrollbar is right on the edge of the window as opposed to floating in the middle, if that's what you mean? I'll be sure to fix the padding also. |
The label text (Quote) looks too far to the bottom of the hover background in this image. |
This is sort of a side-effect of us removing the gray background around each icon. Look at the Columns block to see an outline of where they used to be. One of the thigns to keep in mind is that blocks can color icons, and icon backgrounds, and this is later used in the block chip seen in the switcher and in the inspector. This is also used in the library, but no longer the gray background for icons that have no defined background. This is something I hope to revisit later on, to see if we can balance better so it isn't so overwhelming, but I feel like it might be good to get this out first as an iteration and then revisit. |
I definitely like the direction this is going but all that padding on the outside edge just feels weird vs having it extend full-width. It creates a weirdly raggedy edge… vs (EDIT: Just looking again at these screenshots side-by-side, it ironically feels like the version without the padding on the But I do like the new icons (feels super weird for WordPress to use Material Icons instead of a WordPress-specific icon set, but they still work) and the lack of a background on the default icons isn't as bothersome in practice as I thought it might be. Overall looks good! |
I pushed a refactoring to BlockIcons rendering which hopefully 🤷♂️ does:
|
Uses custom svgs at a 24px base, 36px upscale for the inserter. WordPress should signal that block icons ought to be custom for the sake of clarity for users.
cb665f2
to
f5ee80c
Compare
So tests pass, I think we're ready to ship. Could anyone test everything for last minute breakage? @chrisvanpatten I'm not designer but I had the same thoughts, I feel without the padding, it's better but that's shouldn't block us here. It's still a huge improvement over what we have, we can merge and iterate. |
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.
LGTM 👍
Only remaining thing I noticed, but shouldn't be a blocker, is that dashicons now render blurry in non-retina displays (they may also be blurry in Retina, but I expect not because pixels!) because they're upscaled. It'd be nice if there was a fallback that just padded the dashicons instead of upscaling. But again, that shouldn't be a blocker. |
test/e2e/specs/block-icons.test.js
Outdated
@@ -130,7 +130,7 @@ describe( 'Correctly Renders Block Icons on Inserter and Inspector', () => { | |||
it( 'Renders the icon in the inserter with the correct background color and an automatically compute readable foreground color', async () => { | |||
await searchForBlock( blockTitle ); | |||
validateSvgIcon( await getFirstInserterIcon() ); | |||
expect( await getBackgroundColor( INSERTER_ICON_SELECTOR ) ).toEqual( 'rgb(1, 0, 0)' ); | |||
expect( await getBackgroundColor( INSERTER_ICON_SELECTOR ) ).toEqual( 'rgba(0, 0, 0, 0)' ); |
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 background color is in fact rgb(1, 0, 0) and with this change we don't verify if the background was in fact applied. I think we may need to update the selector const INSERTER_ICON_SELECTOR = ${ INSERTER_BUTTON_SELECTOR } .editor-block-icon
; to be ${ INSERTER_BUTTON_SELECTOR } .editor-block-types-list__item-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.
Oh gotcha I'll take a look
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.
.editor-block-icon is a child of .editor-block-types-list__item-icon and it seems colors are applied in .editor-block-types-list__item-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.
It should be fixed.
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 think we should ship what we have right now. The indent visually does help for padding on scrolling. Let's get in as we have now and we can always iterate.
Awesome work everyone, I love those PRs where so many people push code and review :P |
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.
Curious the impact this might have on bundle size. Probably not critical impact, but I'm sure it's a bump.
{ renderedIcon } | ||
</div> | ||
); | ||
const style = showColors ? { |
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.
Wasted effort to assign variable when following condition shortcuts early return without using (should be assigned after condition).
As per the update in #8916, our core blocks now use Material Design icons. This PR updates our design doc about block design to reflect that.
With this change, all the new hardcoded SVG icons miss the attributes required for accessibility: |
You can assign that issue to me. |
As per the update in #8916, our core blocks now use Material Design icons. This PR updates our design doc about block design to reflect that.
In Progress
This update seeks to add custom icons to the block library in order to reduce the expectation of dashicon usage on blocks, which has resulted in a loss of clarity as soon as multiple blocks share the same icon (quote and pullquote, for example). Dashicons were also designed for UI affordance while blocks have distinct qualities that we should reflect.
It also hopes to encourage people to supply a custom SVG for their own blocks.
Closes #8719.
The new icons have a 24px base grid (pulling from Material design). All core blocks have been replaced except for a few where we had custom icons already which need updating to the new sizing (shortcode and custom HTML). This also reworks all the icons used for embeds and favors service specific icons when available for clarity.
Missing Icons
Remaining Tasks