Skip to content

Commit

Permalink
Update Icon.java
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 13, 2022
1 parent efd57ff commit 2e6c2d7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/src/main/java/org/jenkins/ui/icon/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Icon {
private final String normalizedSelector;
private final String url;
private final String style;
private String xml;
private IconType iconType;
private IconFormat iconFormat;

Expand Down Expand Up @@ -135,6 +136,22 @@ public Icon(String classSpec, String url, String style, IconType iconType, IconF
this.iconFormat = iconFormat;
}

/**
* @param xml The XML of the SVG image you want to use
* You can use icon sources such as Ionicon eg
* 'Icon.fromSvg(IconSet.getIonicon("terminal-outline", null))' to get SVG data
* @return an Icon object with the svg field set
*/
public static Icon fromSvg(String xml) {
if (xml == null) {
return null;
}

Icon icon = new Icon("", "", "", IconFormat.EXTERNAL_SVG_SPRITE);
icon.xml = xml;
return icon;
}

/**
* Get the class specification for this Icon.
* @return The class specification for this Icon.
Expand Down Expand Up @@ -211,6 +228,10 @@ public String getStyle() {
return style;
}

public String getXml() {
return xml;
}

/**
* Normalize the supplied string to an Icon name class e.g. "blue_anime" to "icon-blue-anime".
*
Expand Down

0 comments on commit 2e6c2d7

Please sign in to comment.