Skip to content

Libraries: add a dark theme with a toggle - #380

Open
j-w9 wants to merge 4 commits into
ArduPilot:mainfrom
j-w9:dark-mode
Open

j-w9 wants to merge 4 commits into
ArduPilot:mainfrom
j-w9:dark-mode

Conversation

@j-w9

@j-w9 j-w9 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Follow up to #361. Adds Libraries/theme.js and dark styles in common.css.

  • The theme follows the system setting until the toggle in the page header is used, then the choice is saved in local storage and used on every tool. Nothing else is stored.
  • The toggle is in each page's header beside the GitHub link, drawn the same way.
  • theme.js runs in the head so the page is drawn in the right theme from the start, with no flash of the light page.
  • Plotly plots get a dark template from theme.js, so only Plotly's defaults change and colours set by the tools are kept. This covers 2D and 3D axes, the mode bar, legends and shapes. Traces drawn in black and light grey shaded shapes (Filter Review notch ranges) are swapped for light and dark grey, and back when the theme is changed with plots already drawn.
  • Title tooltips are drawn by the page in the dark theme, as the browser draws them in the system colours.
  • Tabulator tables (Log Finder) have dark styles, and table borders set in code are drawn in the text colour.
  • Landing page screenshots of plots are shown inverted in the dark theme, maps and icons are left as they are.

Light mode is unchanged: every tool below the header is pixel identical to master with a log loaded.

Left out: AirspeedFit, AnalyticTune, DFULoader and SysID; VideoOverlay, as its own styles force a light panel; and AILogAnalyzer, GeofenceGenerator, SimpleGCS, TelemetryDashboard and ThrustExpo, which don't use common.css.

Comment thread Libraries/theme.js Resolved
@IamPete1

Copy link
Copy Markdown
Member

The plotly toolbar looks bad.

image

@IamPete1

Copy link
Copy Markdown
Member

Also I think its worth doing a better job than a standard button shoved up in the corner. This might mean you have to add the element from the individual HTML rather than injecting it from the script.

@IamPete1

Copy link
Copy Markdown
Member

LogFinder table looks bad in dark mode too.

MAGFit has hard coded black lines which disappear.

image

Comment thread DFULoader/index.html Resolved
@IamPete1

Copy link
Copy Markdown
Member

The landing pages look quite bad because all the screen shots have white backgrounds. Also the dev tools icon on the main page disapears.

@IamPete1

Copy link
Copy Markdown
Member

The standard html popups look bad.

image

@IamPete1

Copy link
Copy Markdown
Member

PID review param table disappears.

image

@IamPete1

Copy link
Copy Markdown
Member

Filter reivew notch lines are black and disapear.

image

Comment thread SysID/index.html Resolved
@IamPete1

Copy link
Copy Markdown
Member

SCurve tool has another hard coded black line that disapears.

@IamPete1

IamPete1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Mostly looks good, but if were going to do it then we have to make sure that everything works. I have not had a in-dept look but I have found lots of little issues.

Please actually check each tool carefully, don't just fire off AI on my comments.

@j-w9

j-w9 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Fair point, I went through every tool again in both themes with logs loaded and changed the approach. Plots now get a dark Plotly template from theme.js rather than CSS overrides of Plotly's colours, which also covers the mode bar, 3D axes (Rotation Check, SCurve and Hardware Report were barely readable) and shape lines. Black traces and the light grey notch ranges are swapped for light and dark grey, and swapped back if the theme is changed with plots drawn. The toggle is now in each page's header next to the GitHub link. Title tooltips are drawn by the page in dark mode, Log Finder's table has dark styles, table borders follow the text colour (PID Review), and the landing page screenshots are inverted with their hues kept. Light mode is pixel identical to master below the header on every tool with a log loaded.

@AP-Review

AP-Review commented Nov 22, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-22)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 097b5cc7a7.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/380/1.html#prWebTools-380

The dark theme works across the themed tools, and most of IamPete1's earlier items are fixed, but the SCurve black line is still black and a few smaller issues remain.

Should fix

  • Libraries/theme.js:51: SCurve black line, is_black() misses rgba(0, 0, 0, 1), which SCurveTool.js:449 uses for the target path when all colour options are unchecked, so it stays black in dark mode. Accept opaque rgba black too.
  • Libraries/theme.js:153: Plotly.redraw throws on a purged div, which keeps the js-plotly-plot class but has no data. AirspeedFit purges its result plots when a recalculation gives no fit, after which the theme toggle throws an uncaught error. Skip divs with no gd.data.
  • Libraries/theme.js:248: the toggle does nothing when localStorage throws, because the choice is only kept in storage. Keep an in-memory choice for the page.
  • AirspeedFit/index.html:8: AirspeedFit's .warn (#b30000) and #555 hint/status text are about 2.3-2.4:1 on the dark background. Add dark overrides.
  • Libraries/theme.js:35: the transparent dark paper_bgcolor makes PNG downloads transparent with near-white text, unreadable on white pages. Use the opaque page colour (#181a1b).
Minor (2)
  • Libraries/theme.js:120: new plots take their theme from localStorage, not from the page, so toggling in another tool tab makes later plots here not match the page. Use root.dataset.theme, or call apply() on the storage event.
  • Libraries/theme.js:164: hide_tooltip() puts back the title saved at hover time, overwriting a title the app changed meanwhile (e.g. HardwareReport's minimal config labels). A removed hovered element also leaves the tooltip shown.

j-w9 added 2 commits November 22, 2026 11:13
theme.js applies the theme before the page is drawn: it follows the
system setting until the toggle in the page header is used, then the
choice is saved and used on every tool.

The dark styles are in common.css. Plotly plots are themed by replacing
only Plotly's default colours, so colours set by the tools are kept and
no plotting code changes.

VideoOverlay is left out for now as its own styles force a light panel.
…ach page header

Replace the CSS overrides of Plotly's colours with a dark template that
theme.js applies to every plot, so 3D axes, the mode bar and shape lines
are themed too. Black traces and light grey shaded shapes are swapped
for their dark theme equivalents and back when the theme changes.

The toggle is now part of each page header, beside the GitHub link.
Title tooltips are drawn by the page in the dark theme, as the browser
draws them in the system colours. Add dark styles for Tabulator tables,
draw table borders in the text colour, and show the landing page plot
screenshots inverted in the dark theme.

DFULoader and SysID are left out.
@IamPete1

Copy link
Copy Markdown
Member

Airspeed fit and Analytic tune are not mine either.

…out storage

Use an opaque dark paper color so downloaded images are readable, follow a theme change made in another tab, and keep a title the page changed while its tooltip was shown.
@j-w9

j-w9 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

removed both, they're left out like DFU and SysID now

@AP-Review

AP-Review commented Nov 22, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-22)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 7c441a9965.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/380/2.html#prWebTools-380

The dark theme is close: the two remaining issues are low contrast in code that came in with the rebase onto newer main.
Since the last review, SCurve's black path, the purged-plot toggle error, the toggle without localStorage, the transparent PNG paper, cross-tab plot themes and the tooltip title handling are all fixed, and AirspeedFit/AnalyticTune are no longer themed.

Should fix

  • PIDReview/PIDReview.js:1120 and HardwareReport/HardwareReport.js:1884: the step-stats and configured-outputs tables still use 1px solid #000, so their cell borders are black on the dark background (1.2:1). Use 1px solid as the PR already does at PIDReview/PIDReview.js:608 and HardwareReport/HardwareReport.js:1596.
  • FilterReview/FilterReview.js:296: the low usable-data warning is inline #c00000, which is 2.7:1 on the dark background now that FilterReview/index.html:8 loads theme.js. Use a class with a lighter red under html[data-theme="dark"].

A tooltip left showing after its element is removed, until the mouse next moves, was not counted: no reachable path keeps the pointer still.

@AP-Review

AP-Review commented Nov 22, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-22)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 5245fbc00b.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/380/3.html#prWebTools-380

The dark theme is ready apart from one small light-mode side effect of the latest border fix.
Since the last review, the step-stats and configured-outputs table borders and FilterReview's usable-data warning are fixed for the dark background.

Minor (1)
  • PIDReview/PIDReview.js:1120: with 1px solid the border takes the cell's text colour, and the Test name cells are coloured with their trace colour, so their borders are now blue/orange/red in both themes (light mode is no longer identical to main here). Colour a <span> for the name instead of the cell.

The tooltip that stays visible after its element is removed, until the mouse moves, is still not counted: no path was found that removes an element while the pointer stays still.

…k theme

Tables added to PIDReview and HardwareReport since used black borders, and the FilterReview usable data warning a dark red.
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head d158039c13.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/380/4.html#prWebTools-380

No problems found at this head; the dark theme looks ready to merge.
Since the last review, the step-stats name colour moved to a <span>, so the table borders no longer pick up the trace colours and the light-mode table is pixel-identical to main again.

The tooltip that stays visible after its element is removed, until the mouse moves, is still not counted: no path was found that removes an element while the pointer stays still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants