Utility functions for working with icons and associated HTML.
- Description:
Utility functions for working with icons and associated HTML.
- Source:
Methods
(static) toCssClass(uri) → {String}
- Description:
Convert the URI to a usable CSS class, expected to be represented in the
spritesheet CSS for that module.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
String |
Returns:
- Type
- String
(static) toElements(icon, syncopt) → {Promise.<Array.<HTMLSpanElement>>}
- Description:
Just like
toHtml, but resolves an array of raw Elements instead.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
icon |
String | baja.Ord | Array.<(String|baja.Ord)> | baja.Simple | icon as |
||
sync |
boolean |
<optional> |
false
|
set to true to wait for the image to finish |
Returns:
to be resolved with an array of
span elements
- Type
- Promise.<Array.<HTMLSpanElement>>
(static) toHtml(icon, syncopt) → {Promise.<string>}
- Description:
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.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
icon |
String | baja.Ord | Array.<(String|baja.Ord)> | baja.Simple | icon as |
||
sync |
boolean |
<optional> |
false
|
set to true to wait for the image to finish |
Returns:
promise to be resolved with a raw HTML string containing
one or more span tags
- Type
- Promise.<string>
(static) toImageMetrics(icon) → {Promise.<module:bajaux/icon/iconUtils~ImageMetrics>}
- Description:
Given an icon, calculate the metrics needed to paint the icon in a painting
context such as a canvas.
- Source:
- Since:
- Niagara 4.11
Parameters:
| Name | Type | Description |
|---|---|---|
icon |
String | baja.Ord | Array.<(String|baja.Ord)> | baja.Simple | icon as |
Returns:
- Type
- Promise.<module:bajaux/icon/iconUtils~ImageMetrics>
(static) toUris(icon) → {Array.<String>}
- Description:
Convert a value to an array of image URIs.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
icon |
String | baja.Ord | Array.<(String|baja.Ord)> | baja.Simple | a string |
Throws:
-
if invalid input given
- Type
- Error
Returns:
array of image URIs
- Type
- Array.<String>
Type Definitions
ImageMetrics
- Description:
Metrics needed to paint an icon in a painting context such as a canvas.
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
uri |
string | URI of the image to paint |
x |
number | pixels from left edge of the image |
y |
number | pixels from top edge of the image |
width |
number | width in pixels |
height |
number | height in pixels |
Metrics needed to paint an icon in a painting context such as a canvas.