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

Conversation

MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented May 18, 2024

JENKINS-73187 - Do not apply icon size to text badges

This is a prototype that I'd like to use for discussion. I think that it may go "too far" along the path to compatibility with the 1.9.1 release of the badge plugin, but I think it is worth discussion from others who are more expert in CSS and page layout.

JENKINS-73187 describes result of the mistake that I made when setting the icon class to always include "icon-sm". Short text badges do not need to be limited by that class because it causes the text field to be too small for any text to fit.

Fixes #152 as well.

Includes a test for the icon class of short text.

That change (in the first commit in the pull request) resolves the most glaring issue, but then I started comparing the new layout with the 1.9.1 layout. The second commit restores the short text layout from the 1.9.1 release and removes the CSS styling of the short text box. The Jenkins design library probably has much better ways of styling that text box, but I've not explored those techniques.

The third commit in the pull request replaces paired "if / if not" conditions with paireed "when / otherwise" conditions. I think it makes the jelly file a little easier to read.

Testing done

Compared the layout of short text badges in Jenkins 2.452.1 with plugin version 1.9.1 and with this pull request.

Results for comparison will be uploaded to the pull request as images

Submitter checklist

Preview Give feedback

Testing details

Compared the results with badge plugin 1.9.1 and this pull request

Short text

With the Pipeline script:

addShortText text: 'Less text'

Badge 1.9.1

Screenshot 2024-05-18 085623

Badge PR-153

Screenshot 2024-05-18 085956

Short text with yellow background

With the Pipeline script:

addShortText text: 'few words', background: 'yellow'

Badge 1.9.1

Screenshot 2024-05-18 090359

Badge PR-153

Screenshot 2024-05-18 090423

https://issues.jenkins.io/browse/JENKINS-73187 describes the mistake
that I made when setting the icon class to always include "icon-sm".
Short text badges do not need to be limited by that class because it
causes the text field to be too small for any text to fit.

Fixes jenkinsci#152 as well.

Include a test for the icon class of short text.
The CSS file makes the short text badge better looking but also makes
it use much more space.  Better to switch back to the previous layout
rather than disrupt existing users with a larger layout.
Makes it clear where the conditional is being applied.
@MarkEWaite MarkEWaite requested a review from a team as a code owner May 18, 2024 12:45
@MarkEWaite MarkEWaite added the bug Something isn't working label May 18, 2024
@strangelookingnerd
Copy link
Contributor

I like the idea and followed a quite similar one in #151 as well. I expose the style and class attributes of an enclosing <span> for the text / icon and let the user have all the freedom they desire. For the icons itself I still hard-coded icon-sm as class, just to not render huge images by default. This may go a little too far for this issue here.

I can see some minor differences in the screenshots you provided that I'd like to investigate a little further and see how some edge cases behave (larger text, multiple rows, etc.).

@mPokornyETM
Copy link
Contributor

@MarkEWaite do you want to merge it?

Copy link
Contributor

@mPokornyETM mPokornyETM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@strangelookingnerd strangelookingnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarkEWaite I checked everything I could and found no major issues so far. The minimal changes to how the badges look after this change are neglectable IMHO.

Feel free to merge this if you are satisfied with the solution, I can push a release after that if you want.

@MarkEWaite
Copy link
Contributor Author

Thanks @strangelookingnerd . I'll merge it and let you run the release.

@MarkEWaite MarkEWaite merged commit db43b1b into jenkinsci:master May 21, 2024
19 checks passed
@MarkEWaite MarkEWaite deleted the style-short-text-as-before branch May 21, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon size constraints introduced by Badge 1.11 are applied also to text boxes
3 participants