Feature: #70583 - Introduced Icon API in JavaScript
See forge#70583
Description
A JavaScript-based icon API based on the PHP API has been introduced. The methods get
and get
can be called in a RequireJS module.
When imported in a RequireJS module, a developer can fetch icons via JavaScript with the same parameters as in PHP.
The methods get
and get
return Promise
objects.
Importing
define(['jquery', 'TYPO3/CMS/Backend/Icons'], function($, Icons) {
});
Copied!
Get icons
A single icon can be fetched by get
which takes four parameters:
- identifier
- The icon identifier.
- size
- The size of the icon. Please use the properties of the
Icons.
object.sizes - overlayIdentifier
- An overlay identifier rendered on the icon.
- state
- The state of the icon. Please use the properties of the
Icons.
object.states
To use the fetched icons, chain the done
method to the promise.
Examples
// Get a single icon
Icons.getIcon('spinner-circle-light', Icons.sizes.small).done(function(spinner) {
$toolbarItemIcon.replaceWith(spinner);
});
Copied!