Skip to content

fix: also replace colors in rgb() notation in main.css - #10

Merged
paulmueller merged 1 commit into
DCOR-dev:masterfrom
paulmueller-agent:fix-css-rgb-colors
Nov 3, 2026
Merged

paulmueller merged 1 commit into
DCOR-dev:masterfrom
paulmueller-agent:fix-css-rgb-colors

Conversation

@paulmueller-agent

Copy link
Copy Markdown

Required for the upgrade to CKAN 2.11.7.

Problem

dcor-theme-main-css-branding, which runs as part of dcor develop/dcor inspect, generates dcor_main.css by replacing CKAN's default colors in CKAN's main.css with DCOR colors (color_map, 16 colors). It replaced hex strings only.

CKAN 2.11.7 ships a rebuilt main.css in which many colors are written in rgb() notation with floating point values. Seven of the 16 mapped colors no longer appear in hex at all:

mapped color 2.11.6 (hex) 2.11.7
#00232e 3× rgb(0, 34.6844262295, 45.5) 3×
#003647 3× rgb(0, 54.1229508197, 71) 3×
#235767 1× rgb(35.0476190476, 86.8888888889, 102.9523809524) 1×
#3d97b3 1× rgb(60.9523809524, 151.1111111111, 179.0476190476) 1×
#1b5b6f 2× rgb(27.2, 90.95, 110.5) 2×
#1a5668 9× rgb(25.6, 85.6, 104) 9×
#185062 1× rgb(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() in css/make_dcor_main_css.py, used by main():

  • Replaces hex colors as before.
  • Additionally replaces 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 because rgb(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 and rgb() 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's main.css, no mapped color remains in hex or as a matching rgb() value.

Verified locally:

  • CKAN 2.11.7 (site-packages of the 2.11.7 package): all tests pass.
  • CKAN 2.11.6: the output of replace_colors() for 2.11.6's main.css is identical to that of the previous code, so nothing changes for current instances.

🤖 Generated with Claude Code

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>
@paulmueller
paulmueller merged commit 43cab68 into DCOR-dev:master Nov 3, 2026
3 checks passed
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