Methods
-
<async, static> appendIcon(container, icon)
-
Appends an SVG icon to a container element Handles both string selectors and SVG elements Automatically manages viewBox and transformations
Parameters:
Name Type Description container
HTMLElement Target DOM element to append icon to
icon
string | SVGElement Icon selector or SVG element
Returns:
Processed and appended SVG element
Processing steps:
- Loads icon (from selector or element)
- Creates SVG wrapper if needed
- Computes and sets viewBox
- Applies padding
- Handles transformations
- Appends to container
- Type
- Promise.<SVGElement>
Example
```javascript // Append by selector const icon1 = await Skin.appendIcon( document.querySelector('.toolbar'), '.openlime-zoom' ); // Append existing SVG const icon2 = await Skin.appendIcon( container, existingSvgElement ); ```
-
<async, static> getElement(selector)
-
Retrieves a specific element from the skin by CSS selector Automatically loads the SVG if not already loaded
Parameters:
Name Type Description selector
string CSS selector for the desired element
Throws:
-
Implicitly if element not found
- Type
- Error
Returns:
Cloned SVG element
- Type
- Promise.<SVGElement>
Example
```javascript // Get home icon const homeIcon = await Skin.getElement('.openlime-home'); // Get menu button const menuBtn = await Skin.getElement('.openlime-menu'); ```
-
-
<async, static> loadSvg()
-
Loads and parses the skin SVG file Creates a DOM-based SVG element for future use
Throws:
-
If SVG file fails to load
- Type
- Error
Returns:
- Type
- Promise.<void>
Example
```javascript await Skin.loadSvg(); // SVG is now loaded and ready for use ```
-
-
<static> setUrl(url)
-
Sets the URL for the skin SVG file
Parameters:
Name Type Description url
string Path to SVG file containing UI elements
Example
```javascript // Set custom skin location Skin.setUrl('/assets/custom-skin.svg'); ```