SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:21
Basic SVG icon, extends SvgImage.
Usage:
import iconSrc from "./path/to/icon.svg";
const icon = new SvgIcon(iconSrc, ".my-container") // Create and mount icon .setContainerAttrs({ title: "My icon" }) // Set container attributes .setColor("red") // Set icon color to red .setColorTransition("0.2s ease-out"); // Change icon color transitionExtends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SvgIcon(
src,mountTo?):SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:46
Parameters
Section titled “Parameters”string
SVG source code
mountTo?
Section titled “mountTo?”Element or selector of an element to mount image to. If not provided, image won’t be mounted.
Returns
Section titled “Returns”SvgIcon
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_color
Section titled “_color”
protected_color:string=""
Defined in: vanilla-integration/src/SvgIcon.ts:35
Icon color
_colorTransition
Section titled “_colorTransition”
protected_colorTransition:string=""
Defined in: vanilla-integration/src/SvgIcon.ts:40
Icon color transition
_container
Section titled “_container”
protected_container:Element|undefined
Defined in: vanilla-integration/src/SvgImage.ts:53
Element containing this SvgImage (element passed to mount)
Inherited from
Section titled “Inherited from”
protected_size:string=""
Defined in: vanilla-integration/src/SvgIcon.ts:30
Icon size
protected_span:HTMLSpanElement
Defined in: vanilla-integration/src/SvgIcon.ts:25
<span> element that wraps _svgEl
protected_src:string|undefined
Defined in: vanilla-integration/src/SvgImage.ts:48
User-provided source code
Inherited from
Section titled “Inherited from”_svgAttrs
Section titled “_svgAttrs”
protected_svgAttrs:Record<string,any> ={}
Defined in: vanilla-integration/src/SvgImage.ts:68
User-provided attributes
Inherited from
Section titled “Inherited from”_svgEl
Section titled “_svgEl”
protectedreadonly_svgEl:SVGElement
Defined in: vanilla-integration/src/SvgImage.ts:58
<svg> element
Inherited from
Section titled “Inherited from”_updateSrcRes
Section titled “_updateSrcRes”
protected_updateSrcRes: {attrs?:undefined;id?:undefined; } | {attrs: {height:string;viewBox:string;width:string; };id:string; } | {attrs?:undefined;id:string; } ={}
Defined in: vanilla-integration/src/SvgImage.ts:78
Last onSrcUpdate call result
Inherited from
Section titled “Inherited from”_useEl
Section titled “_useEl”
protectedreadonly_useEl:SVGUseElement
Defined in: vanilla-integration/src/SvgImage.ts:63
<use> element
Inherited from
Section titled “Inherited from”_useElAttrs
Section titled “_useElAttrs”
protected_useElAttrs:Record<string,any> ={}
Defined in: vanilla-integration/src/SvgImage.ts:73
User-provided attributes
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_setWrapperClass()
Section titled “_setWrapperClass()”
protected_setWrapperClass():void
Defined in: vanilla-integration/src/SvgIcon.ts:96
Sets wrapper’s (_span) class property to match stylesheet
Returns
Section titled “Returns”void
_updateSvgEl()
Section titled “_updateSvgEl()”
protected_updateSvgEl():this
Defined in: vanilla-integration/src/SvgIcon.ts:70
Updates SVG element: sets SVG source code, clears previous attributes, sets new attributes
Returns
Section titled “Returns”this
this
Overrides
Section titled “Overrides”_updateUseEl()
Section titled “_updateUseEl()”
protected_updateUseEl():SvgIcon
Defined in: vanilla-integration/src/SvgImage.ts:156
Updates <use> element attributes
Returns
Section titled “Returns”SvgIcon
this
Inherited from
Section titled “Inherited from”getColor()
Section titled “getColor()”getColor():
string
Defined in: vanilla-integration/src/SvgIcon.ts:142
Returns
Section titled “Returns”string
Current icon color or empty string, if color is unset
getColorTransition()
Section titled “getColorTransition()”getColorTransition():
string
Defined in: vanilla-integration/src/SvgIcon.ts:160
Returns
Section titled “Returns”string
Current icon color transition or empty string, if transition is unset
getContainer()
Section titled “getContainer()”getContainer():
Element|undefined
Defined in: vanilla-integration/src/SvgImage.ts:189
Returns
Section titled “Returns”Element | undefined
A container of this image, or undefined, if image is not mounted
Inherited from
Section titled “Inherited from”getSize()
Section titled “getSize()”getSize():
string
Defined in: vanilla-integration/src/SvgIcon.ts:124
Returns
Section titled “Returns”string
Current icon size or empty string, if size is unset
getSrc()
Section titled “getSrc()”getSrc():
string|undefined
Defined in: vanilla-integration/src/SvgImage.ts:182
Returns
Section titled “Returns”string | undefined
SVG source code
Inherited from
Section titled “Inherited from”getSvgEl()
Section titled “getSvgEl()”getSvgEl():
SVGElement
Defined in: vanilla-integration/src/SvgImage.ts:200
Returns <svg> element.
To assign attributes, use setSvgElAttrs instead.
Returns
Section titled “Returns”SVGElement
<svg> element
Inherited from
Section titled “Inherited from”getUseEl()
Section titled “getUseEl()”getUseEl():
SVGUseElement
Defined in: vanilla-integration/src/SvgImage.ts:211
Returns <use> element.
To assign attributes, use setSvgElAttrs instead.
Returns
Section titled “Returns”SVGUseElement
<use> element
Inherited from
Section titled “Inherited from”getWrapper()
Section titled “getWrapper()”getWrapper():
HTMLSpanElement
Defined in: vanilla-integration/src/SvgIcon.ts:103
Returns
Section titled “Returns”HTMLSpanElement
Wrapper (<span>) element
mount()
Section titled “mount()”mount(
to):this
Defined in: vanilla-integration/src/SvgIcon.ts:58
Mounts image to the given element
Parameters
Section titled “Parameters”Element or selector of an element to mount image to
Returns
Section titled “Returns”this
this
Overrides
Section titled “Overrides”setColor()
Section titled “setColor()”setColor(
color):SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:133
Sets icon color. Empty string or undefined unsets color.
Parameters
Section titled “Parameters”Color to set, for example: "red", "var(--icon-color)".
string | undefined
Returns
Section titled “Returns”SvgIcon
this
setColorTransition()
Section titled “setColorTransition()”setColorTransition(
transition):SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:151
Sets icon color transition. This transition is applied when icon color is changed.
Parameters
Section titled “Parameters”transition
Section titled “transition”string = DEFAULT_COLOR_TRANSITION
Transition to set, for example: "0.3s linear", "var(--icon-transition)"
Returns
Section titled “Returns”SvgIcon
this
setSize()
Section titled “setSize()”setSize(
size):SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:112
Sets icon size. Empty string or undefined unsets size.
Parameters
Section titled “Parameters”Size to set, for example: "24px", "1rem"
string | undefined
Returns
Section titled “Returns”SvgIcon
this
setSrc()
Section titled “setSrc()”setSrc(
src):SvgIcon
Defined in: vanilla-integration/src/SvgImage.ts:171
Sets SVG source code
Parameters
Section titled “Parameters”string
SVG source code
Returns
Section titled “Returns”SvgIcon
this
Inherited from
Section titled “Inherited from”setSvgElAttrs()
Section titled “setSvgElAttrs()”setSvgElAttrs(
attrs):SvgIcon
Defined in: vanilla-integration/src/SvgImage.ts:122
Sets <svg> element attributes. It won’t remove id, class and style.
Parameters
Section titled “Parameters”Record<string, any>
Attributes to set
Returns
Section titled “Returns”SvgIcon
this
Inherited from
Section titled “Inherited from”setUseElAttrs()
Section titled “setUseElAttrs()”setUseElAttrs(
attrs):SvgIcon
Defined in: vanilla-integration/src/SvgImage.ts:147
Sets <use> element attributes. It won’t remove id, class and style.
Parameters
Section titled “Parameters”Record<string, any>
Attributes to set
Returns
Section titled “Returns”SvgIcon
this
Inherited from
Section titled “Inherited from”setWrapperAttrs()
Section titled “setWrapperAttrs()”setWrapperAttrs(
attrs):SvgIcon
Defined in: vanilla-integration/src/SvgIcon.ts:84
Sets wrapper (<span>) element attributes.
Warning: you can’t change class, size, color and color transition using this method
Parameters
Section titled “Parameters”Record<string, any>
Attributes to set
Returns
Section titled “Returns”SvgIcon
this
unmount()
Section titled “unmount()”unmount():
this
Defined in: vanilla-integration/src/SvgIcon.ts:63
Removes image from the container
Returns
Section titled “Returns”this
this