Skip to content

Conversation

@atif09
Copy link

@atif09 atif09 commented Nov 25, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1162 .

Description of Changes

Replaces hardcoded color literals (hex & rgba) in the UI CSS with the project's semantic CSS variables defined in openwisp-utils#516

Screenshot

N/A

@atif09 atif09 changed the title Replace hardcoded colors with CSS variables and format css files Replace hardcoded colors with CSS variables and format CSS files Nov 25, 2025
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@coderabbitai review

piyushdev04 and others added 2 commits January 14, 2026 18:53
…#442

Problem: Some tests in TestConfigApi assumed a fixed global Template count;
which fail when other modules like openwisp-monitoring add new templates.

Fix: Updated template-related assertions in test_api.py to compare
counts relatively (eg: capture initial_count, assert +1).

Fixes openwisp#442

* [tests] Remove unnecessary test settings file openwisp#442

The test_settings override is not required to fix the template
counting issue and adds unrelated changes. Removing it to keep
the fix minimal and focused.

Fixes openwisp#442
@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This pull request replaces hard-coded color values with CSS custom properties across six CSS files in openwisp-controller. Affected selectors include form elements, JSON editors, overlays, dialogs, buttons, tables, preformatted text, and other UI components, switching explicit hex/RGBA values to theme variables (e.g., var(--ow-...)). No functional logic, control flow, or public API declarations were modified.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive PR description covers key sections but is incomplete: checklist partially completed, issue referenced, and changes described. However, manual testing and test updates are not checked, and documentation updates are explicitly unchecked. Clarify whether manual testing was actually completed (checkbox appears unchecked), and confirm if test cases or documentation updates are needed for this styling refactor.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarizes the main change: replacing hardcoded colors with CSS variables and formatting CSS files, which directly corresponds to the changeset.
Linked Issues check ✅ Passed Changes fully address issue #1162 by replacing hardcoded colors across five CSS files with semantic CSS variables from openwisp-utils, aligning with the stated solution of unified theming.
Out of Scope Changes check ✅ Passed All changes are strictly scoped to CSS color replacement and formatting as specified in #1162; no unrelated functional or structural modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openwisp_controller/config/static/config/css/lib/jsonschema-ui.css (1)

383-391: Missed hardcoded color value.

Line 386 still contains background-color: white; which should be replaced with var(--ow-color-white) to align with the PR objective of eliminating hardcoded colors.

Proposed fix
 .jsoneditor-wrapper div.jsoneditor .modal {
   position: absolute;
   z-index: 10;
-  background-color: white;
+  background-color: var(--ow-color-white);
   border: 1px solid var(--ow-color-fg-light);
   padding-bottom: 10px;
   width: 340px;
   margin-left: -215px;
 }
🤖 Fix all issues with AI agents
In `@openwisp_controller/config/static/config/css/admin.css`:
- Around line 119-127: The hover rule for .djnjc-overlay .close currently sets
the same background as the base .djnjc-overlay .close so there is no visible
change; update the hover to produce a visible effect by either (a) using an
existing token like var(--ow-color-primary-light) (plus a contrasting color
change such as color or border) or (b) applying a visual tweak such as reduced
opacity (e.g. background-color with rgba/opacity) or a slight
transform/box-shadow, or (c) add and define a new token (e.g.
--ow-color-primary-dark) in your theme if you need a darker variant; modify the
.djnjc-overlay .close:hover selector accordingly and ensure contrast remains
accessible.

In `@openwisp_controller/connection/static/connection/css/command-inline.css`:
- Around line 121-134: The hover/focus rules for `#ow-command-confirm-yes` and
`#ow-command-confirm-no` currently reuse the same background variables and provide
no visual change; replace the nonexistent hover vars with existing tokens or
other visual feedback: update the hover/focus selectors for
`#ow-command-confirm-yes` to use a darker/contrasting variable (e.g.
var(--ow-color-fg-dark) or a semi-transparent overlay) or add a subtle
outline/box-shadow and do the same for `#ow-command-confirm-no` (use a darker
danger/contrast token or opacity change) so users get clear hover/focus feedback
without introducing undefined variables.
🧹 Nitpick comments (4)
openwisp_controller/config/static/config/css/lib/advanced-mode.css (4)

112-114: Semantic concern: Using danger color for number values.

Similar to the URL hover issue, --ow-btn-danger-bg is semantically meant for destructive actions. While JSON editors often use reddish colors for numbers, reusing the "danger" variable could cause confusion in theming. If a dedicated --ow-color-number or similar doesn't exist, consider documenting this choice or using a more neutral variable.


426-431: Consider using an error/warning color for error display.

The .jsoneditor-text-errors element displays validation errors, but uses --ow-color-fg-lighter (neutral) instead of an error-related variable. While this provides a subtle appearance, using --ow-color-error-bg or similar (if available) would better communicate the error state semantically.


612-617: Semantic concern: Using danger color for selected state.

--ow-btn-danger-bg for .jsoneditor-selected button background may confuse users, as red typically signals danger. Consider using --ow-color-primary or a dedicated selection color variable for better semantic clarity.


75-78: Semantic mismatch: Using danger color for link hover state

--ow-btn-danger-bg is reserved for destructive actions (delete buttons, error states, validation errors). Using it for URL hover/focus states creates confusing semantics—users may interpret the red color as an error or warning. URL hover states should use a neutral or primary color variable instead to maintain proper visual hierarchy and UX clarity.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee85ec1 and a3064b0.

