mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
This commit is contained in:
parent
3ecb904e37
commit
4ce47e778b
14
docs/plugins/development/user-interface.md
Normal file
14
docs/plugins/development/user-interface.md
Normal file
@ -0,0 +1,14 @@
|
||||
# User Interface
|
||||
|
||||
## Light & Dark Mode
|
||||
|
||||
The NetBox user interface supports toggling between light and dark versions of the theme. If needed, a plugin can determine the currently active color theme by inspecting `window.localStorage['netbox-color-mode']`, which will indicate either `light` or `dark`.
|
||||
|
||||
Additionally, when the color scheme is toggled by the user, a custom event `netbox.colorModeChanged` indicating the new scheme is dispatched. A plugin can listen for this event if needed to react to the change:
|
||||
|
||||
```typescript
|
||||
window.addEventListener('netbox.colorModeChanged', e => {
|
||||
const customEvent = e as CustomEvent<ColorModeData>;
|
||||
console.log('New color mode:', customEvent.detail.netboxColorMode);
|
||||
});
|
||||
```
|
@ -144,6 +144,7 @@ nav:
|
||||
- Search: 'plugins/development/search.md'
|
||||
- Event Types: 'plugins/development/event-types.md'
|
||||
- Data Backends: 'plugins/development/data-backends.md'
|
||||
- User Interface: 'plugins/development/user-interface.md'
|
||||
- REST API: 'plugins/development/rest-api.md'
|
||||
- GraphQL API: 'plugins/development/graphql-api.md'
|
||||
- Background Jobs: 'plugins/development/background-jobs.md'
|
||||
|
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -43,6 +43,11 @@ function updateElements(targetMode: ColorMode): void {
|
||||
export function setColorMode(mode: ColorMode): void {
|
||||
storeColorMode(mode);
|
||||
updateElements(mode);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent<ColorModeData>('netbox.colorModeChanged', {
|
||||
detail: { netboxColorMode: mode },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
3
netbox/project-static/src/global.d.ts
vendored
3
netbox/project-static/src/global.d.ts
vendored
@ -79,3 +79,6 @@ type FormControls = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
||||
|
||||
type ColorMode = 'light' | 'dark';
|
||||
type ColorModePreference = ColorMode | 'none';
|
||||
type ColorModeData = {
|
||||
netboxColorMode: ColorMode;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user