Repository navigation
fix: also replace colors in rgb() notation in main.css - #10
Merged
Merged
Conversation
CKAN 2.11.7 writes several colors in main.css in `rgb(r, g, b)` notation with floating point values (e.g. `rgb(25.6, 85.6, 104)` instead of `#1a5668`). Seven of the 16 colors in `color_map` only appear in that notation, so the DCOR branding (e.g. the header) would partly be lost when generating dcor_main.css for CKAN 2.11.7. Colors in rgb notation are now replaced as well if all channels are within 1 of a mapped color (the closest one is used). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Required for the upgrade to CKAN 2.11.7.
Problem
dcor-theme-main-css-branding, which runs as part ofdcor develop/dcor inspect, generatesdcor_main.cssby replacing CKAN's default colors in CKAN'smain.csswith DCOR colors (color_map, 16 colors). It replaced hex strings only.CKAN 2.11.7 ships a rebuilt
main.cssin which many colors are written inrgb()notation with floating point values. Seven of the 16 mapped colors no longer appear in hex at all:#00232ergb(0, 34.6844262295, 45.5)3×#003647rgb(0, 54.1229508197, 71)3×#235767rgb(35.0476190476, 86.8888888889, 102.9523809524)1×#3d97b3rgb(60.9523809524, 151.1111111111, 179.0476190476)1×#1b5b6frgb(27.2, 90.95, 110.5)2×#1a5668rgb(25.6, 85.6, 104)9×#185062rgb(24, 80.25, 97.5)1×After upgrading to 2.11.7, the DCOR branding would therefore be partly lost: the dark header/masthead and several link and button colors.
Fix
New function
replace_colors()incss/make_dcor_main_css.py, used bymain():rgb(r, g, b)colors if all channels are within 1 of a mapped color. If several mapped colors match, the closest one is used. This is needed becausergb(27.2, 90.95, 110.5)is within 1 of both#1b5b6f(the correct one) and#1b5a6e. Plain rounding would not work either: 110.5 rounds to 110, not 111.Tests (
tests/test_css.py)test_replace_colors: hex andrgb()notation, a channel exactly 0.5 off, the ambiguous case, and that other colors are left alone.test_replace_colors_ckan_main_css: with the installed CKAN'smain.css, no mapped color remains in hex or as a matchingrgb()value.Verified locally:
replace_colors()for 2.11.6'smain.cssis identical to that of the previous code, so nothing changes for current instances.🤖 Generated with Claude Code