Utility functions for working with icons and associated HTML.
Methods
-
<static> toCssClass(uri)
-
Convert the URI to a usable CSS class, expected to be represented in the
spritesheet CSS for that module.Parameters:
Name Type Description uriString Returns:
- Type
- String
-
<static> toElements(icon [, sync])
-
Just like
toHtml, but resolves an array of raw Elements instead.Parameters:
Name Type Argument Default Description iconString | baja.Ord | Array.<(String|baja.Ord)> | baja.Icon syncboolean <optional>
false set to true to wait for the image to finish
loading (making it possible to query it for width/height) before the
toHtmlpromise resolvesReturns:
to be resolved with an array of
spanelements- Type
- Promise.<Array.<HTMLSpanElement>>
-
<static> toHtml(icon [, sync])
-
Given an icon value (string,
baja.Icon, etc), convert it into a usable
HTML snippet.The HTML will consist of a one or more
spantags. Eachspanwill have
oneimgelement. If the icon is accounted for in a spritesheet, the
imgtag will be hidden and the icon will be represented solely by the
spanusing pure CSS. If the icon is not in a spritesheet, theimg
tag will be shown and have itssrctag set to the raw icon image.Parameters:
Name Type Argument Default Description iconString | baja.Ord | Array.<(String|baja.Ord)> | baja.Icon syncboolean <optional>
false set to true to wait for the image to finish
loading (making it possible to query it for width/height) before the
toHtmlpromise resolvesReturns:
promise to be resolved with a raw HTML string containing
one or morespantags- Type
- Promise.<string>
-
<static> toUris(icon)
-
Convert a value to an array of image URIs.
Parameters:
Name Type Description iconString | baja.Ord | Array.<(String|baja.Ord)> | baja.Icon a string
or array of strings. Each string can be a URI directly, or amodule://
ORD. These will be converted to URIs to image files. If passing in
arbitrary ORDs, it's recommended to relativizeToSession() first.Throws:
-
if invalid input given
- Type
- Error
Returns:
array of image URIs
- Type
- Array.<String>
-