Repository navigation
Icon block: Show collection name in the "All" tab of the icon library #84055
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
Changes from 4 commits
d1f19bb
0cba690
d9ef451
3861417
2dd9c81
eb88a30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Groups icons by collection, in the order of `collections`. | ||
| * | ||
| * @param {Object[]} icons Icons, each with a `collection` slug. | ||
| * @param {Object[]} collections Icon collections, each with a `slug` and `label`. | ||
| * @return {Object[]} Groups, each with a `slug`, `label` and `icons`. | ||
| */ | ||
| export function groupIconsByCollection( icons, collections ) { | ||
| const groups = new Map( | ||
| collections.map( ( { slug, label } ) => [ | ||
| slug, | ||
| { slug, label, icons: [] }, | ||
| ] ) | ||
| ); | ||
|
|
||
| icons.forEach( ( icon ) => { | ||
| groups.get( icon.collection )?.icons.push( icon ); | ||
| } ); | ||
|
|
||
| return [ ...groups.values() ].filter( ( group ) => group.icons.length ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,18 @@ | |||||
| overflow-wrap: break-word; | ||||||
| } | ||||||
|
|
||||||
| .wp-block-icon__inserter-modal .wp-block-icon__inserter-grid-group-title { | ||||||
| position: sticky; | ||||||
| top: -$grid-unit-05; | ||||||
| z-index: 1; | ||||||
| padding: $grid-unit-15 $grid-unit-05; | ||||||
| margin: 0; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to the top property having a negative value, the title shifts by 4px when scrolling. icon-shift.mp4To avoid this, a negative top margin would likely be effective.
Suggested change
However, because this style also affects subsequent headings, they appear slightly shifted upward.
Therefore, we might need a little more space between the icon groups.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this! The jump comes from the modal contents 4px top padding ( .wp-block-icon__inserter-modal .wp-block-icon__inserter-grid > :first-child > .wp-block-icon__inserter-grid-group-title {
margin-top: -$grid-unit-05;
}
I have added the above fix. |
||||||
| color: var(--wpds-color-foreground-content-neutral-weak); | ||||||
| text-transform: uppercase; | ||||||
| font-size: var(--wpds-typography-font-size-sm); | ||||||
| background-color: $white; | ||||||
| } | ||||||
|
|
||||||
| .wp-block-icon__toolbar-content { | ||||||
| width: 250px; | ||||||
| } | ||||||
|
|
||||||

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
aria-labelhas no effect because this element is adiv, which has thegenericrole.We can simply refactor it like this:
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.
Updated to remove the aria-label.