-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
[Block] IconAffects the Icon blockAffects the Icon block[Feature] IconRelated to Icon registration API and Icon REST APIRelated to Icon registration API and Icon REST API[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.
Description
Important Issues and PRs:
We have stabilized three core features and shipped them in 7.0 Beta1:
WP_Icons_Registryclass: The singleton class that loads core SVG icons from a manifest file, stores them, and exposes methods to check registration and retrieve icon data and content. There is currently no way to register a custom icon.WP_REST_Icons_Controller: The REST API controller that exposes the icon registry overwp/v2/icons, letting the editor list icons and fetch a single icon by name.- Icon block (
core/icon): The core block that retrieves a list of icons from the endpoint and lists them in a modal. The selected icon name is saved as an attribute, and the content is rendered server-side via the icon registry.
To make the Icon API more robust and extensible, I believe the following features are necessary:
Icon registry enhancements
- Create public APIs (ref): I think we need APIs like the one below to allow consumers to filter the core icons and submit custom icons.
register_icon()functionunregister_icon()functioncore-iconstheme support: This is similar to thecore-block-patternstheme support: if this support is disabled, all core icons will not be registered.
- SVG sanitization (ref): There is no core function to properly sanitize SVGs, so a class method currently does the job, but it is not perfect, and there is room for improvement. See #75550 for more details. Maybe we could create a core function like
sanitize_svg()instead.
Icons Registry: improve SVG sanitizer #75550 - Icon namespace validation (ref): Currently, custom icon registration is not allowed, and the namespace is hardcoded as
core/. If we allow custom icon registration in the future, we will need to strictly check that the icon name follows the{namespace/icon-name}format.
Icons: Enforce strict name validation inregistermethod #76079
REST API enhancements
- Search based on keywords: The current endpoint allows us to filter icons by the
searchparameter, but only thenamefield is referenced. We could also reference thelabelfield and an optionalkeywordsfield. Icons API: Support searching in labels; extend classes post-7.0 work #75878
Category Support
Similar to block patterns, it should be possible to support categories: consumers will want to group icon sets based on their own brand.
- Create a registry like
WP_Icon_Categories_Registry - Create an endpoint like
WP_REST_Icons_Categories_Controller - Create public APIs:
register_icon_category()functionunregister_icon_category()function
Create Icon Picker Modal component
- To avoid increasing bundle size, the initial implementation built a custom picker without using
DataViewPicker. (ref) Perhaps it should be possible to add a component likeIconPickerModalto the@wordpress/block-editorpackage and load it from a block. This icon picker should be useful for blocks other than the Icon block as well.DataViewsPickerbased UI- Filter icons by category
Icon block enhancements
- For example, the early prototype of the Icon Block had the following features, which we can consider as enhancements:
- Flip icon (Vertical or Horizontal)
- Rotate
- Should we allow icons to have links?
Customizable icon support for other blocks
Some icons render their own hard-coded SVG content or symbols. Make those icons selectable via the Icon API.
- Navigation block: Toggle button, Overlay Close button
- Breadcrumbs: Separator (The text can be changed, but the icon cannot be used)
- Navigation Overly Close block: Close icon
- Accordion Heading lock: Toggle icon (
+symbol) - Details block: Browser default triangle symbol
Inline SVG icon (Inline format)
- At the moment I don't know how to implement this. Perhaps it will be based on "BITS". (ref)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Block] IconAffects the Icon blockAffects the Icon block[Feature] IconRelated to Icon registration API and Icon REST APIRelated to Icon registration API and Icon REST API[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.