Skip to content

Improve Color Mode Documentation and Notification Mechanism for Plugins #18006

@iDebugAll

Description

@iDebugAll

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.

Metadata

Metadata

Assignees

Labels

complexity: lowRequires minimal effort to implementstatus: acceptedThis issue has been accepted for implementationtopic: pluginsRelates to the plugins frameworktype: featureIntroduction of new functionality to the application

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions