Improve Color Mode Documentation and Notification Mechanism for Plugins #10471

Closed
opened 2025-12-29 21:31:56 +01:00 by adam · 2 comments
Owner

Originally created by @iDebugAll on GitHub (Nov 13, 2024).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.1.4

Feature type

Change to existing functionality

Triage priority

I volunteer to perform this work (if approved)

Proposed functionality

  1. Emit CustomEvent on Color Mode Change. An event-driven workflow will simplify color mode handling for plugins and decouple it from any existing UI elements. This should involve only a single-line addition in netbox/project-static/src/colorMode.ts:

    export function setColorMode(mode: ColorMode): void {
      storeColorMode(mode);
      updateElements(mode);
      window.dispatchEvent(new CustomEvent('netbox.colorModeChanged', { netboxColorMode: mode }));
    }
    
  2. Update the Plugin Development Guide. Document how the color mode can be detected on load using window.localStorage['netbox-color-mode'] and managed on change using the proposed event-driven approach.

Use case

This functionality should allow plugins to dynamically update visual elements, such as images, that don’t currently adjust with color mode changes. Additionally, since color mode behavior is undocumented, standardizing this would improve consistency across plugins and streamline plugin development.

Database changes

No.

External dependencies

No.

Originally created by @iDebugAll on GitHub (Nov 13, 2024). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.1.4 ### Feature type Change to existing functionality ### Triage priority I volunteer to perform this work (if approved) ### Proposed functionality 1. **Emit `CustomEvent` on Color Mode Change.** An event-driven workflow will simplify color mode handling for plugins and decouple it from any existing UI elements. This should involve only a single-line addition in `netbox/project-static/src/colorMode.ts`: ```typescript export function setColorMode(mode: ColorMode): void { storeColorMode(mode); updateElements(mode); window.dispatchEvent(new CustomEvent('netbox.colorModeChanged', { netboxColorMode: mode })); } ``` 2. **Update the Plugin Development Guide.** Document how the color mode can be detected on load using `window.localStorage['netbox-color-mode']` and managed on change using the proposed event-driven approach. ### Use case This functionality should allow plugins to dynamically update visual elements, such as images, that don’t currently adjust with color mode changes. Additionally, since color mode behavior is undocumented, standardizing this would improve consistency across plugins and streamline plugin development. ### Database changes No. ### External dependencies No.
adam added the status: acceptedtype: featuretopic: pluginscomplexity: low labels 2025-12-29 21:31:56 +01:00
adam closed this issue 2025-12-29 21:31:56 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 9, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jul 9, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Aug 6, 2025):

Tagging this for v4.4 as it's technically an extension of the plugins API.

@jeremystretch commented on GitHub (Aug 6, 2025): Tagging this for v4.4 as it's technically an extension of the plugins API.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10471