📒 Files selected for processing (6)
  • openwisp_controller/config/static/config/css/admin.css
  • openwisp_controller/config/static/config/css/lib/advanced-mode.css
  • openwisp_controller/config/static/config/css/lib/jsonschema-ui.css
  • openwisp_controller/config/static/import_export/import-openwisp.css
  • openwisp_controller/connection/static/connection/css/command-inline.css
  • openwisp_controller/subnet_division/static/subnet-division/css/subnet-division.css
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
🔇 Additional comments (22)
openwisp_controller/config/static/config/css/lib/jsonschema-ui.css (2)

15-25: LGTM!

Border and button background colors are appropriately replaced with semantic CSS variables (--ow-color-fg-light, --ow-btn-danger-bg).


491-498: LGTM!

The inline-related header styling correctly uses semantic variables for text color, background, and borders, providing consistent theming.

openwisp_controller/subnet_division/static/subnet-division/css/subnet-division.css (2)

1-4: LGTM!

The readonly input styling correctly uses overlay variables for border and background, replacing the previous rgba values.


5-11: Verify if openwisp-utils provides warning-specific color variables.

The class .help-text-warning uses --ow-color-primary-light for its background. While using a primary brand color for warning context may lack semantic clarity, this concern depends on whether openwisp-utils (v1.3) provides dedicated warning or alert color variables. No warning-specific variables are used anywhere in openwisp-controller, so verify with the openwisp-utils documentation whether --ow-color-warning, --ow-color-alert, or similar variables exist and should be used here instead.

openwisp_controller/config/static/config/css/admin.css (3)

5-23: LGTM!

The preformatted and JSON editor text styling correctly uses semantic variables for foreground/background colors, maintaining the monospace code appearance.


30-33: LGTM!

Readonly input styling matches the same pattern used in subnet-division.css, ensuring consistency across the codebase.


249-279: LGTM!

Tab styling correctly uses semantic variables for different states (default, hover, current), providing consistent theming for navigation elements.

openwisp_controller/connection/static/connection/css/command-inline.css (2)

41-52: LGTM!

The command overlay and dialog styling appropriately uses semantic variables for backdrop, border, and shadow colors.


101-114: LGTM!

The confirmation dialog styling correctly uses semantic variables for background and text colors, with appropriate font-family declaration.

openwisp_controller/config/static/import_export/import-openwisp.css (1)

15-38: The implementation is correct. Using CSS variables within a @media (prefers-color-scheme: dark) block is the recommended pattern for openwisp-utils, as the variables themselves are static light-mode values and are designed to be overridden in prefers-color-scheme media queries. The code correctly forces consistent light-theme colors when the browser requests dark mode, which aligns with the stated intent that dark theme is not yet fully supported in OpenWISP.

openwisp_controller/config/static/config/css/lib/advanced-mode.css (12)

84-103: LGTM!

Consistent use of --ow-color-fg-lighter for highlight and focus states provides visual coherence.


155-162: LGTM!

Appropriate use of neutral foreground variables for button focus states.


167-179: LGTM!

Good semantic usage—primary color for the container border establishes visual hierarchy, and darker foreground for text ensures readability.


289-299: LGTM!

Appropriate variable choices for the popover: dark background with white text ensures good contrast, and overlay variable for shadows is semantically correct.


325-355: LGTM!

Arrow border colors correctly match the popover background for visual consistency.


461-472: LGTM!

Appropriate use of neutral border and overlay variables for the context menu.


704-714: LGTM!

Primary color for the menu bar is semantically appropriate and establishes clear visual hierarchy.


730-740: LGTM!

Consistent use of light overlay for interactive states on the dark menu background.


787-803: LGTM!

Good contrast choices for the exit button with appropriate hover state feedback.


898-908: LGTM!

White background for full-screen mode is appropriate.


915-924: LGTM!

White text for menu labels maintains proper contrast against the primary-colored menu bar.


531-542: Formatting changes look acceptable.

These multi-line selector reformats appear to be Prettier output. While the line-per-selector style increases line count, it improves readability for complex selectors.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

…1162

Replaced all hardcoded color literals (gray, lightgray, green, yellow, white)
in advanced-mode.css and jsonschema-ui.css with semantic CSS variables from
openwisp-utils for consistent theming support.

Changes:
- advanced-mode.css: Replaced 14 hardcoded colors with appropriate CSS variables
  (--ow-color-fg-medium, --ow-color-fg-light, --ow-color-success,
   --ow-color-warning, --ow-color-white)
- jsonschema-ui.css: Replaced 1 hardcoded white with --ow-color-white

This completes the color variable migration started in the initial commit.

Fixes openwisp#1162
@atif09 atif09 marked this pull request as draft January 15, 2026 15:20
Replaced hardcoded color values with OpenWISP CSS variables
to support theming and maintain consistency with the design system.

Fixes openwisp#1162
@coveralls
Copy link

coveralls commented Jan 15, 2026

Coverage Status

coverage: 98.641%. remained the same
when pulling 3351c17 on atif09:issues/1162-replace-hardcoded-colors-with-ow-vars
into 6697a3a on openwisp:master.

@atif09
Copy link
Author

atif09 commented Jan 16, 2026

  • the comment by code rabbit outside the diff which was about missing the hard coded values from jsonschema-ui.css has been covered in the commit(7ee0f34).
  • as for the nitpick comments which are about semantic concerns, please let me know if those changes need to be implemented in this PR

@atif09 atif09 marked this pull request as ready for review January 16, 2026 10:30
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.

[chores] Use theme colors from openwisp-utils variables

4 participants