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

Use Jenkins theme CSS color variables for inverse text #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdknight
Copy link

The original support for negative/inverse text uses a combination off currentColor and a bright-level-7 value. When using a default Jenkins theme, these color definitions work as expected. However, clients using the dark theme may not be able to read the text since both the text and background are a bright color.

Modern Jenkins themes provide CSS color variables. Instead of trying to rely on currentColor, use the default text color (var(--text-color)) and the default background color (var(--background)). This should allow negative/inverse text to render appropriately no matter what theme mode is used.

Testing done

With unit test changes that seemed to be right (please check), perform a mvn test to confirm expected results.

Started up a fresh Jenkins container instance and setup a pipeline job with the following:

node {
    stage('Build') {
        ansiColor('xterm') {
            echo 'This is a test.'
            echo '\033[7mThis is a test.\033[0m'
            echo 'This is a test.'
        }
    }
}

Before the changes, installed the ansicolor plugin from the online and observed the issue:

image

Then uninstalled the plugin, restarted and manually installed a newly built ansicolor.hpi plugin. Navigated back to the job results and observed that the inversed text could be read:

image

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

The original support for negative/inverse text uses a combination off
`currentColor` and a bright-level-7 value. When using a default Jenkins
theme, these color definitions work as expected. However, clients using
the dark theme may not be able to read the text since both the text and
background are a bright color.

Modern Jenkins themes provide CSS color variables. Instead of trying to
rely on `currentColor`, use the default text color (`var(--text-color)`)
and the default background color (`var(--background)`). This should
allow negative/inverse text to render appropriately no matter what
theme mode is used.

Signed-off-by: James Knight <[email protected]>
@jdknight jdknight requested a review from a team as a code owner November 11, 2024 08:14
@dblock
Copy link
Member

dblock commented Nov 11, 2024

Very nice! Add a line to https://github.com/jenkinsci/ansicolor-plugin/blob/master/CHANGELOG.md?

Let's increment the version to 1.1 as part of this PR as well, it's a big change.

@jdknight
Copy link
Author

Add a line to https://github.com/jenkinsci/ansicolor-plugin/blob/master/CHANGELOG.md?

I do not mind adding some information there, but it seemed that as of v1.0.3, change log entries are only being populated inside GitHub releases.

@dblock
Copy link
Member

dblock commented Nov 12, 2024

Add a line to https://github.com/jenkinsci/ansicolor-plugin/blob/master/CHANGELOG.md?

I do not mind adding some information there, but it seemed that as of v1.0.3, change log entries are only being populated inside GitHub releases.

ah yes, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants