Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-73187] - Do not apply icon size to text badges #153

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ public String getBorderColor() {
*/
public String getIconClass() {
List<String> classes = new LinkedList<>();
classes.add("icon-sm"); // control icon image size
if (!isTextOnly()) {
classes.add("icon-sm"); // control image size only when using an icon
}

if (this.color != null) {
if (this.color.startsWith("jenkins-!-")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,45 @@ THE SOFTWARE.
<j:if test="${it.iconPath != null}">
<j:set var="badgeStyle" value=""/>
<j:if test="${it.iconColorStyle != null}">
<j:set var="badgeStyle" value="${badgeStyle};color: ${it.iconColorStyle};"/>
</j:if>

<j:if test="${it.link == null}">
<l:icon src="${it.iconPath}" class="${it.iconClass}" style="${badgeStyle}" htmlTooltip="${it.text}" />
<j:set var="badgeStyle" value="color: ${it.iconColorStyle};"/>
</j:if>

<j:if test="${it.link != null}">
<a href="${it.link}"><l:icon src="${it.iconPath}" class="${it.iconClass}" style="${badgeStyle}" htmlTooltip="${it.text}" /></a>
</j:if>
<j:choose>
<j:when test="${it.link == null}">
<l:icon src="${it.iconPath}" class="${it.iconClass}" style="${badgeStyle}" htmlTooltip="${it.text}" />
</j:when>
<j:otherwise>
<a href="${it.link}"><l:icon src="${it.iconPath}" class="${it.iconClass}" style="${badgeStyle}" htmlTooltip="${it.text}" /></a>
</j:otherwise>
</j:choose>
</j:if>

<j:if test="${it.iconPath == null}">
<st:adjunct includes="com.jenkinsci.plugins.badge.assets"/>
<j:set var="badgeStyle" value=""/>
<j:set var="badgeStyle" value="border: solid"/>
<j:set var="badgeClass" value="badge-shortText"/>
<j:if test="${it.border != null}">
<j:set var="badgeStyle" value="${badgeStyle};border: ${it.border} solid ${it.borderColor}"/>
</j:if>
<j:if test="${it.background != null}">
<j:set var="badgeStyle" value="${badgeStyle};background: ${it.background}"/>
</j:if>
<j:if test="${it.background == null}">
<j:set var="badgeClass" value="${badgeClass} badge-shortText--default-background"/>
<j:set var="badgeStyle" value="border: ${it.border} solid ${it.borderColor}"/>
</j:if>
<j:choose>
<j:when test="${it.background == null}">
<j:set var="badgeClass" value="${badgeClass} badge-shortText--default-background"/>
</j:when>
<j:otherwise>
<j:set var="badgeStyle" value="${badgeStyle};background: ${it.background}"/>
</j:otherwise>
</j:choose>
<j:if test="${it.iconColorStyle != null}">
<j:set var="badgeStyle" value="${badgeStyle};color: ${it.iconColorStyle};"/>
</j:if>

<j:if test="${it.link == null}">
<div style="${badgeStyle}" class="${it.iconClass} ${badgeClass}">${it.text}</div>
</j:if>

<j:if test="${it.link != null}">
<a href="${it.link}"><span style="${badgeStyle}" class="${it.iconClass} ${badgeClass}">${it.text}</span></a>
</j:if>
<j:choose>
<j:when test="${it.link == null}">
<span style="${badgeStyle}" class="${it.iconClass} ${badgeClass}">${it.text}</span>
</j:when>
<j:otherwise>
<a href="${it.link}"><span style="${badgeStyle}" class="${it.iconClass} ${badgeClass}">${it.text}</span></a>
</j:otherwise>
</j:choose>
</j:if>

</j:jelly>
30 changes: 0 additions & 30 deletions src/main/resources/com/jenkinsci/plugins/badge/assets.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void getIconClass(@SuppressWarnings("unused") JenkinsRule r) {
assertEquals("icon-sm jenkins-!-color-blue", action.getIconClass());
action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "jenkins-!-color-red", "", null);
assertEquals("icon-sm jenkins-!-color-red", action.getIconClass());
action = BadgeAction.createShortText("Short text");
assertEquals("", action.getIconClass()); // Short text must not set icon-sm class
// teal is not in the palette
action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
assertEquals("icon-sm", action.getIconClass());
Expand Down